@visactor/vchart 1.1.2 → 1.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +420 -163
- package/build/index.min.js +1 -1
- package/cjs/chart/area/area.js +3 -1
- package/cjs/chart/area/area.js.map +1 -1
- package/cjs/chart/base-chart.d.ts +7 -2
- package/cjs/chart/base-chart.js +51 -23
- package/cjs/chart/base-chart.js.map +1 -1
- package/cjs/chart/interface/chart.d.ts +1 -0
- package/cjs/chart/interface/chart.js.map +1 -1
- package/cjs/chart/line/line.js +3 -1
- package/cjs/chart/line/line.js.map +1 -1
- package/cjs/chart/radar/radar.js +3 -1
- package/cjs/chart/radar/radar.js.map +1 -1
- package/cjs/chart/sequence/sequence.js +5 -3
- package/cjs/chart/sequence/sequence.js.map +1 -1
- package/cjs/chart/stack.js +3 -3
- package/cjs/chart/stack.js.map +1 -1
- package/cjs/compile/compiler.js +9 -5
- package/cjs/compile/compiler.js.map +1 -1
- package/cjs/compile/interface/compiler.d.ts +1 -0
- package/cjs/compile/interface/compiler.js.map +1 -1
- package/cjs/component/axis/cartesian/axis.js +1 -1
- package/cjs/component/axis/cartesian/axis.js.map +1 -1
- package/cjs/component/axis/interface.d.ts +25 -27
- package/cjs/component/axis/interface.js.map +1 -1
- package/cjs/component/axis/polar/axis.js +2 -2
- package/cjs/component/axis/polar/axis.js.map +1 -1
- package/cjs/component/geo/geo-coordinate.js +1 -1
- package/cjs/component/geo/geo-coordinate.js.map +1 -1
- package/cjs/component/geo/projection.js +1 -2
- package/cjs/component/geo/projection.js.map +1 -1
- package/cjs/component/indicator/indicator.js +1 -1
- package/cjs/component/indicator/indicator.js.map +1 -1
- package/cjs/component/marker/base-marker.js +1 -1
- package/cjs/component/marker/base-marker.js.map +1 -1
- package/cjs/component/marker/interface.d.ts +2 -2
- package/cjs/component/marker/interface.js.map +1 -1
- package/cjs/component/tooltip/processor/dimension-tooltip.js +3 -2
- package/cjs/component/tooltip/processor/dimension-tooltip.js.map +1 -1
- package/cjs/constant/event.d.ts +2 -0
- package/cjs/constant/event.js +2 -1
- package/cjs/constant/event.js.map +1 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/core/vchart.d.ts +6 -0
- package/cjs/core/vchart.js +72 -27
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/data/initialize.d.ts +2 -1
- package/cjs/data/initialize.js +8 -5
- package/cjs/data/initialize.js.map +1 -1
- package/cjs/data/transforms/legend-data/discrete/discrete.js +3 -2
- package/cjs/data/transforms/legend-data/discrete/discrete.js.map +1 -1
- package/cjs/data/transforms/sankey.d.ts +2 -0
- package/cjs/data/transforms/sankey.js +9 -1
- package/cjs/data/transforms/sankey.js.map +1 -1
- package/cjs/event/events/dimension/base.js +6 -4
- package/cjs/event/events/dimension/base.js.map +1 -1
- package/cjs/event/events/dimension/interface.js.map +1 -1
- package/cjs/event/events/dimension/util/cartesian.d.ts +2 -2
- package/cjs/event/events/dimension/util/cartesian.js +12 -11
- package/cjs/event/events/dimension/util/cartesian.js.map +1 -1
- package/cjs/event/events/dimension/util/common.d.ts +1 -1
- package/cjs/event/events/dimension/util/common.js +13 -6
- package/cjs/event/events/dimension/util/common.js.map +1 -1
- package/cjs/layout/base-layout.d.ts +3 -0
- package/cjs/layout/base-layout.js +8 -4
- package/cjs/layout/base-layout.js.map +1 -1
- package/cjs/layout/grid-layout/grid-layout.d.ts +3 -1
- package/cjs/layout/grid-layout/grid-layout.js +3 -2
- package/cjs/layout/grid-layout/grid-layout.js.map +1 -1
- package/cjs/layout/interface.d.ts +2 -1
- package/cjs/layout/interface.js.map +1 -1
- package/cjs/model/interface.d.ts +1 -4
- package/cjs/model/interface.js.map +1 -1
- package/cjs/model/layout-item.d.ts +0 -3
- package/cjs/model/layout-item.js +1 -8
- package/cjs/model/layout-item.js.map +1 -1
- package/cjs/series/area/area.js +5 -4
- package/cjs/series/area/area.js.map +1 -1
- package/cjs/series/area/interface.d.ts +1 -0
- package/cjs/series/area/interface.js.map +1 -1
- package/cjs/series/base/base-series.js +2 -4
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/geo/geo.js +3 -3
- package/cjs/series/geo/geo.js.map +1 -1
- package/cjs/series/line/interface.d.ts +4 -2
- package/cjs/series/line/interface.js.map +1 -1
- package/cjs/series/line/line.js +5 -3
- package/cjs/series/line/line.js.map +1 -1
- package/cjs/series/map/map.js +6 -6
- package/cjs/series/map/map.js.map +1 -1
- package/cjs/series/mixin/line-mixin.d.ts +1 -1
- package/cjs/series/mixin/line-mixin.js +3 -2
- package/cjs/series/mixin/line-mixin.js.map +1 -1
- package/cjs/series/radar/interface.d.ts +1 -0
- package/cjs/series/radar/interface.js.map +1 -1
- package/cjs/series/radar/radar.js +4 -4
- package/cjs/series/radar/radar.js.map +1 -1
- package/cjs/series/sankey/sankey.js +7 -4
- package/cjs/series/sankey/sankey.js.map +1 -1
- package/cjs/series/scatter/scatter.js +7 -4
- package/cjs/series/scatter/scatter.js.map +1 -1
- package/cjs/series/sunburst/sunburst.d.ts +1 -1
- package/cjs/series/word-cloud/base.d.ts +7 -0
- package/cjs/series/word-cloud/base.js +8 -3
- package/cjs/series/word-cloud/base.js.map +1 -1
- package/cjs/theme/buildin-theme/light/series/area.js +5 -0
- package/cjs/theme/buildin-theme/light/series/area.js.map +1 -1
- package/cjs/theme/buildin-theme/light/series/line.js +5 -0
- package/cjs/theme/buildin-theme/light/series/line.js.map +1 -1
- package/cjs/theme/buildin-theme/light/series/radar.js +5 -0
- package/cjs/theme/buildin-theme/light/series/radar.js.map +1 -1
- package/cjs/typings/params.d.ts +5 -0
- package/cjs/typings/params.js.map +1 -1
- package/cjs/typings/spec/common.d.ts +8 -2
- package/cjs/typings/spec/common.js.map +1 -1
- package/cjs/typings/visual.d.ts +1 -1
- package/cjs/typings/visual.js.map +1 -1
- package/cjs/util/debug.d.ts +2 -2
- package/cjs/util/debug.js +4 -3
- package/cjs/util/debug.js.map +1 -1
- package/cjs/util/image.d.ts +2 -1
- package/cjs/util/image.js +10 -6
- package/cjs/util/image.js.map +1 -1
- package/cjs/util/math.js +5 -3
- package/cjs/util/math.js.map +1 -1
- package/cjs/util/spec.d.ts +4 -0
- package/cjs/util/spec.js +24 -2
- package/cjs/util/spec.js.map +1 -1
- package/esm/chart/area/area.js +3 -1
- package/esm/chart/area/area.js.map +1 -1
- package/esm/chart/base-chart.d.ts +7 -2
- package/esm/chart/base-chart.js +51 -21
- package/esm/chart/base-chart.js.map +1 -1
- package/esm/chart/interface/chart.d.ts +1 -0
- package/esm/chart/interface/chart.js.map +1 -1
- package/esm/chart/line/line.js +3 -1
- package/esm/chart/line/line.js.map +1 -1
- package/esm/chart/radar/radar.js +3 -1
- package/esm/chart/radar/radar.js.map +1 -1
- package/esm/chart/sequence/sequence.js +5 -3
- package/esm/chart/sequence/sequence.js.map +1 -1
- package/esm/chart/stack.js +3 -3
- package/esm/chart/stack.js.map +1 -1
- package/esm/compile/compiler.js +10 -6
- package/esm/compile/compiler.js.map +1 -1
- package/esm/compile/interface/compiler.d.ts +1 -0
- package/esm/compile/interface/compiler.js.map +1 -1
- package/esm/component/axis/cartesian/axis.js +1 -1
- package/esm/component/axis/cartesian/axis.js.map +1 -1
- package/esm/component/axis/interface.d.ts +25 -27
- package/esm/component/axis/interface.js.map +1 -1
- package/esm/component/axis/polar/axis.js +2 -2
- package/esm/component/axis/polar/axis.js.map +1 -1
- package/esm/component/geo/geo-coordinate.js +1 -1
- package/esm/component/geo/geo-coordinate.js.map +1 -1
- package/esm/component/geo/projection.js +1 -1
- package/esm/component/geo/projection.js.map +1 -1
- package/esm/component/indicator/indicator.js +1 -1
- package/esm/component/indicator/indicator.js.map +1 -1
- package/esm/component/marker/base-marker.js +1 -1
- package/esm/component/marker/base-marker.js.map +1 -1
- package/esm/component/marker/interface.d.ts +2 -2
- package/esm/component/marker/interface.js.map +1 -1
- package/esm/component/tooltip/processor/dimension-tooltip.js +4 -1
- package/esm/component/tooltip/processor/dimension-tooltip.js.map +1 -1
- package/esm/constant/event.d.ts +2 -0
- package/esm/constant/event.js +2 -1
- package/esm/constant/event.js.map +1 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/core/vchart.d.ts +6 -0
- package/esm/core/vchart.js +74 -27
- package/esm/core/vchart.js.map +1 -1
- package/esm/data/initialize.d.ts +2 -1
- package/esm/data/initialize.js +9 -4
- package/esm/data/initialize.js.map +1 -1
- package/esm/data/transforms/legend-data/discrete/discrete.js +4 -1
- package/esm/data/transforms/legend-data/discrete/discrete.js.map +1 -1
- package/esm/data/transforms/sankey.d.ts +2 -0
- package/esm/data/transforms/sankey.js +9 -1
- package/esm/data/transforms/sankey.js.map +1 -1
- package/esm/event/events/dimension/base.js +8 -4
- package/esm/event/events/dimension/base.js.map +1 -1
- package/esm/event/events/dimension/interface.js.map +1 -1
- package/esm/event/events/dimension/util/cartesian.d.ts +2 -2
- package/esm/event/events/dimension/util/cartesian.js +7 -8
- package/esm/event/events/dimension/util/cartesian.js.map +1 -1
- package/esm/event/events/dimension/util/common.d.ts +1 -1
- package/esm/event/events/dimension/util/common.js +14 -6
- package/esm/event/events/dimension/util/common.js.map +1 -1
- package/esm/layout/base-layout.d.ts +3 -0
- package/esm/layout/base-layout.js +8 -4
- package/esm/layout/base-layout.js.map +1 -1
- package/esm/layout/grid-layout/grid-layout.d.ts +3 -1
- package/esm/layout/grid-layout/grid-layout.js +3 -2
- package/esm/layout/grid-layout/grid-layout.js.map +1 -1
- package/esm/layout/interface.d.ts +2 -1
- package/esm/layout/interface.js.map +1 -1
- package/esm/model/interface.d.ts +1 -4
- package/esm/model/interface.js.map +1 -1
- package/esm/model/layout-item.d.ts +0 -3
- package/esm/model/layout-item.js +1 -8
- package/esm/model/layout-item.js.map +1 -1
- package/esm/series/area/area.js +5 -4
- package/esm/series/area/area.js.map +1 -1
- package/esm/series/area/interface.d.ts +1 -0
- package/esm/series/area/interface.js.map +1 -1
- package/esm/series/base/base-series.js +1 -4
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/geo/geo.js +3 -3
- package/esm/series/geo/geo.js.map +1 -1
- package/esm/series/line/interface.d.ts +4 -2
- package/esm/series/line/interface.js.map +1 -1
- package/esm/series/line/line.js +5 -3
- package/esm/series/line/line.js.map +1 -1
- package/esm/series/map/map.js +6 -6
- package/esm/series/map/map.js.map +1 -1
- package/esm/series/mixin/line-mixin.d.ts +1 -1
- package/esm/series/mixin/line-mixin.js +3 -2
- package/esm/series/mixin/line-mixin.js.map +1 -1
- package/esm/series/radar/interface.d.ts +1 -0
- package/esm/series/radar/interface.js.map +1 -1
- package/esm/series/radar/radar.js +4 -4
- package/esm/series/radar/radar.js.map +1 -1
- package/esm/series/sankey/sankey.js +7 -4
- package/esm/series/sankey/sankey.js.map +1 -1
- package/esm/series/scatter/scatter.js +5 -4
- package/esm/series/scatter/scatter.js.map +1 -1
- package/esm/series/sunburst/sunburst.d.ts +1 -1
- package/esm/series/word-cloud/base.d.ts +7 -0
- package/esm/series/word-cloud/base.js +7 -0
- package/esm/series/word-cloud/base.js.map +1 -1
- package/esm/theme/buildin-theme/light/series/area.js +5 -0
- package/esm/theme/buildin-theme/light/series/area.js.map +1 -1
- package/esm/theme/buildin-theme/light/series/line.js +5 -0
- package/esm/theme/buildin-theme/light/series/line.js.map +1 -1
- package/esm/theme/buildin-theme/light/series/radar.js +5 -0
- package/esm/theme/buildin-theme/light/series/radar.js.map +1 -1
- package/esm/typings/params.d.ts +5 -0
- package/esm/typings/params.js.map +1 -1
- package/esm/typings/spec/common.d.ts +8 -2
- package/esm/typings/spec/common.js.map +1 -1
- package/esm/typings/visual.d.ts +1 -1
- package/esm/typings/visual.js.map +1 -1
- package/esm/util/debug.d.ts +2 -2
- package/esm/util/debug.js +4 -3
- package/esm/util/debug.js.map +1 -1
- package/esm/util/image.d.ts +2 -1
- package/esm/util/image.js +6 -3
- package/esm/util/image.js.map +1 -1
- package/esm/util/math.js +4 -2
- package/esm/util/math.js.map +1 -1
- package/esm/util/spec.d.ts +4 -0
- package/esm/util/spec.js +21 -0
- package/esm/util/spec.js.map +1 -1
- package/package.json +7 -17
- package/chart.d.ts +0 -1
- package/chart.js +0 -1
- package/component.d.ts +0 -1
- package/component.js +0 -1
- package/core.d.ts +0 -1
- package/core.js +0 -1
- package/layout.d.ts +0 -1
- package/layout.js +0 -1
- package/mark.d.ts +0 -1
- package/mark.js +0 -1
- package/series.d.ts +0 -1
- package/series.js +0 -1
package/cjs/chart/area/area.js
CHANGED
|
@@ -13,11 +13,13 @@ class AreaChart extends cartesian_1.CartesianChart {
|
|
|
13
13
|
super(...arguments), this.type = interface_2.ChartTypeEnum.area, this.seriesType = interface_1.SeriesTypeEnum.area;
|
|
14
14
|
}
|
|
15
15
|
_getDefaultSeriesSpec(spec) {
|
|
16
|
+
var _a;
|
|
16
17
|
return Object.assign(Object.assign({}, super._getDefaultSeriesSpec(spec)), {
|
|
17
18
|
invalidType: spec.invalidType || "break",
|
|
18
19
|
point: spec.point,
|
|
19
20
|
line: spec.line,
|
|
20
|
-
area: spec.area
|
|
21
|
+
area: spec.area,
|
|
22
|
+
seriesMark: null !== (_a = spec.seriesMark) && void 0 !== _a ? _a : "area"
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
25
|
transformSpec(spec) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chart/area/area.ts"],"names":[],"mappings":";;;AAAA,sDAAwD;AACxD,sDAAwD;AACxD,4CAA6C;AAE7C,kCAA+D;AAC/D,8CAA2C;AAC3C,yCAA0C;AAC1C,eAAM,CAAC,SAAS,CAAC,CAAC,mBAAU,CAAC,CAAC,CAAC;AAE/B,MAAa,SAAU,SAAQ,0BAAc;IAA7C;;QAGW,SAAI,GAAW,yBAAa,CAAC,IAAI,CAAC;QAClC,eAAU,GAAW,0BAAc,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/chart/area/area.ts"],"names":[],"mappings":";;;AAAA,sDAAwD;AACxD,sDAAwD;AACxD,4CAA6C;AAE7C,kCAA+D;AAC/D,8CAA2C;AAC3C,yCAA0C;AAC1C,eAAM,CAAC,SAAS,CAAC,CAAC,mBAAU,CAAC,CAAC,CAAC;AAE/B,MAAa,SAAU,SAAQ,0BAAc;IAA7C;;QAGW,SAAI,GAAW,yBAAa,CAAC,IAAI,CAAC;QAClC,eAAU,GAAW,0BAAc,CAAC,IAAI,CAAC;IAiBpD,CAAC;IAfW,qBAAqB,CAAC,IAAoB;;QAClD,uCACK,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,KACpC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,OAAO,EACxC,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,UAAU,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,MAAM,IACrC;IACJ,CAAC;IAED,aAAa,CAAC,IAAS;QACrB,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAA,2CAAoC,EAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;;AApBH,8BAqBC;AApBiB,cAAI,GAAW,yBAAa,CAAC,IAAI,CAAC;AAClC,cAAI,GAAW,eAAe,CAAC","file":"area.js","sourcesContent":["import { SeriesTypeEnum } from '../../series/interface';\nimport { CartesianChart } from '../cartesian/cartesian';\nimport { ChartTypeEnum } from '../interface';\nimport type { IAreaChartSpec } from './interface';\nimport { setDefaultCrosshairForCartesianChart } from '../util';\nimport { VChart } from '../../core/vchart';\nimport { AreaSeries } from '../../series';\nVChart.useSeries([AreaSeries]);\n\nexport class AreaChart extends CartesianChart {\n static readonly type: string = ChartTypeEnum.area;\n static readonly view: string = 'singleDefault';\n readonly type: string = ChartTypeEnum.area;\n readonly seriesType: string = SeriesTypeEnum.area;\n\n protected _getDefaultSeriesSpec(spec: IAreaChartSpec): any {\n return {\n ...super._getDefaultSeriesSpec(spec),\n invalidType: spec.invalidType || 'break',\n point: spec.point,\n line: spec.line,\n area: spec.area,\n seriesMark: spec.seriesMark ?? 'area'\n };\n }\n\n transformSpec(spec: any): void {\n super.transformSpec(spec);\n setDefaultCrosshairForCartesianChart(spec);\n }\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ISeriesSpec, Datum, IMarkStateSpec, IRegionQuerier, MaybeArray, IPadding, IRect, StringOrNumber } from '../typings';
|
|
1
|
+
import type { ISeriesSpec, Datum, IMarkStateSpec, IRegionQuerier, MaybeArray, IPadding, IRect, StringOrNumber, IChartSpec } from '../typings';
|
|
2
2
|
import type { LayoutCallBack } from '../layout/interface';
|
|
3
3
|
import type { ILayoutModelState, ILayoutOrientPadding, ILayoutRect, IModel, IModelOption, IUpdateSpecResult } from '../model/interface';
|
|
4
4
|
import type { IChart, IChartLayoutOption, IChartRenderOption, IChartOption, IChartEvaluateOption, ILayoutParams, DimensionIndexOption } from './interface';
|
|
5
5
|
import type { ISeries } from '../series/interface';
|
|
6
6
|
import type { IRegion } from '../region/interface';
|
|
7
7
|
import type { IComponent } from '../component/interface';
|
|
8
|
-
import type
|
|
8
|
+
import { type IMark } from '../mark/interface';
|
|
9
9
|
import type { IEvent } from '../event/interface';
|
|
10
10
|
import type { DataView } from '@visactor/vdataset';
|
|
11
11
|
import type { DataSet } from '@visactor/vdataset/es/data-set';
|
|
@@ -16,12 +16,14 @@ import type { IBoundsLike } from '@visactor/vutils';
|
|
|
16
16
|
import type { IMorphConfig, IMark as IVGrammarMark, IView } from '@visactor/vgrammar';
|
|
17
17
|
import { CompilableBase } from '../compile/compilable-base';
|
|
18
18
|
import type { IGlobalScale } from '../scale/interface';
|
|
19
|
+
import type { IRectMark } from '../mark/rect';
|
|
19
20
|
export declare class BaseChart extends CompilableBase implements IChart {
|
|
20
21
|
readonly type: string;
|
|
21
22
|
readonly id: number;
|
|
22
23
|
protected _spec: any;
|
|
23
24
|
getSpec(): any;
|
|
24
25
|
setSpec(s: any): void;
|
|
26
|
+
getOption(): IChartOption;
|
|
25
27
|
protected _theme: ITheme;
|
|
26
28
|
protected _regions: IRegion[];
|
|
27
29
|
protected _series: ISeries[];
|
|
@@ -47,12 +49,14 @@ export declare class BaseChart extends CompilableBase implements IChart {
|
|
|
47
49
|
padding: IPadding;
|
|
48
50
|
protected _paddingSpec: ILayoutOrientPadding;
|
|
49
51
|
protected _canvasRect: ILayoutRect;
|
|
52
|
+
protected _backgroundMark: IRectMark;
|
|
50
53
|
constructor(spec: any, option: IChartOption);
|
|
51
54
|
created(): void;
|
|
52
55
|
transformSpec(spec: any): void;
|
|
53
56
|
init(options?: any): void;
|
|
54
57
|
onResize(width: number, height: number): void;
|
|
55
58
|
updateViewBox(viewBox: IBoundsLike): void;
|
|
59
|
+
createBackground(bg: IChartSpec['background']): void;
|
|
56
60
|
createRegion(regionSpec: any[]): void;
|
|
57
61
|
initRegion(): void;
|
|
58
62
|
createSeries(seriesSpec: ISeriesSpec[]): void;
|
|
@@ -124,6 +128,7 @@ export declare class BaseChart extends CompilableBase implements IChart {
|
|
|
124
128
|
compile(): void;
|
|
125
129
|
afterCompile(): void;
|
|
126
130
|
compileLayout(): void;
|
|
131
|
+
compileBackground(): void;
|
|
127
132
|
compileRegions(): void;
|
|
128
133
|
compileSeries(): void;
|
|
129
134
|
compileComponents(): void;
|
package/cjs/chart/base-chart.js
CHANGED
|
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
30
30
|
value: !0
|
|
31
31
|
}), exports.BaseChart = void 0;
|
|
32
32
|
|
|
33
|
-
const global_scale_1 = require("../scale/global-scale"), interface_1 = require("../component/interface"), factory_1 = require("../core/factory"), event_1 = require("../event/event"), util_1 = require("../util"), stack_1 = require("./stack"), base_model_1 = require("../model/base-model"), base_mark_1 = require("../mark/base/base-mark"), base_1 = require("../constant/base"), initialize_1 = require("../data/initialize"), vutils_1 = require("@visactor/vutils"), util_2 = require("../theme/color-scheme/util"), compilable_base_1 = require("../compile/compilable-base"),
|
|
33
|
+
const global_scale_1 = require("../scale/global-scale"), interface_1 = require("../component/interface"), interface_2 = require("../mark/interface"), factory_1 = require("../core/factory"), event_1 = require("../event/event"), util_1 = require("../util"), stack_1 = require("./stack"), base_model_1 = require("../model/base-model"), base_mark_1 = require("../mark/base/base-mark"), base_1 = require("../constant/base"), initialize_1 = require("../data/initialize"), vutils_1 = require("@visactor/vutils"), util_2 = require("../theme/color-scheme/util"), compilable_base_1 = require("../compile/compilable-base"), interface_3 = require("../compile/mark/interface"), constant_1 = require("../constant"), dimension_1 = require("../event/events/dimension");
|
|
34
34
|
|
|
35
35
|
class BaseChart extends compilable_base_1.CompilableBase {
|
|
36
36
|
getSpec() {
|
|
@@ -39,6 +39,9 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
39
39
|
setSpec(s) {
|
|
40
40
|
this.transformSpec(s), this._spec = s;
|
|
41
41
|
}
|
|
42
|
+
getOption() {
|
|
43
|
+
return this._option;
|
|
44
|
+
}
|
|
42
45
|
getLayoutRect() {
|
|
43
46
|
return this._layoutRect;
|
|
44
47
|
}
|
|
@@ -109,12 +112,14 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
109
112
|
getChartLayoutRect: () => this._layoutRect,
|
|
110
113
|
getChartViewRect: () => this._viewRect,
|
|
111
114
|
getChart: () => this,
|
|
112
|
-
globalScale: this._globalScale
|
|
115
|
+
globalScale: this._globalScale,
|
|
116
|
+
onError: this._option.onError
|
|
113
117
|
}), this._stack = new stack_1.Stack(this), this._spec = spec;
|
|
114
118
|
}
|
|
115
119
|
created() {
|
|
116
|
-
this.transformSpec(this._spec), this.createGlobalScale(), this.
|
|
117
|
-
this.
|
|
120
|
+
this.transformSpec(this._spec), this.createGlobalScale(), this.createBackground(this._spec.background),
|
|
121
|
+
this.createLayout(), this.createRegion(this._spec.region), this.createSeries(this._spec.series),
|
|
122
|
+
this.createComponent(this._spec);
|
|
118
123
|
}
|
|
119
124
|
transformSpec(spec) {
|
|
120
125
|
spec.region && 0 !== spec.region.length || (spec.region = [ {} ]), (0, vutils_1.has)(spec, "tooltip") || (spec.tooltip = {});
|
|
@@ -136,6 +141,20 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
136
141
|
updateViewBox(viewBox) {
|
|
137
142
|
this._updateLayoutRect(viewBox), this.setLayoutTag(!0);
|
|
138
143
|
}
|
|
144
|
+
createBackground(bg) {
|
|
145
|
+
bg && "object" == typeof bg && (this._backgroundMark = factory_1.Factory.createMark(interface_2.MarkTypeEnum.group, "chart-background", {
|
|
146
|
+
model: this,
|
|
147
|
+
map: this._option.map,
|
|
148
|
+
getCompiler: this.getCompiler,
|
|
149
|
+
globalScale: this._globalScale
|
|
150
|
+
}), this._backgroundMark.created(), this._backgroundMark.setStyle((0, util_1.convertBackgroundSpec)(bg)),
|
|
151
|
+
this._backgroundMark.setStyle({
|
|
152
|
+
x: () => this._viewBox.x1,
|
|
153
|
+
y: () => this._viewBox.y1,
|
|
154
|
+
width: () => this._viewBox.x2 - this._viewBox.x1,
|
|
155
|
+
height: () => this._viewBox.y2 - this._viewBox.y1
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
139
158
|
createRegion(regionSpec) {
|
|
140
159
|
regionSpec && regionSpec.forEach(((s, i) => {
|
|
141
160
|
const region = factory_1.Factory.createRegion("region", s, Object.assign(Object.assign({}, this._modelOption), {
|
|
@@ -151,8 +170,10 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
151
170
|
createSeries(seriesSpec) {
|
|
152
171
|
seriesSpec.forEach(((spec, index) => {
|
|
153
172
|
let region;
|
|
154
|
-
if (spec.data ? spec.data = (0, initialize_1.dataToDataView)(spec.data, this._dataSet, this._spec.data
|
|
155
|
-
|
|
173
|
+
if (spec.data ? spec.data = (0, initialize_1.dataToDataView)(spec.data, this._dataSet, this._spec.data, {
|
|
174
|
+
onError: this._option.onError
|
|
175
|
+
}) : spec.data = this.getSeriesData(spec.dataId, spec.dataIndex), !1 === this._option.animation && (spec.animation = !1),
|
|
176
|
+
(0, util_1.isValid)(spec.regionId) ? region = this.getRegionsInUserId(spec.regionId) : (0,
|
|
156
177
|
util_1.isValid)(spec.regionIndex) && (region = this.getRegionsInIndex([ spec.regionIndex ])[0]),
|
|
157
178
|
region || (region = this._regions[0]), !region) return;
|
|
158
179
|
const series = factory_1.Factory.createSeries(spec.type, spec, Object.assign(Object.assign({}, this._modelOption), {
|
|
@@ -227,7 +248,9 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
227
248
|
if (this._layoutFunc = this._option.layout, !this._layoutFunc) {
|
|
228
249
|
let use3dLayout = !1;
|
|
229
250
|
(this._spec.zField || this._spec.series && this._spec.series.some((s => s.zField))) && (use3dLayout = !0);
|
|
230
|
-
const layout = new (factory_1.Factory.getLayout(null !== (_b = null === (_a = this._spec.layout) || void 0 === _a ? void 0 : _a.type) && void 0 !== _b ? _b : use3dLayout ? "layout3d" : "base"))(this._spec.layout
|
|
251
|
+
const layout = new (factory_1.Factory.getLayout(null !== (_b = null === (_a = this._spec.layout) || void 0 === _a ? void 0 : _a.type) && void 0 !== _b ? _b : use3dLayout ? "layout3d" : "base"))(this._spec.layout, {
|
|
252
|
+
onError: this._option.onError
|
|
253
|
+
});
|
|
231
254
|
this._layoutFunc = layout.layoutItems.bind(layout);
|
|
232
255
|
}
|
|
233
256
|
}
|
|
@@ -314,17 +337,14 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
314
337
|
return this._canvasRect;
|
|
315
338
|
}
|
|
316
339
|
getSeriesData(id, index) {
|
|
317
|
-
if (!this._spec.data)
|
|
340
|
+
if (!this._spec.data) return this._option.onError("no data in spec!"), null;
|
|
318
341
|
if ("string" == typeof id) {
|
|
319
342
|
const metchData = this._spec.data.filter((data => data.name === id));
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
if ("number" == typeof index) {
|
|
324
|
-
if (this._spec.data[index]) return this._spec.data[index];
|
|
325
|
-
throw new Error(`no data matches dataIndex ${index}!`);
|
|
343
|
+
return metchData[0] ? metchData[0] : (this._option.onError(`no data matches dataId ${id}!`),
|
|
344
|
+
null);
|
|
326
345
|
}
|
|
327
|
-
return this._spec.data[
|
|
346
|
+
return "number" == typeof index ? this._spec.data[index] ? this._spec.data[index] : (this._option.onError(`no data matches dataIndex ${index}!`),
|
|
347
|
+
null) : this._spec.data[0];
|
|
328
348
|
}
|
|
329
349
|
_transformSpecScale() {
|
|
330
350
|
var _a, _b, _c;
|
|
@@ -454,7 +474,8 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
454
474
|
large: spec.large,
|
|
455
475
|
largeThreshold: spec.largeThreshold,
|
|
456
476
|
progressiveStep: spec.progressiveStep,
|
|
457
|
-
progressiveThreshold: spec.progressiveThreshold
|
|
477
|
+
progressiveThreshold: spec.progressiveThreshold,
|
|
478
|
+
background: spec.seriesBackground
|
|
458
479
|
};
|
|
459
480
|
}
|
|
460
481
|
_mergeUpdateResult(resultA, resultB) {
|
|
@@ -505,7 +526,8 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
505
526
|
}))));
|
|
506
527
|
}
|
|
507
528
|
compile() {
|
|
508
|
-
this.
|
|
529
|
+
this.compileBackground(), this.compileLayout(), this.compileRegions(), this.compileSeries(),
|
|
530
|
+
this.compileComponents();
|
|
509
531
|
}
|
|
510
532
|
afterCompile() {
|
|
511
533
|
this.getAllRegions().forEach((r => {
|
|
@@ -523,6 +545,14 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
523
545
|
const {width: width, height: height} = this.getCanvasRect();
|
|
524
546
|
this.getCompiler().setSize(width, height);
|
|
525
547
|
}
|
|
548
|
+
compileBackground() {
|
|
549
|
+
var _a;
|
|
550
|
+
this._backgroundMark && (this._backgroundMark.compile(), null === (_a = this._backgroundMark.getProduct()) || void 0 === _a || _a.configure({
|
|
551
|
+
context: {
|
|
552
|
+
model: this
|
|
553
|
+
}
|
|
554
|
+
}).layout((() => {})));
|
|
555
|
+
}
|
|
526
556
|
compileRegions() {
|
|
527
557
|
var _a, _b, _c, _d;
|
|
528
558
|
null === (_b = null === (_a = this._option.performanceHook) || void 0 === _a ? void 0 : _a.beforeRegionCompile) || void 0 === _b || _b.call(_a),
|
|
@@ -559,10 +589,8 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
559
589
|
}
|
|
560
590
|
checkUpdate(mark, model, sceneRoot) {
|
|
561
591
|
var _a, _b;
|
|
562
|
-
|
|
563
|
-
model = mark.context.model), model && mark.isUpdated
|
|
564
|
-
void model.setAttributeTag(!0);
|
|
565
|
-
"group" === mark.markType && mark.children.forEach((child => {
|
|
592
|
+
(null === (_a = mark.context) || void 0 === _a ? void 0 : _a.model) && (sceneRoot = mark,
|
|
593
|
+
model = mark.context.model), model && mark.isUpdated ? null === (_b = model.bindSceneNode) || void 0 === _b || _b.call(model, sceneRoot.elements[0]) : "group" === mark.markType && mark.children.forEach((child => {
|
|
566
594
|
this.checkUpdate(child, model, sceneRoot);
|
|
567
595
|
}));
|
|
568
596
|
}
|
|
@@ -586,10 +614,10 @@ class BaseChart extends compilable_base_1.CompilableBase {
|
|
|
586
614
|
}
|
|
587
615
|
}
|
|
588
616
|
setSelected(datum, filter, region) {
|
|
589
|
-
this._setStateInDatum(
|
|
617
|
+
this._setStateInDatum(interface_3.STATE_VALUE_ENUM.STATE_SELECTED, !0, datum, filter, region);
|
|
590
618
|
}
|
|
591
619
|
setHovered(datum, filter, region) {
|
|
592
|
-
this._setStateInDatum(
|
|
620
|
+
this._setStateInDatum(interface_3.STATE_VALUE_ENUM.STATE_HOVER, !0, datum, filter, region);
|
|
593
621
|
}
|
|
594
622
|
initEvent() {
|
|
595
623
|
[ constant_1.ChartEvent.dataZoomChange, constant_1.ChartEvent.scrollBarChange ].forEach((event => {
|