You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/07/15 05:08:22 UTC
[echarts] branch dataset-perf updated: refact(data): getValues from
storage. add unit test
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch dataset-perf
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/dataset-perf by this push:
new 1d8da4a refact(data): getValues from storage. add unit test
1d8da4a is described below
commit 1d8da4a9557d8f50128991d494f8e4cfa138a261
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Jul 15 13:07:15 2021 +0800
refact(data): getValues from storage. add unit test
---
src/data/DataStorage.ts | 25 +++++++++++++++++++++++++
src/data/SeriesData.ts | 16 ++++------------
src/data/helper/sourceManager.ts | 2 +-
3 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/src/data/DataStorage.ts b/src/data/DataStorage.ts
index bb6e473..63a764e 100644
--- a/src/data/DataStorage.ts
+++ b/src/data/DataStorage.ts
@@ -447,6 +447,31 @@ class DataStorage {
return dimStore ? dimStore[this.getRawIndex(idx)] : NaN;
}
+ getValues(idx: number): ParsedValue[];
+ getValues(dimensions: readonly DimensionIndex[], idx?: number): ParsedValue[]
+ getValues(dimensions: readonly DimensionIndex[] | number, idx?: number): ParsedValue[] {
+ const values = [];
+ let dimArr: DimensionIndex[] = [];
+ if (idx == null) {
+ idx = dimensions as number;
+ // TODO get all from store?
+ dimensions = [];
+ // All dimensions
+ for (let i = 0; i < this._dimensions.length; i++) {
+ dimArr.push(i);
+ }
+ }
+ else {
+ dimArr = dimensions as DimensionIndex[];
+ }
+
+ for (let i = 0, len = dimArr.length; i < len; i++) {
+ values.push(this.get(dimArr[i], idx));
+ }
+
+ return values;
+ }
+
/**
* @param dim concrete dim
*/
diff --git a/src/data/SeriesData.ts b/src/data/SeriesData.ts
index ad280b0..72e6c6e 100644
--- a/src/data/SeriesData.ts
+++ b/src/data/SeriesData.ts
@@ -656,18 +656,10 @@ class SeriesData<
getValues(idx: number): ParsedValue[];
getValues(dimensions: readonly DimensionName[], idx: number): ParsedValue[];
getValues(dimensions: readonly DimensionName[] | number, idx?: number): ParsedValue[] {
- const values = [];
- if (!zrUtil.isArray(dimensions)) {
- idx = dimensions as number;
- // TODO get all from store?
- dimensions = this.dimensions;
- }
-
- for (let i = 0, len = dimensions.length; i < len; i++) {
- values.push(this.get(dimensions[i], idx));
- }
-
- return values;
+ const store = this._store;
+ return zrUtil.isArray(dimensions)
+ ? store.getValues(map(dimensions, dim => this._getStoreDimIndex(dim)), idx)
+ : store.getValues(dimensions as number);
}
/**
diff --git a/src/data/helper/sourceManager.ts b/src/data/helper/sourceManager.ts
index da73f55..3094ed5 100644
--- a/src/data/helper/sourceManager.ts
+++ b/src/data/helper/sourceManager.ts
@@ -369,7 +369,7 @@ export class SourceManager {
*/
getDataStorage(): DataStorage | undefined {
if (__DEV__) {
- assert(isSeries(this._sourceHost), 'Can only call getDataStorage on series source manager.')
+ assert(isSeries(this._sourceHost), 'Can only call getDataStorage on series source manager.');
}
const source = this.getSource(0);
const dimensionsDefine = source.dimensionsDefine;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org