@carbon/charts 0.30.21 → 0.30.25
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/CHANGELOG.md +337 -1035
- package/README.md +3 -0
- package/axis-chart.js +8 -14
- package/axis-chart.js.map +1 -1
- package/build/demo/{data/create-codesandbox.d.ts → create-codesandbox.d.ts} +16 -13
- package/build/demo/data/bar.d.ts +175 -1
- package/build/demo/data/bubble.d.ts +41 -0
- package/build/demo/data/donut.d.ts +23 -0
- package/build/demo/data/line.d.ts +70 -0
- package/build/demo/data/pie.d.ts +13 -0
- package/build/demo/data/scatter.d.ts +31 -0
- package/build/demo/data/step.d.ts +4 -0
- package/build/demo/data/time-series-axis.d.ts +55 -3
- package/build/src/components/axes/grid.d.ts +3 -3
- package/build/src/components/axes/two-dimensional-axes.d.ts +3 -0
- package/build/src/components/essentials/threshold.d.ts +17 -0
- package/build/src/components/graphs/bar.d.ts +1 -1
- package/build/src/components/graphs/scatter.d.ts +1 -0
- package/build/src/components/graphs/skeleton.d.ts +22 -0
- package/build/src/components/index.d.ts +2 -0
- package/build/src/interfaces/axis-scales.d.ts +22 -11
- package/build/src/interfaces/charts.d.ts +5 -0
- package/build/src/interfaces/components.d.ts +21 -0
- package/build/src/interfaces/enums.d.ts +9 -0
- package/build/src/interfaces/events.d.ts +7 -0
- package/build/src/model.d.ts +1 -0
- package/build/src/services/scales-cartesian.d.ts +9 -1
- package/build/stories/tutorials/event-listeners.d.ts +1 -0
- package/build/stories/tutorials/index.d.ts +2 -1
- package/bundle.js +1 -1
- package/chart.js +15 -24
- package/chart.js.map +1 -1
- package/charts/bar-grouped.js +6 -2
- package/charts/bar-grouped.js.map +1 -1
- package/charts/bar-simple.js +6 -2
- package/charts/bar-simple.js.map +1 -1
- package/charts/bar-stacked.js +6 -2
- package/charts/bar-stacked.js.map +1 -1
- package/charts/bubble.js +6 -2
- package/charts/bubble.js.map +1 -1
- package/charts/donut.js +6 -2
- package/charts/donut.js.map +1 -1
- package/charts/line.js +6 -2
- package/charts/line.js.map +1 -1
- package/charts/pie.js +6 -2
- package/charts/pie.js.map +1 -1
- package/charts/radar.js +1 -3
- package/charts/radar.js.map +1 -1
- package/charts/scatter.js +6 -2
- package/charts/scatter.js.map +1 -1
- package/components/axes/axis.js +93 -43
- package/components/axes/axis.js.map +1 -1
- package/components/axes/grid.d.ts +3 -3
- package/components/axes/grid.js +46 -23
- package/components/axes/grid.js.map +1 -1
- package/components/axes/ruler.js +7 -5
- package/components/axes/ruler.js.map +1 -1
- package/components/axes/two-dimensional-axes.d.ts +3 -0
- package/components/axes/two-dimensional-axes.js +35 -2
- package/components/axes/two-dimensional-axes.js.map +1 -1
- package/components/axes/zero-line.js +16 -1
- package/components/axes/zero-line.js.map +1 -1
- package/components/component.js +2 -4
- package/components/component.js.map +1 -1
- package/components/essentials/legend.js +46 -23
- package/components/essentials/legend.js.map +1 -1
- package/components/essentials/threshold.d.ts +17 -0
- package/components/essentials/threshold.js +171 -0
- package/components/essentials/threshold.js.map +1 -0
- package/components/essentials/title.js +6 -4
- package/components/essentials/title.js.map +1 -1
- package/components/essentials/tooltip-bar.js +39 -20
- package/components/essentials/tooltip-bar.js.map +1 -1
- package/components/essentials/tooltip-pie.js +4 -3
- package/components/essentials/tooltip-pie.js.map +1 -1
- package/components/essentials/tooltip-radar.js +6 -3
- package/components/essentials/tooltip-radar.js.map +1 -1
- package/components/essentials/tooltip-scatter.js +3 -1
- package/components/essentials/tooltip-scatter.js.map +1 -1
- package/components/essentials/tooltip.js +35 -15
- package/components/essentials/tooltip.js.map +1 -1
- package/components/graphs/bar-grouped.js +48 -20
- package/components/graphs/bar-grouped.js.map +1 -1
- package/components/graphs/bar-simple.js +39 -19
- package/components/graphs/bar-simple.js.map +1 -1
- package/components/graphs/bar-stacked.js +50 -28
- package/components/graphs/bar-stacked.js.map +1 -1
- package/components/graphs/bar.d.ts +1 -1
- package/components/graphs/bar.js +1 -1
- package/components/graphs/bar.js.map +1 -1
- package/components/graphs/bubble.js +22 -8
- package/components/graphs/bubble.js.map +1 -1
- package/components/graphs/donut.js +17 -3
- package/components/graphs/donut.js.map +1 -1
- package/components/graphs/line.js +14 -7
- package/components/graphs/line.js.map +1 -1
- package/components/graphs/pie.js +80 -44
- package/components/graphs/pie.js.map +1 -1
- package/components/graphs/radar.js +271 -140
- package/components/graphs/radar.js.map +1 -1
- package/components/graphs/scatter.d.ts +1 -0
- package/components/graphs/scatter.js +80 -19
- package/components/graphs/scatter.js.map +1 -1
- package/components/graphs/skeleton.d.ts +22 -0
- package/components/graphs/skeleton.js +256 -0
- package/components/graphs/skeleton.js.map +1 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -0
- package/components/index.js.map +1 -1
- package/components/layout/layout.js +38 -26
- package/components/layout/layout.js.map +1 -1
- package/components/layout/spacer.js +2 -1
- package/components/layout/spacer.js.map +1 -1
- package/configuration.js +17 -14
- package/configuration.js.map +1 -1
- package/demo/{data/create-codesandbox.d.ts → create-codesandbox.d.ts} +16 -13
- package/demo/{data/create-codesandbox.js → create-codesandbox.js} +24 -21
- package/demo/create-codesandbox.js.map +1 -0
- package/demo/data/bar.d.ts +175 -1
- package/demo/data/bar.js +189 -3
- package/demo/data/bar.js.map +1 -1
- package/demo/data/bubble.d.ts +41 -0
- package/demo/data/bubble.js +48 -3
- package/demo/data/bubble.js.map +1 -1
- package/demo/data/bundle.js +1 -1
- package/demo/data/donut.d.ts +23 -0
- package/demo/data/donut.js +25 -0
- package/demo/data/donut.js.map +1 -1
- package/demo/data/index.js +189 -7
- package/demo/data/index.js.map +1 -1
- package/demo/data/line.d.ts +70 -0
- package/demo/data/line.js +71 -0
- package/demo/data/line.js.map +1 -1
- package/demo/data/pie.d.ts +13 -0
- package/demo/data/pie.js +15 -0
- package/demo/data/pie.js.map +1 -1
- package/demo/data/radar.js.map +1 -1
- package/demo/data/scatter.d.ts +31 -0
- package/demo/data/scatter.js +33 -0
- package/demo/data/scatter.js.map +1 -1
- package/demo/data/step.d.ts +4 -0
- package/demo/data/step.js +15 -0
- package/demo/data/step.js.map +1 -1
- package/demo/data/time-series-axis.d.ts +55 -3
- package/demo/data/time-series-axis.js +62 -6
- package/demo/data/time-series-axis.js.map +1 -1
- package/demo/styles.css +342 -18
- package/demo/styles.css.map +1 -1
- package/demo/styles.min.css +1 -1
- package/demo/styles.min.css.map +1 -1
- package/demo/tsconfig.tsbuildinfo +232 -229
- package/index.js.map +1 -1
- package/interfaces/axis-scales.d.ts +22 -11
- package/interfaces/axis-scales.js.map +1 -1
- package/interfaces/charts.d.ts +5 -0
- package/interfaces/charts.js.map +1 -1
- package/interfaces/components.d.ts +21 -0
- package/interfaces/components.js.map +1 -1
- package/interfaces/enums.d.ts +9 -0
- package/interfaces/enums.js +10 -0
- package/interfaces/enums.js.map +1 -1
- package/interfaces/events.d.ts +7 -0
- package/interfaces/events.js +8 -0
- package/interfaces/events.js.map +1 -1
- package/model.d.ts +1 -0
- package/model.js +30 -16
- package/model.js.map +1 -1
- package/package.json +4 -2
- package/polyfills.js +7 -2
- package/polyfills.js.map +1 -1
- package/services/angle-utils.js +34 -9
- package/services/angle-utils.js.map +1 -1
- package/services/colors.js.map +1 -1
- package/services/curves.js +4 -2
- package/services/curves.js.map +1 -1
- package/services/essentials/dom-utils.js +4 -3
- package/services/essentials/dom-utils.js.map +1 -1
- package/services/essentials/transitions.js +3 -4
- package/services/essentials/transitions.js.map +1 -1
- package/services/scales-cartesian.d.ts +9 -1
- package/services/scales-cartesian.js +96 -23
- package/services/scales-cartesian.js.map +1 -1
- package/services/time-series.js +36 -19
- package/services/time-series.js.map +1 -1
- package/styles/components/_axis.scss +4 -0
- package/styles/components/_layout.scss +0 -1
- package/styles/components/_ruler.scss +5 -2
- package/styles/components/_skeleton.scss +56 -0
- package/styles/components/_threshold.scss +49 -0
- package/styles/components/_tooltip.scss +6 -5
- package/styles/components/index.scss +2 -0
- package/styles/graphs/_bubble.scss +1 -1
- package/styles/graphs/_radar.scss +4 -2
- package/styles/graphs/_scatter.scss +5 -1
- package/styles/mixins.scss +2 -2
- package/styles-g10.css +87 -4
- package/styles-g10.css.map +1 -1
- package/styles-g10.min.css +1 -1
- package/styles-g10.min.css.map +1 -1
- package/styles-g100.css +87 -4
- package/styles-g100.css.map +1 -1
- package/styles-g100.min.css +1 -1
- package/styles-g100.min.css.map +1 -1
- package/styles-g90.css +87 -4
- package/styles-g90.css.map +1 -1
- package/styles-g90.min.css +1 -1
- package/styles-g90.min.css.map +1 -1
- package/styles.css +87 -4
- package/styles.css.map +1 -1
- package/styles.min.css +1 -1
- package/styles.min.css.map +1 -1
- package/tools.js +25 -7
- package/tools.js.map +1 -1
- package/tsconfig.tsbuildinfo +169 -106
- package/demo/data/create-codesandbox.js.map +0 -1
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAEzB,uBAAuB;AACvB,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,mCAAmC;AACnC,IAAM,aAAa,GAAG,OAAO,CAAC;AAE9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAEzB,uBAAuB;AACvB,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,mCAAmC;AACnC,IAAM,aAAa,GAAG,OAAO,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC","sourcesContent":["export * from \"./charts\";\n\n// Configs & interfaces\nimport * as configurations from \"./configuration\";\nimport * as interfaces from \"./interfaces\";\n\nimport * as colorPalettes from \"./services/colorPalettes\";\nimport { DEFAULT } from \"./services/colorPalettes\";\n// TODO 1.0 - Remove deprecated API\nconst defaultColors = DEFAULT;\n\nexport { interfaces, configurations, defaultColors, colorPalettes };\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ScaleTypes } from "./enums";
|
|
2
2
|
import { AxisDomain } from "d3";
|
|
3
3
|
import { Locale } from "date-fns";
|
|
4
|
+
import { ThresholdOptions } from "./components";
|
|
4
5
|
/**
|
|
5
6
|
* options to configure a scale. not all options are used by all scales
|
|
6
7
|
*/
|
|
@@ -18,10 +19,10 @@ export interface AxisOptions {
|
|
|
18
19
|
*/
|
|
19
20
|
domain?: AxisDomain[];
|
|
20
21
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
* Whether the Axis should be forced to include 0 as a starting point
|
|
23
|
+
* (or ending point, in case of all negative axis).
|
|
24
|
+
* Default: true
|
|
25
|
+
*/
|
|
25
26
|
includeZero?: boolean;
|
|
26
27
|
/**
|
|
27
28
|
* identifies what key within the data the axis values would map to
|
|
@@ -31,6 +32,16 @@ export interface AxisOptions {
|
|
|
31
32
|
* optional title for the scales
|
|
32
33
|
*/
|
|
33
34
|
title?: string;
|
|
35
|
+
/**
|
|
36
|
+
* thresholds
|
|
37
|
+
* Example:
|
|
38
|
+
* [
|
|
39
|
+
* {value: 10000},
|
|
40
|
+
* {value: 40020, valueFormatter: (x) => x},
|
|
41
|
+
* {value: 55000, label: "Custom label", fillColor: "#03a9f4"},
|
|
42
|
+
* ]
|
|
43
|
+
*/
|
|
44
|
+
thresholds?: ThresholdOptions[];
|
|
34
45
|
/**
|
|
35
46
|
* tick configuration
|
|
36
47
|
*/
|
|
@@ -88,14 +99,14 @@ export interface TickFormats {
|
|
|
88
99
|
}
|
|
89
100
|
export interface TimeIntervalFormats {
|
|
90
101
|
"15seconds"?: TickFormats;
|
|
91
|
-
|
|
102
|
+
minute?: TickFormats;
|
|
92
103
|
"30minutes"?: TickFormats;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
hourly?: TickFormats;
|
|
105
|
+
daily?: TickFormats;
|
|
106
|
+
weekly?: TickFormats;
|
|
107
|
+
monthly?: TickFormats;
|
|
108
|
+
quarterly?: TickFormats;
|
|
109
|
+
yearly?: TickFormats;
|
|
99
110
|
}
|
|
100
111
|
/**
|
|
101
112
|
* customize the axes components
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axis-scales.js","sourceRoot":"","sources":["axis-scales.ts"],"names":[],"mappings":"","sourcesContent":["import { ScaleTypes } from \"./enums\";\nimport { AxisDomain } from \"d3\";\nimport { Locale } from \"date-fns\";\n\n/**\n * options to configure a scale. not all options are used by all scales\n */\nexport interface AxisOptions {\n\t/**\n\t * type of the scale used on axis\n\t */\n\tscaleType?: ScaleTypes;\n\t/**\n\t * Whether the Axis should use the specified domain\n\t * instead of it being dynamically generated based on data extents.\n\t * The type of values should depend on the scale type.\n\t * Example for continuous axis scale: [-100, 100]\n\t * Example for discrete axis scale: ['Qty', 'More', 'Sold']\n\t */\n\tdomain?: AxisDomain[];\n\t/**\n\t* Whether the Axis should be forced to include 0 as a starting point\n\t* (or ending point, in case of all negative axis).\n\t* Default: true\n\t*/\n\tincludeZero?: boolean;\n\t/**\n\t * identifies what key within the data the axis values would map to\n\t */\n\tmapsTo?: string;\n\t/**\n\t * optional title for the scales\n\t */\n\ttitle?: string;\n\t/**\n\t * tick configuration\n\t */\n\tticks?: {\n\t\t/**\n\t\t * number of ticks to show\n\t\t */\n\t\tnumber?: number;\n\t\t/**\n\t\t * minimum tick value\n\t\t */\n\t\tmin?: number;\n\t\t/**\n\t\t * maximum tick value\n\t\t */\n\t\tmax?: number;\n\t\t/**\n\t\t * minimum width of a tick\n\t\t * before getting rotated (in pixels)\n\t\t */\n\t\trotateIfSmallerThan?: number;\n\t\t/**\n\t\t * function to format the ticks\n\t\t */\n\t\tformatter?: Function;\n\t};\n}\n\n/**\n * customize time series scales\n */\nexport interface TimeScaleOptions {\n\taddSpaceOnEdges?: number;\n\t/**\n\t * if it's true, days are shown as mon-sun,\n\t * otherwise days are shown as number 1-31\n\t */\n\tshowDayName?: boolean;\n\t/**\n\t * formats for each time interval\n\t */\n\ttimeIntervalFormats?: TimeIntervalFormats;\n\t/**\n\t * locale object, for more information see https://date-fns.org/v2.11.0/docs/Locale.\n\t * example: `import enUSLocaleObject from \"date-fns/locale/en-US/index\"`.\n\t * available locale objects are: https://github.com/date-fns/date-fns/tree/master/src/locale\n\t */\n\tlocaleObject?: Locale;\n}\n\n/**\n * time scales: customize ticks format for different time intervals\n */\nexport interface TickFormats {\n\tprimary?: string;\n\tsecondary?: string;\n}\n\
|
|
1
|
+
{"version":3,"file":"axis-scales.js","sourceRoot":"","sources":["axis-scales.ts"],"names":[],"mappings":"","sourcesContent":["import { ScaleTypes } from \"./enums\";\nimport { AxisDomain } from \"d3\";\nimport { Locale } from \"date-fns\";\nimport { ThresholdOptions } from \"./components\";\n\n/**\n * options to configure a scale. not all options are used by all scales\n */\nexport interface AxisOptions {\n\t/**\n\t * type of the scale used on axis\n\t */\n\tscaleType?: ScaleTypes;\n\t/**\n\t * Whether the Axis should use the specified domain\n\t * instead of it being dynamically generated based on data extents.\n\t * The type of values should depend on the scale type.\n\t * Example for continuous axis scale: [-100, 100]\n\t * Example for discrete axis scale: ['Qty', 'More', 'Sold']\n\t */\n\tdomain?: AxisDomain[];\n\t/**\n\t * Whether the Axis should be forced to include 0 as a starting point\n\t * (or ending point, in case of all negative axis).\n\t * Default: true\n\t */\n\tincludeZero?: boolean;\n\t/**\n\t * identifies what key within the data the axis values would map to\n\t */\n\tmapsTo?: string;\n\t/**\n\t * optional title for the scales\n\t */\n\ttitle?: string;\n\t/**\n\t * thresholds\n\t * Example:\n\t * [\n\t *\t\t{value: 10000},\n\t *\t\t{value: 40020, valueFormatter: (x) => x},\n\t *\t\t{value: 55000, label: \"Custom label\", fillColor: \"#03a9f4\"},\n\t * ]\n\t */\n\tthresholds?: ThresholdOptions[];\n\t/**\n\t * tick configuration\n\t */\n\tticks?: {\n\t\t/**\n\t\t * number of ticks to show\n\t\t */\n\t\tnumber?: number;\n\t\t/**\n\t\t * minimum tick value\n\t\t */\n\t\tmin?: number;\n\t\t/**\n\t\t * maximum tick value\n\t\t */\n\t\tmax?: number;\n\t\t/**\n\t\t * minimum width of a tick\n\t\t * before getting rotated (in pixels)\n\t\t */\n\t\trotateIfSmallerThan?: number;\n\t\t/**\n\t\t * function to format the ticks\n\t\t */\n\t\tformatter?: Function;\n\t};\n}\n\n/**\n * customize time series scales\n */\nexport interface TimeScaleOptions {\n\taddSpaceOnEdges?: number;\n\t/**\n\t * if it's true, days are shown as mon-sun,\n\t * otherwise days are shown as number 1-31\n\t */\n\tshowDayName?: boolean;\n\t/**\n\t * formats for each time interval\n\t */\n\ttimeIntervalFormats?: TimeIntervalFormats;\n\t/**\n\t * locale object, for more information see https://date-fns.org/v2.11.0/docs/Locale.\n\t * example: `import enUSLocaleObject from \"date-fns/locale/en-US/index\"`.\n\t * available locale objects are: https://github.com/date-fns/date-fns/tree/master/src/locale\n\t */\n\tlocaleObject?: Locale;\n}\n\n/**\n * time scales: customize ticks format for different time intervals\n */\nexport interface TickFormats {\n\tprimary?: string;\n\tsecondary?: string;\n}\n\nexport interface TimeIntervalFormats {\n\t\"15seconds\"?: TickFormats;\n\tminute?: TickFormats;\n\t\"30minutes\"?: TickFormats;\n\thourly?: TickFormats;\n\tdaily?: TickFormats;\n\tweekly?: TickFormats;\n\tmonthly?: TickFormats;\n\tquarterly?: TickFormats;\n\tyearly?: TickFormats;\n}\n\n/**\n * customize the axes components\n */\nexport interface AxesOptions {\n\tleft?: AxisOptions;\n\tbottom?: AxisOptions;\n\tright?: AxisOptions;\n\ttop?: AxisOptions;\n}\n"]}
|
package/interfaces/charts.d.ts
CHANGED
|
@@ -57,6 +57,10 @@ export interface BaseChartOptions {
|
|
|
57
57
|
* identifier for data groups
|
|
58
58
|
*/
|
|
59
59
|
groupMapsTo?: string;
|
|
60
|
+
/**
|
|
61
|
+
* used to simulate data loading
|
|
62
|
+
*/
|
|
63
|
+
loading?: Boolean;
|
|
60
64
|
};
|
|
61
65
|
/**
|
|
62
66
|
* options related to color scales
|
|
@@ -171,6 +175,7 @@ export interface PieChartOptions extends BaseChartOptions {
|
|
|
171
175
|
export interface DonutChartOptions extends PieChartOptions {
|
|
172
176
|
donut?: {
|
|
173
177
|
center?: {
|
|
178
|
+
label?: string;
|
|
174
179
|
numberFontSize?: Function;
|
|
175
180
|
titleFontSize?: Function;
|
|
176
181
|
titleYPosition?: Function;
|
package/interfaces/charts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charts.js","sourceRoot":"","sources":["charts.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"charts.js","sourceRoot":"","sources":["charts.ts"],"names":[],"mappings":"","sourcesContent":["import {\n\tLegendOptions,\n\tTooltipOptions,\n\tGridOptions,\n\tAxesOptions\n} from \"./index\";\nimport {\n\tAxisTooltipOptions,\n\tBarTooltipOptions,\n\tBarOptions,\n\tStackedBarOptions\n} from \"./components\";\n\n/**\n * Base chart options common to any chart\n */\nexport interface BaseChartOptions {\n\t/**\n\t * boolean to disable animations (enabled by default)\n\t */\n\tanimations?: boolean;\n\t/**\n\t * boolean to prevent the container from resizing\n\t */\n\tresizable?: boolean;\n\t/**\n\t * Optionally specify a width for the chart\n\t */\n\twidth?: string;\n\t/**\n\t * Optionally specify a height for the chart\n\t */\n\theight?: string;\n\t/**\n\t * tooltip configuration\n\t */\n\ttooltip?: TooltipOptions;\n\t/**\n\t * legend configuration\n\t */\n\tlegend?: LegendOptions;\n\t/**\n\t * Optional function to determine whether is filled based on datasetLabel, label, and/or data\n\t */\n\tgetIsFilled?: (\n\t\tdatasetLabel: any,\n\t\tlabel?: any,\n\t\tdata?: any,\n\t\tdefaultFilled?: boolean\n\t) => boolean;\n\t/**\n\t * Optional function to generate the fill color based on datasetLabel, label, and/or data\n\t */\n\tgetFillColor?: (\n\t\tdatasetLabel: any,\n\t\tlabel?: any,\n\t\tdata?: any,\n\t\tdefaultFillColor?: string\n\t) => string;\n\t/**\n\t * Optional function to generate the stroke color based on datasetLabel, label, and/or data\n\t */\n\tgetStrokeColor?: (\n\t\tdatasetLabel: any,\n\t\tlabel?: any,\n\t\tdata?: any,\n\t\tdefaultStrokeColor?: string\n\t) => string;\n\t/**\n\t * stylesheet options\n\t */\n\tstyle?: {\n\t\t/**\n\t\t * optional prefixing string for css classes (defaults to 'cc')\n\t\t */\n\t\tprefix?: string;\n\t};\n\t/**\n\t * options related to charting data\n\t */\n\tdata?: {\n\t\t/**\n\t\t * identifier for data groups\n\t\t */\n\t\tgroupMapsTo?: string;\n\t\t/**\n\t\t * used to simulate data loading\n\t\t */\n\t\tloading?: Boolean;\n\t};\n\t/**\n\t * options related to color scales\n\t */\n\tcolor?: {\n\t\t/**\n\t\t * e.g. { \"Dataset 1\": \"blue\" }\n\t\t */\n\t\tscale?: object;\n\t};\n}\n\n/**\n * Options common to any chart with an axis\n */\nexport interface AxisChartOptions extends BaseChartOptions {\n\taxes?: AxesOptions;\n\tgrid?: GridOptions;\n\ttooltip?: AxisTooltipOptions;\n}\n\n/**\n * options specific to bar charts\n */\nexport interface BarChartOptions extends AxisChartOptions {\n\tbars?: BarOptions;\n\ttooltip?: BarTooltipOptions;\n}\n\n/**\n * options specific to stacked bar charts\n */\nexport interface StackedBarChartOptions extends BarChartOptions {\n\tbars?: StackedBarOptions;\n}\n\n/**\n * options specific to scatter charts\n */\nexport interface ScatterChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the points\n\t */\n\tpoints?: {\n\t\t/**\n\t\t * sets the radius of the point\n\t\t */\n\t\tradius: number;\n\t\tfillOpacity?: number;\n\t\tfilled?: boolean;\n\t};\n}\n\n/**\n * options specific to bubble charts\n */\nexport interface BubbleChartOptions extends AxisChartOptions {\n\t/**\n\t * options for the individual bubbles\n\t */\n\tbubble?: {\n\t\t/**\n\t\t * the key to lookup in charting data for the bubble radius value\n\t\t */\n\t\tradiusMapsTo?: string;\n\t\t/**\n\t\t * A function that would determine the range of the bubble radius to use\n\t\t * Returns an array with the 1st value being the min and the 2nd value being the max radius\n\t\t */\n\t\tradiusRange?: Function;\n\t\t/**\n\t\t * Opacity of the fills used within each circle\n\t\t */\n\t\tfillOpacity?: number;\n\t};\n}\n\n/**\n * options specific to line charts\n */\nexport interface LineChartOptions extends ScatterChartOptions {\n\t/**\n\t * options for the curve of the line\n\t */\n\tcurve?:\n\t\t| string\n\t\t| {\n\t\t\t\tname: string;\n\t\t };\n}\n\n/**\n * options specific to pie charts\n */\nexport interface PieChartOptions extends BaseChartOptions {\n\tpie?: {\n\t\tradiusOffset?: number;\n\t\tinnerRadius?: number;\n\t\tpadAngle?: number;\n\t\thoverArc?: {\n\t\t\touterRadiusOffset?: number;\n\t\t};\n\t\txOffset?: number;\n\t\tyOffset?: number;\n\t\tyOffsetCallout?: number;\n\t\tcallout?: {\n\t\t\tminSliceDegree?: number;\n\t\t\toffsetX?: number;\n\t\t\toffsetY?: number;\n\t\t\thorizontalLineLength?: number;\n\t\t\ttextMargin?: number;\n\t\t};\n\t\tlabels?: {\n\t\t\tformatter?: Function;\n\t\t};\n\t};\n}\n\n/**\n * options specific to donut charts\n */\nexport interface DonutChartOptions extends PieChartOptions {\n\tdonut?: {\n\t\tcenter?: {\n\t\t\tlabel?: string;\n\t\t\tnumberFontSize?: Function;\n\t\t\ttitleFontSize?: Function;\n\t\t\ttitleYPosition?: Function;\n\t\t\tnumberFormatter?: Function;\n\t\t};\n\t};\n}\n\n/**\n * options specific to radar charts\n */\nexport interface RadarChartOptions extends BaseChartOptions {\n\tradar?: {\n\t\topacity: {\n\t\t\tunselected: number;\n\t\t\tselected: number;\n\t\t};\n\t\taxes: {\n\t\t\tangle: string;\n\t\t\tvalue: string;\n\t\t};\n\t\txLabelPadding: number;\n\t\tyLabelPadding: number;\n\t\tyTicksNumber: number;\n\t\tminRange: number;\n\t\txAxisRectHeight: number;\n\t\tdotsRadius: number;\n\t};\n}\n"]}
|
|
@@ -86,6 +86,27 @@ export interface TooltipOptions {
|
|
|
86
86
|
width?: number;
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Threshold options
|
|
91
|
+
*/
|
|
92
|
+
export interface ThresholdOptions {
|
|
93
|
+
/**
|
|
94
|
+
* threshold value
|
|
95
|
+
*/
|
|
96
|
+
value: number | Date;
|
|
97
|
+
/**
|
|
98
|
+
* a function to format the threshold values
|
|
99
|
+
*/
|
|
100
|
+
valueFormatter?: Function;
|
|
101
|
+
/**
|
|
102
|
+
* hex threshold line color
|
|
103
|
+
*/
|
|
104
|
+
fillColor: string;
|
|
105
|
+
/**
|
|
106
|
+
* threshold label
|
|
107
|
+
*/
|
|
108
|
+
label: string;
|
|
109
|
+
}
|
|
89
110
|
/**
|
|
90
111
|
* extends tooltip options to provide support for multiple gridline tooltips
|
|
91
112
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["components.ts"],"names":[],"mappings":"","sourcesContent":["import { LayoutGrowth, LegendPositions } from \"./enums\";\nimport { Component } from \"../components/component\";\n\n/**\n * customize the overlay contents\n */\nexport interface LayoutComponentChild {\n\tid: string;\n\t/**\n\t * the component that'll be rendered inside layout child\n\t */\n\tcomponents: Component[];\n\t/**\n\t * size of the layout child\n\t */\n\tsize?: number;\n\t/**\n\t * how the layout child will grow or shrink in x & y directions\n\t */\n\tgrowth?: {\n\t\tx: LayoutGrowth
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["components.ts"],"names":[],"mappings":"","sourcesContent":["import { LayoutGrowth, LegendPositions } from \"./enums\";\nimport { Component } from \"../components/component\";\n\n/**\n * customize the overlay contents\n */\nexport interface LayoutComponentChild {\n\tid: string;\n\t/**\n\t * the component that'll be rendered inside layout child\n\t */\n\tcomponents: Component[];\n\t/**\n\t * size of the layout child\n\t */\n\tsize?: number;\n\t/**\n\t * how the layout child will grow or shrink in x & y directions\n\t */\n\tgrowth?: {\n\t\tx: LayoutGrowth;\n\t\ty: LayoutGrowth;\n\t};\n}\n\n/**\n * customize the legend component\n */\nexport interface LegendOptions {\n\tposition?: LegendPositions;\n\t/**\n\t * the clickability of legend items\n\t */\n\tclickable?: boolean;\n\t/**\n\t * is the legend visible or not\n\t */\n\tenabled?: boolean;\n\titems?: {\n\t\tstatus?: {\n\t\t\tACTIVE?: Number;\n\t\t\tDISABLED?: Number;\n\t\t};\n\t\thorizontalSpace?: Number;\n\t\tverticalSpace?: Number;\n\t\ttextYOffset?: Number;\n\t};\n\tcheckbox?: {\n\t\tradius?: Number;\n\t\tspaceAfter?: Number;\n\t};\n}\n\nexport interface TooltipOptions {\n\t/**\n\t * a function to format the tooltip values\n\t */\n\tvalueFormatter?: Function;\n\t/**\n\t * custom function for returning tooltip HTML\n\t * passed an array or object with the data, and then the default tooltip markup\n\t */\n\tcustomHTML?: Function;\n\t/**\n\t * options to configure the datapoint tooltip\n\t */\n\tdatapoint?: {\n\t\t/**\n\t\t * offset of the tooltip from the mouse position\n\t\t */\n\t\thorizontalOffset?: number;\n\t\t/**\n\t\t * toggles on/off datapoint tooltips.\n\t\t */\n\t\tenabled?: boolean;\n\t\t/**\n\t\t * vertical offset for tooltip placement\n\t\t */\n\t\tverticalOffset?: number;\n\t};\n\ttitle?: {\n\t\t/**\n\t\t * vertical offset for title tooltip placement. < 0 shifts the tooltip above title, > 0 shifts vertically down\n\t\t */\n\t\tverticalOffset?: number;\n\t\t/**\n\t\t * max width of title tooltip relative to the width of the chart-svg (percentage should be < 1)\n\t\t */\n\t\twidth?: number;\n\t};\n}\n\n/**\n * Threshold options\n */\nexport interface ThresholdOptions {\n\t/**\n\t * threshold value\n\t */\n\tvalue: number | Date;\n\t/**\n\t * a function to format the threshold values\n\t */\n\tvalueFormatter?: Function;\n\t/**\n\t * hex threshold line color\n\t */\n\tfillColor: string;\n\t/**\n\t * threshold label\n\t */\n\tlabel: string;\n}\n\n/**\n * extends tooltip options to provide support for multiple gridline tooltips\n */\nexport interface AxisTooltipOptions extends TooltipOptions {\n\t/** options for gridline event listeners */\n\tgridline?: {\n\t\t/**\n\t\t * controls whether the gridlines are active for tooltip support\n\t\t */\n\t\tenabled?: boolean;\n\t\t/**\n\t\t * optional set threshold (value between 0 and 1) for active gridlines\n\t\t */\n\t\tthreshold?: number;\n\t};\n}\n\n/**\n * extends tooltip for bar tooltip\n */\nexport interface BarTooltipOptions extends TooltipOptions {\n\tdatapoint: {\n\t\t/**\n\t\t * padding between the bar items and the tooltip\n\t\t */\n\t\tverticalOffset: number;\n\t};\n}\n\nexport interface GridOptions {\n\ty?: {\n\t\tnumberOfTicks?: number;\n\t};\n\tx?: {\n\t\tnumberOfTicks?: number;\n\t};\n\tstrokeColor?: string;\n}\n\nexport interface BarOptions {\n\twidth?: number;\n\tmaxWidth?: number;\n}\n\nexport interface StackedBarOptions extends BarOptions {\n\tdividerSize?: number;\n}\n"]}
|
package/interfaces/enums.d.ts
CHANGED
|
@@ -93,6 +93,15 @@ export declare enum CalloutDirections {
|
|
|
93
93
|
LEFT = "left",
|
|
94
94
|
RIGHT = "right"
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* enum of all possible skeleton/empty state types
|
|
98
|
+
*/
|
|
99
|
+
export declare enum Skeletons {
|
|
100
|
+
GRID = "grid",
|
|
101
|
+
VERT_OR_HORIZ = "vertOrHoriz",
|
|
102
|
+
PIE = "pie",
|
|
103
|
+
DONUT = "donut"
|
|
104
|
+
}
|
|
96
105
|
/**
|
|
97
106
|
* enum of all possible attributes used to aling text horizontally
|
|
98
107
|
*/
|
package/interfaces/enums.js
CHANGED
|
@@ -104,6 +104,16 @@ export var CalloutDirections;
|
|
|
104
104
|
CalloutDirections["LEFT"] = "left";
|
|
105
105
|
CalloutDirections["RIGHT"] = "right";
|
|
106
106
|
})(CalloutDirections || (CalloutDirections = {}));
|
|
107
|
+
/**
|
|
108
|
+
* enum of all possible skeleton/empty state types
|
|
109
|
+
*/
|
|
110
|
+
export var Skeletons;
|
|
111
|
+
(function (Skeletons) {
|
|
112
|
+
Skeletons["GRID"] = "grid";
|
|
113
|
+
Skeletons["VERT_OR_HORIZ"] = "vertOrHoriz";
|
|
114
|
+
Skeletons["PIE"] = "pie";
|
|
115
|
+
Skeletons["DONUT"] = "donut";
|
|
116
|
+
})(Skeletons || (Skeletons = {}));
|
|
107
117
|
/**
|
|
108
118
|
* enum of all possible attributes used to aling text horizontally
|
|
109
119
|
*/
|
package/interfaces/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["enums.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,UAAU,CAAC;AACvC,MAAM,CAAC,IAAM,MAAM,GAAG,UAAU,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,iCAAmB,CAAA;IACnB,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,yBAAW,CAAA;AACZ,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACxB,8BAAa,CAAA;IACb,gCAAe,CAAA;IACf,4BAAW,CAAA;IACX,kCAAiB,CAAA;AAClB,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAED;;;;;GAKG;AACH,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAChC,8CAAqB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AAZ,YAAY,QAIvB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC5B,kCAAa,CAAA;IACb,oCAAe,CAAA;AAChB,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACrB,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,yBAAW,CAAA;AACZ,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC3B,yCAAqB,CAAA;IACrB,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACpB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B","sourcesContent":["import * as EventEnums from \"./events\";\nexport const Events = EventEnums;\n\n/**\n * enum of all supported chart themes\n */\nexport enum ChartTheme {\n\tDEFAULT = \"default\",\n\tG100 = \"g100\",\n\tG90 = \"g90\",\n\tG10 = \"g10\"\n}\n\n/**\n * enum of all possible axis positions\n */\nexport enum AxisPositions {\n\tLEFT = \"left\",\n\tRIGHT = \"right\",\n\tTOP = \"top\",\n\tBOTTOM = \"bottom\"\n}\n\n/**\n * enum of all possible cartesian orientations\n * to be used for determining the orientation\n * of graphs being draw over\n * cartesian scales\n */\nexport enum CartesianOrientations {\n\tVERTICAL = \"vertical\",\n\tHORIZONTAL = \"horizontal\"\n}\n\n/**\n * enum of all possible scale types\n */\nexport enum ScaleTypes {\n\tTIME = \"time\",\n\tLINEAR = \"linear\",\n\tLOG = \"log\",\n\tLABELS = \"labels\"\n}\n\n/**\n * enum of supported tooltip position relative to\n */\nexport enum TooltipPosition {\n\tMOUSE = \"mouse\",\n\tTOP = \"top\",\n\tBOTTOM = \"bottom\"\n}\n\n/**\n * enum of tooltip types for custom tooltip event\n */\nexport enum TooltipTypes {\n\tDATAPOINT = \"datapoint\",\n\tGRIDLINE = \"gridline\",\n\tTITLE = \"title\"\n}\n\n/**\n * enum of all possible legend positions\n */\nexport enum LegendPositions {\n\tRIGHT = \"right\",\n\tLEFT = \"left\",\n\tTOP = \"top\",\n\tBOTTOM = \"bottom\"\n}\n\n/**\n * enum of all possible legend orientations\n */\nexport enum LegendOrientations {\n\tHORIZONTAL = \"horizontal\",\n\tVERTICAL = \"vertical\"\n}\n\n/**\n * enum of all possible layout directions\n */\nexport enum LayoutDirection {\n\tROW = \"row\",\n\tCOLUMN = \"column\",\n\tROW_REVERSE = \"row-reverse\",\n\tCOLUMN_REVERSE = \"column-reverse\"\n}\n\n/**\n * enum of all possible layout growth values\n */\nexport enum LayoutGrowth {\n\tFIXED = \"fixed\",\n\tPREFERRED = \"preferred\",\n\tSTRETCH = \"stretch\"
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["enums.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,UAAU,CAAC;AACvC,MAAM,CAAC,IAAM,MAAM,GAAG,UAAU,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,iCAAmB,CAAA;IACnB,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,yBAAW,CAAA;AACZ,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACxB,8BAAa,CAAA;IACb,gCAAe,CAAA;IACf,4BAAW,CAAA;IACX,kCAAiB,CAAA;AAClB,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAED;;;;;GAKG;AACH,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAChC,8CAAqB,CAAA;IACrB,kDAAyB,CAAA;AAC1B,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,2BAAa,CAAA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,iBAAiB,QAG5B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACpB,0BAAa,CAAA;IACb,0CAA6B,CAAA;IAC7B,wBAAW,CAAA;IACX,4BAAe,CAAA;AAChB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACrB,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,yBAAW,CAAA;AACZ,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC3B,yCAAqB,CAAA;IACrB,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACpB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B","sourcesContent":["import * as EventEnums from \"./events\";\nexport const Events = EventEnums;\n\n/**\n * enum of all supported chart themes\n */\nexport enum ChartTheme {\n\tDEFAULT = \"default\",\n\tG100 = \"g100\",\n\tG90 = \"g90\",\n\tG10 = \"g10\"\n}\n\n/**\n * enum of all possible axis positions\n */\nexport enum AxisPositions {\n\tLEFT = \"left\",\n\tRIGHT = \"right\",\n\tTOP = \"top\",\n\tBOTTOM = \"bottom\"\n}\n\n/**\n * enum of all possible cartesian orientations\n * to be used for determining the orientation\n * of graphs being draw over\n * cartesian scales\n */\nexport enum CartesianOrientations {\n\tVERTICAL = \"vertical\",\n\tHORIZONTAL = \"horizontal\"\n}\n\n/**\n * enum of all possible scale types\n */\nexport enum ScaleTypes {\n\tTIME = \"time\",\n\tLINEAR = \"linear\",\n\tLOG = \"log\",\n\tLABELS = \"labels\"\n}\n\n/**\n * enum of supported tooltip position relative to\n */\nexport enum TooltipPosition {\n\tMOUSE = \"mouse\",\n\tTOP = \"top\",\n\tBOTTOM = \"bottom\"\n}\n\n/**\n * enum of tooltip types for custom tooltip event\n */\nexport enum TooltipTypes {\n\tDATAPOINT = \"datapoint\",\n\tGRIDLINE = \"gridline\",\n\tTITLE = \"title\"\n}\n\n/**\n * enum of all possible legend positions\n */\nexport enum LegendPositions {\n\tRIGHT = \"right\",\n\tLEFT = \"left\",\n\tTOP = \"top\",\n\tBOTTOM = \"bottom\"\n}\n\n/**\n * enum of all possible legend orientations\n */\nexport enum LegendOrientations {\n\tHORIZONTAL = \"horizontal\",\n\tVERTICAL = \"vertical\"\n}\n\n/**\n * enum of all possible layout directions\n */\nexport enum LayoutDirection {\n\tROW = \"row\",\n\tCOLUMN = \"column\",\n\tROW_REVERSE = \"row-reverse\",\n\tCOLUMN_REVERSE = \"column-reverse\"\n}\n\n/**\n * enum of all possible layout growth values\n */\nexport enum LayoutGrowth {\n\tFIXED = \"fixed\",\n\tPREFERRED = \"preferred\",\n\tSTRETCH = \"stretch\"\n}\n\n/**\n * enum of all possible callout directions\n */\nexport enum CalloutDirections {\n\tLEFT = \"left\",\n\tRIGHT = \"right\"\n}\n\n/**\n * enum of all possible skeleton/empty state types\n */\nexport enum Skeletons {\n\tGRID = \"grid\",\n\tVERT_OR_HORIZ = \"vertOrHoriz\",\n\tPIE = \"pie\",\n\tDONUT = \"donut\"\n}\n\n/**\n * enum of all possible attributes used to aling text horizontally\n */\nexport enum TextAnchor {\n\tSTART = \"start\",\n\tMIDDLE = \"middle\",\n\tEND = \"end\"\n}\n\n/**\n * enum of all possible attributes used to aling text vertically\n */\nexport enum DominantBaseline {\n\tBASELINE = \"baseline\",\n\tMIDDLE = \"middle\",\n\tHANGING = \"hanging\"\n}\n"]}
|
package/interfaces/events.d.ts
CHANGED
|
@@ -72,6 +72,13 @@ export declare enum Tooltip {
|
|
|
72
72
|
SHOW = "show-tooltip",
|
|
73
73
|
HIDE = "hide-tooltip"
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* enum of all threshold events
|
|
77
|
+
*/
|
|
78
|
+
export declare enum Threshold {
|
|
79
|
+
SHOW = "show-threshold",
|
|
80
|
+
HIDE = "hide-threshold"
|
|
81
|
+
}
|
|
75
82
|
/**
|
|
76
83
|
* enum of all legend related events
|
|
77
84
|
*/
|
package/interfaces/events.js
CHANGED
|
@@ -81,6 +81,14 @@ export var Tooltip;
|
|
|
81
81
|
Tooltip["SHOW"] = "show-tooltip";
|
|
82
82
|
Tooltip["HIDE"] = "hide-tooltip";
|
|
83
83
|
})(Tooltip || (Tooltip = {}));
|
|
84
|
+
/**
|
|
85
|
+
* enum of all threshold events
|
|
86
|
+
*/
|
|
87
|
+
export var Threshold;
|
|
88
|
+
(function (Threshold) {
|
|
89
|
+
Threshold["SHOW"] = "show-threshold";
|
|
90
|
+
Threshold["HIDE"] = "hide-threshold";
|
|
91
|
+
})(Threshold || (Threshold = {}));
|
|
84
92
|
/**
|
|
85
93
|
* enum of all legend related events
|
|
86
94
|
*/
|
package/interfaces/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["events.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,KAGX;AAHD,WAAY,KAAK;IAChB,4CAAmC,CAAA;IACnC,gCAAuB,CAAA;AACxB,CAAC,EAHW,KAAK,KAAL,KAAK,QAGhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,KAEX;AAFD,WAAY,KAAK;IAChB,gCAAuB,CAAA;AACxB,CAAC,EAFW,KAAK,KAAL,KAAK,QAEhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,IAKX;AALD,WAAY,IAAI;IACf,gDAAwC,CAAA;IACxC,gDAAwC,CAAA;IACxC,wCAAgC,CAAA;IAChC,8CAAsC,CAAA;AACvC,CAAC,EALW,IAAI,KAAJ,IAAI,QAKf;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,GAKX;AALD,WAAY,GAAG;IACd,8CAAuC,CAAA;IACvC,8CAAuC,CAAA;IACvC,sCAA+B,CAAA;IAC/B,4CAAqC,CAAA;AACtC,CAAC,EALW,GAAG,KAAH,GAAG,QAKd;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,GAKX;AALD,WAAY,GAAG;IACd,sCAA+B,CAAA;IAC/B,sCAA+B,CAAA;IAC/B,8BAAuB,CAAA;IACvB,oCAA6B,CAAA;AAC9B,CAAC,EALW,GAAG,KAAH,GAAG,QAKd;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,OAKX;AALD,WAAY,OAAO;IAClB,kDAAuC,CAAA;IACvC,kDAAuC,CAAA;IACvC,0CAA+B,CAAA;IAC/B,gDAAqC,CAAA;AACtC,CAAC,EALW,OAAO,KAAP,OAAO,QAKlB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,IAKX;AALD,WAAY,IAAI;IACf,6CAAqC,CAAA;IACrC,6CAAqC,CAAA;IACrC,qCAA6B,CAAA;IAC7B,2CAAmC,CAAA;AACpC,CAAC,EALW,IAAI,KAAJ,IAAI,QAKf;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,KAKX;AALD,WAAY,KAAK;IAChB,oDAA2C,CAAA;IAC3C,oDAA2C,CAAA;IAC3C,4CAAmC,CAAA;IACnC,kDAAyC,CAAA;AAC1C,CAAC,EALW,KAAK,KAAL,KAAK,QAKhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IAClB,gCAAqB,CAAA;IACrB,gCAAqB,CAAA;AACtB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IACjB,4CAAkC,CAAA;IAClC,4CAAkC,CAAA;IAClC,kDAAwC,CAAA;IACxC,8CAAoC,CAAA;AACrC,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB","sourcesContent":["/**\n * enum of all events related to the chart on the DOM\n */\nexport enum Chart {\n\tRENDER_FINISHED = \"render-finished\",\n\tRESIZE = \"chart-resize\"\n}\n\n/**\n * enum of all events related to the chart model\n */\nexport enum Model {\n\tUPDATE = \"model-update\"\n}\n\n/**\n * enum of all axis-related events\n */\nexport enum Axis {\n\tLABEL_MOUSEOVER = \"axis-label-mouseover\",\n\tLABEL_MOUSEMOVE = \"axis-label-mousemove\",\n\tLABEL_CLICK = \"axis-label-click\",\n\tLABEL_MOUSEOUT = \"axis-label-mouseout\"\n}\n\n/**\n * enum of all pie graph events\n */\nexport enum Pie {\n\tSLICE_MOUSEOVER = \"pie-slice-mouseover\",\n\tSLICE_MOUSEMOVE = \"pie-slice-mousemove\",\n\tSLICE_CLICK = \"pie-slice-click\",\n\tSLICE_MOUSEOUT = \"pie-slice-mouseout\"\n}\n\n/**\n * enum of all bar graph events\n */\nexport enum Bar {\n\tBAR_MOUSEOVER = \"bar-mouseover\",\n\tBAR_MOUSEMOVE = \"bar-mousemove\",\n\tBAR_CLICK = \"bar-click\",\n\tBAR_MOUSEOUT = \"bar-mouseout\"\n}\n\n/**\n * enum of all scatter graph events\n */\nexport enum Scatter {\n\tSCATTER_MOUSEOVER = \"scatter-mouseover\",\n\tSCATTER_MOUSEMOVE = \"scatter-mousemove\",\n\tSCATTER_CLICK = \"scatter-click\",\n\tSCATTER_MOUSEOUT = \"scatter-mouseout\"\n}\n\n/**\n * enum of all line graph events\n */\nexport enum Line {\n\tPOINT_MOUSEOVER = \"scatter-mouseover\",\n\tPOINT_MOUSEMOVE = \"scatter-mousemove\",\n\tPOINT_CLICK = \"scatter-click\",\n\tPOINT_MOUSEOUT = \"scatter-mouseout\"\n}\n\n/**\n * enum of all radar graph events\n */\nexport enum Radar {\n\tX_AXIS_MOUSEOVER = \"radar-x-axis-mouseover\",\n\tX_AXIS_MOUSEMOVE = \"radar-x-axis-mousemove\",\n\tX_AXIS_CLICK = \"radar-x-axis-click\",\n\tX_AXIS_MOUSEOUT = \"radar-x-axis-mouseout\"\n}\n\n/**\n * enum of all tooltip events\n */\nexport enum Tooltip {\n\tSHOW = \"show-tooltip\",\n\tHIDE = \"hide-tooltip\"\n}\n\n/**\n * enum of all legend related events\n */\nexport enum Legend {\n\tITEM_HOVER = \"legend-item-onhover\",\n\tITEM_CLICK = \"legend-item-onclick\",\n\tITEM_MOUSEOUT = \"legend-item-onmouseout\",\n\tITEMS_UPDATE = \"legend-items-update\"\n}\n"]}
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["events.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,KAGX;AAHD,WAAY,KAAK;IAChB,4CAAmC,CAAA;IACnC,gCAAuB,CAAA;AACxB,CAAC,EAHW,KAAK,KAAL,KAAK,QAGhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,KAEX;AAFD,WAAY,KAAK;IAChB,gCAAuB,CAAA;AACxB,CAAC,EAFW,KAAK,KAAL,KAAK,QAEhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,IAKX;AALD,WAAY,IAAI;IACf,gDAAwC,CAAA;IACxC,gDAAwC,CAAA;IACxC,wCAAgC,CAAA;IAChC,8CAAsC,CAAA;AACvC,CAAC,EALW,IAAI,KAAJ,IAAI,QAKf;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,GAKX;AALD,WAAY,GAAG;IACd,8CAAuC,CAAA;IACvC,8CAAuC,CAAA;IACvC,sCAA+B,CAAA;IAC/B,4CAAqC,CAAA;AACtC,CAAC,EALW,GAAG,KAAH,GAAG,QAKd;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,GAKX;AALD,WAAY,GAAG;IACd,sCAA+B,CAAA;IAC/B,sCAA+B,CAAA;IAC/B,8BAAuB,CAAA;IACvB,oCAA6B,CAAA;AAC9B,CAAC,EALW,GAAG,KAAH,GAAG,QAKd;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,OAKX;AALD,WAAY,OAAO;IAClB,kDAAuC,CAAA;IACvC,kDAAuC,CAAA;IACvC,0CAA+B,CAAA;IAC/B,gDAAqC,CAAA;AACtC,CAAC,EALW,OAAO,KAAP,OAAO,QAKlB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,IAKX;AALD,WAAY,IAAI;IACf,6CAAqC,CAAA;IACrC,6CAAqC,CAAA;IACrC,qCAA6B,CAAA;IAC7B,2CAAmC,CAAA;AACpC,CAAC,EALW,IAAI,KAAJ,IAAI,QAKf;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,KAKX;AALD,WAAY,KAAK;IAChB,oDAA2C,CAAA;IAC3C,oDAA2C,CAAA;IAC3C,4CAAmC,CAAA;IACnC,kDAAyC,CAAA;AAC1C,CAAC,EALW,KAAK,KAAL,KAAK,QAKhB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IAClB,gCAAqB,CAAA;IACrB,gCAAqB,CAAA;AACtB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACpB,oCAAuB,CAAA;IACvB,oCAAuB,CAAA;AACxB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IACjB,4CAAkC,CAAA;IAClC,4CAAkC,CAAA;IAClC,kDAAwC,CAAA;IACxC,8CAAoC,CAAA;AACrC,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB","sourcesContent":["/**\n * enum of all events related to the chart on the DOM\n */\nexport enum Chart {\n\tRENDER_FINISHED = \"render-finished\",\n\tRESIZE = \"chart-resize\"\n}\n\n/**\n * enum of all events related to the chart model\n */\nexport enum Model {\n\tUPDATE = \"model-update\"\n}\n\n/**\n * enum of all axis-related events\n */\nexport enum Axis {\n\tLABEL_MOUSEOVER = \"axis-label-mouseover\",\n\tLABEL_MOUSEMOVE = \"axis-label-mousemove\",\n\tLABEL_CLICK = \"axis-label-click\",\n\tLABEL_MOUSEOUT = \"axis-label-mouseout\"\n}\n\n/**\n * enum of all pie graph events\n */\nexport enum Pie {\n\tSLICE_MOUSEOVER = \"pie-slice-mouseover\",\n\tSLICE_MOUSEMOVE = \"pie-slice-mousemove\",\n\tSLICE_CLICK = \"pie-slice-click\",\n\tSLICE_MOUSEOUT = \"pie-slice-mouseout\"\n}\n\n/**\n * enum of all bar graph events\n */\nexport enum Bar {\n\tBAR_MOUSEOVER = \"bar-mouseover\",\n\tBAR_MOUSEMOVE = \"bar-mousemove\",\n\tBAR_CLICK = \"bar-click\",\n\tBAR_MOUSEOUT = \"bar-mouseout\"\n}\n\n/**\n * enum of all scatter graph events\n */\nexport enum Scatter {\n\tSCATTER_MOUSEOVER = \"scatter-mouseover\",\n\tSCATTER_MOUSEMOVE = \"scatter-mousemove\",\n\tSCATTER_CLICK = \"scatter-click\",\n\tSCATTER_MOUSEOUT = \"scatter-mouseout\"\n}\n\n/**\n * enum of all line graph events\n */\nexport enum Line {\n\tPOINT_MOUSEOVER = \"scatter-mouseover\",\n\tPOINT_MOUSEMOVE = \"scatter-mousemove\",\n\tPOINT_CLICK = \"scatter-click\",\n\tPOINT_MOUSEOUT = \"scatter-mouseout\"\n}\n\n/**\n * enum of all radar graph events\n */\nexport enum Radar {\n\tX_AXIS_MOUSEOVER = \"radar-x-axis-mouseover\",\n\tX_AXIS_MOUSEMOVE = \"radar-x-axis-mousemove\",\n\tX_AXIS_CLICK = \"radar-x-axis-click\",\n\tX_AXIS_MOUSEOUT = \"radar-x-axis-mouseout\"\n}\n\n/**\n * enum of all tooltip events\n */\nexport enum Tooltip {\n\tSHOW = \"show-tooltip\",\n\tHIDE = \"hide-tooltip\"\n}\n\n/**\n * enum of all threshold events\n */\nexport enum Threshold {\n\tSHOW = \"show-threshold\",\n\tHIDE = \"hide-threshold\"\n}\n\n/**\n * enum of all legend related events\n */\nexport enum Legend {\n\tITEM_HOVER = \"legend-item-onhover\",\n\tITEM_CLICK = \"legend-item-onclick\",\n\tITEM_MOUSEOUT = \"legend-item-onmouseout\",\n\tITEMS_UPDATE = \"legend-items-update\"\n}\n"]}
|
package/model.d.ts
CHANGED
package/model.js
CHANGED
|
@@ -36,6 +36,9 @@ var ChartModel = /** @class */ (function () {
|
|
|
36
36
|
ChartModel.prototype.getData = function () {
|
|
37
37
|
return this.get("data");
|
|
38
38
|
};
|
|
39
|
+
ChartModel.prototype.isDataEmpty = function () {
|
|
40
|
+
return !this.getData().length;
|
|
41
|
+
};
|
|
39
42
|
/**
|
|
40
43
|
*
|
|
41
44
|
* @param newData The new raw data to be set
|
|
@@ -68,15 +71,15 @@ var ChartModel = /** @class */ (function () {
|
|
|
68
71
|
var groupMapsTo = this.getOptions().data.groupMapsTo;
|
|
69
72
|
displayData.map(function (datum) {
|
|
70
73
|
var group = datum[groupMapsTo];
|
|
71
|
-
if (groupedData[group] !== null &&
|
|
74
|
+
if (groupedData[group] !== null &&
|
|
75
|
+
groupedData[group] !== undefined) {
|
|
72
76
|
groupedData[group].push(datum);
|
|
73
77
|
}
|
|
74
78
|
else {
|
|
75
79
|
groupedData[group] = [datum];
|
|
76
80
|
}
|
|
77
81
|
});
|
|
78
|
-
return Object.keys(groupedData)
|
|
79
|
-
.map(function (groupName) { return ({
|
|
82
|
+
return Object.keys(groupedData).map(function (groupName) { return ({
|
|
80
83
|
name: groupName,
|
|
81
84
|
data: groupedData[groupName]
|
|
82
85
|
}); });
|
|
@@ -93,10 +96,12 @@ var ChartModel = /** @class */ (function () {
|
|
|
93
96
|
var correspondingValues = { sharedStackKey: key };
|
|
94
97
|
dataGroupNames.forEach(function (dataGroupName) {
|
|
95
98
|
var correspondingDatum = displayData.find(function (datum) {
|
|
96
|
-
return datum[groupMapsTo] === dataGroupName &&
|
|
97
|
-
datum[domainIdentifier].toString() === key;
|
|
99
|
+
return (datum[groupMapsTo] === dataGroupName &&
|
|
100
|
+
datum[domainIdentifier].toString() === key);
|
|
98
101
|
});
|
|
99
|
-
correspondingValues[dataGroupName] = correspondingDatum
|
|
102
|
+
correspondingValues[dataGroupName] = correspondingDatum
|
|
103
|
+
? correspondingDatum[rangeIdentifier]
|
|
104
|
+
: null;
|
|
100
105
|
});
|
|
101
106
|
return correspondingValues;
|
|
102
107
|
});
|
|
@@ -106,7 +111,8 @@ var ChartModel = /** @class */ (function () {
|
|
|
106
111
|
var groupMapsTo = options.data.groupMapsTo;
|
|
107
112
|
var dataGroupNames = this.getDataGroupNames();
|
|
108
113
|
var dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys();
|
|
109
|
-
return stack()
|
|
114
|
+
return stack()
|
|
115
|
+
.keys(dataGroupNames)(dataValuesGroupedByKeys)
|
|
110
116
|
.map(function (series, i) {
|
|
111
117
|
// Add data group names to each series
|
|
112
118
|
return Object.keys(series)
|
|
@@ -166,7 +172,7 @@ var ChartModel = /** @class */ (function () {
|
|
|
166
172
|
};
|
|
167
173
|
/*
|
|
168
174
|
* Data labels
|
|
169
|
-
|
|
175
|
+
*/
|
|
170
176
|
ChartModel.prototype.toggleDataLabel = function (changedLabel) {
|
|
171
177
|
var _a = Configuration.legend.items.status, ACTIVE = _a.ACTIVE, DISABLED = _a.DISABLED;
|
|
172
178
|
var dataGroups = this.getDataGroups();
|
|
@@ -176,7 +182,8 @@ var ChartModel = /** @class */ (function () {
|
|
|
176
182
|
if (hasDeactivatedItems) {
|
|
177
183
|
// If the only active item is being toggled
|
|
178
184
|
// Activate all items
|
|
179
|
-
if (activeItems.length === 1 &&
|
|
185
|
+
if (activeItems.length === 1 &&
|
|
186
|
+
activeItems[0].name === changedLabel) {
|
|
180
187
|
// If every item is active, then enable "changedLabel" and disable all other items
|
|
181
188
|
dataGroups.forEach(function (group, i) {
|
|
182
189
|
dataGroups[i].status = ACTIVE;
|
|
@@ -184,13 +191,17 @@ var ChartModel = /** @class */ (function () {
|
|
|
184
191
|
}
|
|
185
192
|
else {
|
|
186
193
|
var indexToChange = dataGroups.findIndex(function (group) { return group.name === changedLabel; });
|
|
187
|
-
dataGroups[indexToChange].status =
|
|
194
|
+
dataGroups[indexToChange].status =
|
|
195
|
+
dataGroups[indexToChange].status === DISABLED
|
|
196
|
+
? ACTIVE
|
|
197
|
+
: DISABLED;
|
|
188
198
|
}
|
|
189
199
|
}
|
|
190
200
|
else {
|
|
191
201
|
// If every item is active, then enable "changedLabel" and disable all other items
|
|
192
202
|
dataGroups.forEach(function (group, i) {
|
|
193
|
-
dataGroups[i].status =
|
|
203
|
+
dataGroups[i].status =
|
|
204
|
+
group.name === changedLabel ? ACTIVE : DISABLED;
|
|
194
205
|
});
|
|
195
206
|
}
|
|
196
207
|
// dispatch legend filtering event with the status of all the dataLabels
|
|
@@ -295,7 +306,7 @@ var ChartModel = /** @class */ (function () {
|
|
|
295
306
|
};
|
|
296
307
|
/*
|
|
297
308
|
* Data groups
|
|
298
|
-
|
|
309
|
+
*/
|
|
299
310
|
ChartModel.prototype.updateAllDataGroups = function () {
|
|
300
311
|
// allDataGroups is used to generate a color scale that applies
|
|
301
312
|
// to all the groups. Now when the data updates, you might remove a group,
|
|
@@ -329,14 +340,16 @@ var ChartModel = /** @class */ (function () {
|
|
|
329
340
|
};
|
|
330
341
|
/*
|
|
331
342
|
* Fill scales
|
|
332
|
-
|
|
343
|
+
*/
|
|
333
344
|
ChartModel.prototype.setColorScale = function () {
|
|
334
345
|
var defaultColors = colorPalettes.DEFAULT;
|
|
335
346
|
var options = this.getOptions();
|
|
336
347
|
var userProvidedScale = Tools.getProperty(options, "color", "scale");
|
|
337
348
|
// If there is no valid user provided scale, use the default set of colors
|
|
338
|
-
if (userProvidedScale === null ||
|
|
339
|
-
|
|
349
|
+
if (userProvidedScale === null ||
|
|
350
|
+
Object.keys(userProvidedScale).length === 0) {
|
|
351
|
+
this.colorScale = scaleOrdinal()
|
|
352
|
+
.range(defaultColors)
|
|
340
353
|
.domain(this.allDataGroups);
|
|
341
354
|
return;
|
|
342
355
|
}
|
|
@@ -361,7 +374,8 @@ var ChartModel = /** @class */ (function () {
|
|
|
361
374
|
colorIndex++;
|
|
362
375
|
}
|
|
363
376
|
});
|
|
364
|
-
this.colorScale = scaleOrdinal()
|
|
377
|
+
this.colorScale = scaleOrdinal()
|
|
378
|
+
.range(colorRange)
|
|
365
379
|
.domain(this.allDataGroups);
|
|
366
380
|
};
|
|
367
381
|
return ChartModel;
|
package/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["model.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,KAAK;AACL,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;qEACqE;AACrE;IAwBC,oBAAY,QAAa;QAfzB,uBAAuB;QACb,UAAK,GAAQ;YACtB,OAAO,EAAE,EAAE;SACX,CAAC;QASF,qCAAqC;QAC3B,eAAU,GAAQ,EAAE,CAAC;QAG9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,mCAAc,GAAd;QACC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC;SACZ;QAEO,IAAA,iDAAM,CAAuC;QACrD,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAExC,0CAA0C;QAC1C,IAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1C,IAAA,gDAAW,CAA4B;QAE/C,OAAO,WAAW,CAAC,MAAM,CAAC,UAAA,KAAK;YAC9B,IAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,IAAI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;MAEE;IACQ,kCAAa,GAAvB;QACC,IAAI,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC;QAE1C,IAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,IAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAEvE,0EAA0E;QAC1E,IAAI,iBAAiB,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9E,IAAI,CAAC,UAAU,GAAG,YAAY,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC;iBACnD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAE7B,OAAO;SACP;QAED;;;;WAIG;QACH,IAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAA,SAAS;YACnC,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE;gBACjC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;aAC9C;iBAAM;gBACN,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;aAC3C;YAED,IAAI,UAAU,KAAK,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5C,UAAU,GAAG,CAAC,CAAC;aACf;iBAAM;gBACN,UAAU,EAAE,CAAC;aACb;QACF,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,YAAY,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC;aAChD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IACF,iBAAC;AAAD,CAAC,AAvaD,IAuaC","sourcesContent":["// Internal Imports\nimport * as Configuration from \"./configuration\";\nimport { Tools } from \"./tools\";\nimport * as colorPalettes from \"./services/colorPalettes\";\nimport { Events } from \"./interfaces\";\n\n// D3\nimport { scaleOrdinal } from \"d3-scale\";\nimport { map } from \"d3-collection\";\nimport { stack } from \"d3-shape\";\n\n/** The charting model layer which includes mainly the chart data and options,\n * as well as some misc. information to be shared among components */\nexport class ChartModel {\n\t// Callbacks\n\t/**\n\t * Function to be called when data or options update within the model\n\t * @type Function\n\t */\n\tprotected updateCallback: Function;\n\tprotected services: any;\n\n\t// Internal Model state\n\tprotected state: any = {\n\t\toptions: {}\n\t};\n\n\t// Data labels\n\t/**\n\t * A list of all the data groups that have existed within the lifetime of the chart\n\t * @type string[]\n\t */\n\tprotected allDataGroups: string[];\n\n\t// Fill scales & fill related objects\n\tprotected colorScale: any = {};\n\n\tconstructor(services: any) {\n\t\tthis.services = services;\n\t}\n\n\tgetDisplayData() {\n\t\tif (!this.get(\"data\")) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\t// Remove datasets that have been disabled\n\t\tconst displayData = Tools.clone(this.get(\"data\"));\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\treturn displayData.filter(datum => {\n\t\t\tconst group = dataGroups.find(group => group.name === datum[groupMapsTo]);\n\n\t\t\treturn group.status === ACTIVE;\n\t\t});\n\t}\n\n\tgetData() {\n\t\treturn this.get(\"data\");\n\t}\n\n\t/**\n\t *\n\t * @param newData The new raw data to be set\n\t */\n\tsetData(newData) {\n\t\tconst sanitizedData = this.sanitize(Tools.clone(newData));\n\t\tconst dataGroups = this.generateDataGroups(sanitizedData);\n\n\t\tthis.set({\n\t\t\tdata: sanitizedData,\n\t\t\tdataGroups\n\t\t});\n\n\t\treturn sanitizedData;\n\t}\n\n\tgetDataGroups() {\n\t\treturn this.get(\"dataGroups\");\n\t}\n\n\tgetActiveDataGroups() {\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\treturn this.getDataGroups().filter(dataGroup => dataGroup.status === ACTIVE);\n\t}\n\n\tgetDataGroupNames() {\n\t\treturn this.getDataGroups().map(dataGroup => dataGroup.name);\n\t}\n\n\tgetActiveDataGroupNames() {\n\t\treturn this.getActiveDataGroups().map(dataGroup => dataGroup.name);\n\t}\n\n\tgetGroupedData() {\n\t\tconst displayData = this.getDisplayData();\n\t\tconst groupedData = {};\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\tdisplayData.map(datum => {\n\t\t\tconst group = datum[groupMapsTo];\n\t\t\tif (groupedData[group] !== null && groupedData[group] !== undefined) {\n\t\t\t\tgroupedData[group].push(datum);\n\t\t\t} else {\n\t\t\t\tgroupedData[group] = [datum];\n\t\t\t}\n\t\t});\n\n\t\treturn Object.keys(groupedData)\n\t\t\t.map(groupName => ({\n\t\t\t\tname: groupName,\n\t\t\t\tdata: groupedData[groupName]\n\t\t\t}));\n\t}\n\n\tgetDataValuesGroupedByKeys() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst displayData = this.getDisplayData();\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\tconst stackKeys = map(displayData, datum => datum[domainIdentifier]).keys();\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\n\t\treturn stackKeys.map(key => {\n\t\t\tconst correspondingValues = { sharedStackKey: key };\n\t\t\tdataGroupNames.forEach(dataGroupName => {\n\t\t\t\tconst correspondingDatum = displayData.find(datum => {\n\t\t\t\t\treturn datum[groupMapsTo] === dataGroupName &&\n\t\t\t\t\t\tdatum[domainIdentifier].toString() === key;\n\t\t\t\t});\n\n\t\t\t\tcorrespondingValues[dataGroupName] = correspondingDatum ? correspondingDatum[rangeIdentifier] : null;\n\t\t\t});\n\t\t\treturn correspondingValues;\n\t\t}) as any;\n\t}\n\n\tgetStackedData() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\t\tconst dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys();\n\n\t\treturn stack().keys(dataGroupNames)(dataValuesGroupedByKeys)\n\t\t\t.map((series, i) => {\n\t\t\t\t// Add data group names to each series\n\t\t\t\treturn Object.keys(series)\n\t\t\t\t\t.filter((key: any) => !isNaN(key))\n\t\t\t\t\t.map(key => {\n\t\t\t\t\t\tconst element = series[key];\n\t\t\t\t\t\telement[groupMapsTo] = dataGroupNames[i];\n\n\t\t\t\t\t\treturn element;\n\t\t\t\t\t});\n\t\t\t});\n\t}\n\n\t/**\n\t * @return {Object} The chart's options\n\t */\n\tgetOptions() {\n\t\treturn this.state.options;\n\t}\n\n\tset(newState: any, skipUpdate = false) {\n\t\tthis.state = Object.assign({}, this.state, newState);\n\n\t\tif (!skipUpdate) {\n\t\t\tthis.update();\n\t\t}\n\t}\n\n\tget(property?: string) {\n\t\tif (property) {\n\t\t\treturn this.state[property];\n\t\t} else {\n\t\t\treturn this.state;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * @param newOptions New options to be set\n\t */\n\tsetOptions(newOptions) {\n\t\tthis.set({\n\t\t\toptions: Tools.merge(this.getOptions(), newOptions)\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * Updates miscellanous information within the model\n\t * such as the color scales, or the legend data labels\n\t */\n\tupdate() {\n\t\tif (!this.getDisplayData()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updateAllDataGroups();\n\n\t\tthis.setColorScale();\n\t\tthis.services.events.dispatchEvent(Events.Model.UPDATE);\n\t}\n\n\tsetUpdateCallback(cb: Function) {\n\t\tthis.updateCallback = cb;\n\t}\n\n\t/*\n\t * Data labels\n\t*/\n\ttoggleDataLabel(changedLabel: string) {\n\t\tconst { ACTIVE, DISABLED } = Configuration.legend.items.status;\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\tconst hasDeactivatedItems = dataGroups.some(group => group.status === DISABLED);\n\t\tconst activeItems = dataGroups.filter(group => group.status === ACTIVE);\n\n\t\t// If there are deactivated items, toggle \"changedLabel\"\n\t\tif (hasDeactivatedItems) {\n\t\t\t// If the only active item is being toggled\n\t\t\t// Activate all items\n\t\t\tif (activeItems.length === 1 && activeItems[0].name === changedLabel) {\n\t\t\t\t// If every item is active, then enable \"changedLabel\" and disable all other items\n\t\t\t\tdataGroups.forEach((group, i) => {\n\t\t\t\t\tdataGroups[i].status = ACTIVE;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst indexToChange = dataGroups.findIndex(group => group.name === changedLabel);\n\t\t\t\tdataGroups[indexToChange].status = dataGroups[indexToChange].status === DISABLED ? ACTIVE : DISABLED;\n\t\t\t}\n\t\t} else {\n\t\t\t// If every item is active, then enable \"changedLabel\" and disable all other items\n\t\t\tdataGroups.forEach((group, i) => {\n\t\t\t\tdataGroups[i].status = (group.name === changedLabel ? ACTIVE : DISABLED);\n\t\t\t});\n\t\t}\n\n\t\t// dispatch legend filtering event with the status of all the dataLabels\n\t\tthis.services.events.dispatchEvent(Events.Legend.ITEMS_UPDATE, {\n\t\t\tdataGroups\n\t\t});\n\n\t\t// Update model\n\t\tthis.set({\n\t\t\tdataGroups\n\t\t});\n\t}\n\n\t/**\n\t * Should the data point be filled?\n\t * @param group\n\t * @param key\n\t * @param value\n\t * @param defaultFilled the default for this chart\n\t */\n\tgetIsFilled(group: any, key?: any, data?: any, defaultFilled?: boolean) {\n\t\tconst options = this.getOptions();\n\t\tif (options.getIsFilled) {\n\t\t\treturn options.getIsFilled(group, key, data, defaultFilled);\n\t\t} else {\n\t\t\treturn defaultFilled;\n\t\t}\n\t}\n\n\tgetFillColor(group: any, key?: any, data?: any) {\n\t\tconst options = this.getOptions();\n\t\tconst defaultFillColor = this.getFillScale()(group);\n\t\tif (options.getFillColor) {\n\t\t\treturn options.getFillColor(group, key, data, defaultFillColor);\n\t\t} else {\n\t\t\treturn defaultFillColor;\n\t\t}\n\t}\n\n\tgetStrokeColor(group: any, key?: any, data?: any) {\n\t\tconst options = this.getOptions();\n\t\tconst defaultStrokeColor = this.colorScale(group);\n\t\tif (options.getStrokeColor) {\n\t\t\treturn options.getStrokeColor(group, key, data, defaultStrokeColor);\n\t\t} else {\n\t\t\treturn defaultStrokeColor;\n\t\t}\n\t}\n\n\tgetFillScale() {\n\t\treturn this.colorScale;\n\t}\n\n\t/**\n\t * Converts data provided in the older format to tabular\n\t *\n\t */\n\tprotected transformToTabularData(data) {\n\t\tconsole.warn(\"We've updated the charting data format to be tabular by default. The current format you're using is deprecated and will be removed in v1.0, read more here https://carbon-design-system.github.io/carbon-charts/?path=/story/tutorials--tabular-data-format\")\n\t\tconst tabularData = [];\n\t\tconst { datasets, labels } = data;\n\n\t\t// Loop through all datasets\n\t\tdatasets.forEach(dataset => {\n\t\t\t// Update each data point to the new format\n\t\t\tdataset.data.forEach((datum, i) => {\n\t\t\t\tlet group;\n\n\t\t\t\tconst datasetLabel = Tools.getProperty(dataset, \"label\");\n\t\t\t\tif (datasetLabel === null) {\n\t\t\t\t\tconst correspondingLabel = Tools.getProperty(labels, i);\n\t\t\t\t\tif (correspondingLabel) {\n\t\t\t\t\t\tgroup = correspondingLabel;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgroup = \"Ungrouped\";\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tgroup = datasetLabel;\n\t\t\t\t}\n\n\t\t\t\tconst updatedDatum = {\n\t\t\t\t\tgroup,\n\t\t\t\t\tkey: labels[i]\n\t\t\t\t};\n\n\t\t\t\tif (isNaN(datum)) {\n\t\t\t\t\tupdatedDatum[\"value\"] = datum.value;\n\t\t\t\t\tupdatedDatum[\"date\"] = datum.date;\n\t\t\t\t} else {\n\t\t\t\t\tupdatedDatum[\"value\"] = datum;\n\t\t\t\t}\n\n\t\t\t\ttabularData.push(updatedDatum);\n\t\t\t});\n\t\t});\n\n\t\treturn tabularData;\n\t}\n\n\tprotected getTabularData(data) {\n\t\t// if data is not an array\n\t\tif (!Array.isArray(data)) {\n\t\t\treturn this.transformToTabularData(data);\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tprotected sanitize(data) {\n\t\treturn this.getTabularData(data);\n\t}\n\n\t/*\n\t * Data groups\n\t*/\n\tprotected updateAllDataGroups() {\n\t\t// allDataGroups is used to generate a color scale that applies\n\t\t// to all the groups. Now when the data updates, you might remove a group,\n\t\t// and then bring it back in a newer data update, therefore\n\t\t// the order of the groups in allDataGroups matters so that you'd never\n\t\t// have an incorrect color assigned to a group.\n\n\t\t// Also, a new group should only be added to allDataGroups if\n\t\t// it doesn't currently exist\n\n\t\tif (!this.allDataGroups) {\n\t\t\tthis.allDataGroups = this.getDataGroupNames();\n\t\t} else {\n\t\t\t// Loop through current data groups\n\t\t\tthis.getDataGroupNames().forEach(dataGroupName => {\n\t\t\t\t// If group name hasn't been stored yet, store it\n\t\t\t\tif (this.allDataGroups.indexOf(dataGroupName) === -1) {\n\t\t\t\t\tthis.allDataGroups.push(dataGroupName);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected generateDataGroups(data) {\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\tconst uniqueDataGroups = map(data, datum => datum[groupMapsTo]).keys();\n\t\treturn uniqueDataGroups.map(groupName => ({\n\t\t\tname: groupName,\n\t\t\tstatus: ACTIVE\n\t\t}));\n\t}\n\n\t/*\n\t * Fill scales\n\t*/\n\tprotected setColorScale() {\n\t\tlet defaultColors = colorPalettes.DEFAULT;\n\n\t\tconst options = this.getOptions();\n\t\tconst userProvidedScale = Tools.getProperty(options, \"color\", \"scale\");\n\n\t\t// If there is no valid user provided scale, use the default set of colors\n\t\tif (userProvidedScale === null || Object.keys(userProvidedScale).length === 0) {\n\t\t\tthis.colorScale = scaleOrdinal().range(defaultColors)\n\t\t\t\t.domain(this.allDataGroups);\n\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * Go through allDataGroups. If a data group has a color value provided\n\t\t * by the user, add that to the color range\n\t\t * If not, add a default color\n\t\t */\n\t\tconst colorRange = [];\n\t\tlet colorIndex = 0;\n\t\tthis.allDataGroups.forEach(dataGroup => {\n\t\t\tif (userProvidedScale[dataGroup]) {\n\t\t\t\tcolorRange.push(userProvidedScale[dataGroup]);\n\t\t\t} else {\n\t\t\t\tcolorRange.push(defaultColors[colorIndex]);\n\t\t\t}\n\n\t\t\tif (colorIndex === defaultColors.length - 1) {\n\t\t\t\tcolorIndex = 0;\n\t\t\t} else {\n\t\t\t\tcolorIndex++;\n\t\t\t}\n\t\t});\n\n\t\tthis.colorScale = scaleOrdinal().range(colorRange)\n\t\t\t.domain(this.allDataGroups);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["model.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,KAAK;AACL,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;qEACqE;AACrE;IAwBC,oBAAY,QAAa;QAfzB,uBAAuB;QACb,UAAK,GAAQ;YACtB,OAAO,EAAE,EAAE;SACX,CAAC;QASF,qCAAqC;QAC3B,eAAU,GAAQ,EAAE,CAAC;QAG9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,mCAAc,GAAd;QACC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC;SACZ;QAEO,IAAA,iDAAM,CAAuC;QACrD,IAA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YAED,IAAI,UAAU,KAAK,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5C,UAAU,GAAG,CAAC,CAAC;aACf;iBAAM;gBACN,UAAU,EAAE,CAAC;aACb;QACF,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,YAAY,EAAE;aAC9B,KAAK,CAAC,UAAU,CAAC;aACjB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,CAAC;IACF,iBAAC;AAAD,CAAC,AA3cD,IA2cC","sourcesContent":["// Internal Imports\nimport * as Configuration from \"./configuration\";\nimport { Tools } from \"./tools\";\nimport * as colorPalettes from \"./services/colorPalettes\";\nimport { Events } from \"./interfaces\";\n\n// D3\nimport { scaleOrdinal } from \"d3-scale\";\nimport { map } from \"d3-collection\";\nimport { stack } from \"d3-shape\";\n\n/** The charting model layer which includes mainly the chart data and options,\n * as well as some misc. information to be shared among components */\nexport class ChartModel {\n\t// Callbacks\n\t/**\n\t * Function to be called when data or options update within the model\n\t * @type Function\n\t */\n\tprotected updateCallback: Function;\n\tprotected services: any;\n\n\t// Internal Model state\n\tprotected state: any = {\n\t\toptions: {}\n\t};\n\n\t// Data labels\n\t/**\n\t * A list of all the data groups that have existed within the lifetime of the chart\n\t * @type string[]\n\t */\n\tprotected allDataGroups: string[];\n\n\t// Fill scales & fill related objects\n\tprotected colorScale: any = {};\n\n\tconstructor(services: any) {\n\t\tthis.services = services;\n\t}\n\n\tgetDisplayData() {\n\t\tif (!this.get(\"data\")) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\t// Remove datasets that have been disabled\n\t\tconst displayData = Tools.clone(this.get(\"data\"));\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\treturn displayData.filter(datum => {\n\t\t\tconst group = dataGroups.find(\n\t\t\t\tgroup => group.name === datum[groupMapsTo]\n\t\t\t);\n\n\t\t\treturn group.status === ACTIVE;\n\t\t});\n\t}\n\n\tgetData() {\n\t\treturn this.get(\"data\");\n\t}\n\n\tisDataEmpty() {\n\t\treturn !this.getData().length;\n\t}\n\n\t/**\n\t *\n\t * @param newData The new raw data to be set\n\t */\n\tsetData(newData) {\n\t\tconst sanitizedData = this.sanitize(Tools.clone(newData));\n\t\tconst dataGroups = this.generateDataGroups(sanitizedData);\n\n\t\tthis.set({\n\t\t\tdata: sanitizedData,\n\t\t\tdataGroups\n\t\t});\n\n\t\treturn sanitizedData;\n\t}\n\n\tgetDataGroups() {\n\t\treturn this.get(\"dataGroups\");\n\t}\n\n\tgetActiveDataGroups() {\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\treturn this.getDataGroups().filter(\n\t\t\tdataGroup => dataGroup.status === ACTIVE\n\t\t);\n\t}\n\n\tgetDataGroupNames() {\n\t\treturn this.getDataGroups().map(dataGroup => dataGroup.name);\n\t}\n\n\tgetActiveDataGroupNames() {\n\t\treturn this.getActiveDataGroups().map(dataGroup => dataGroup.name);\n\t}\n\n\tgetGroupedData() {\n\t\tconst displayData = this.getDisplayData();\n\t\tconst groupedData = {};\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\n\t\tdisplayData.map(datum => {\n\t\t\tconst group = datum[groupMapsTo];\n\t\t\tif (\n\t\t\t\tgroupedData[group] !== null &&\n\t\t\t\tgroupedData[group] !== undefined\n\t\t\t) {\n\t\t\t\tgroupedData[group].push(datum);\n\t\t\t} else {\n\t\t\t\tgroupedData[group] = [datum];\n\t\t\t}\n\t\t});\n\n\t\treturn Object.keys(groupedData).map(groupName => ({\n\t\t\tname: groupName,\n\t\t\tdata: groupedData[groupName]\n\t\t}));\n\t}\n\n\tgetDataValuesGroupedByKeys() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst displayData = this.getDisplayData();\n\t\tconst domainIdentifier = this.services.cartesianScales.getDomainIdentifier();\n\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\n\t\tconst stackKeys = map(\n\t\t\tdisplayData,\n\t\t\tdatum => datum[domainIdentifier]\n\t\t).keys();\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\n\t\treturn stackKeys.map(key => {\n\t\t\tconst correspondingValues = { sharedStackKey: key };\n\t\t\tdataGroupNames.forEach(dataGroupName => {\n\t\t\t\tconst correspondingDatum = displayData.find(datum => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdatum[groupMapsTo] === dataGroupName &&\n\t\t\t\t\t\tdatum[domainIdentifier].toString() === key\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tcorrespondingValues[dataGroupName] = correspondingDatum\n\t\t\t\t\t? correspondingDatum[rangeIdentifier]\n\t\t\t\t\t: null;\n\t\t\t});\n\t\t\treturn correspondingValues;\n\t\t}) as any;\n\t}\n\n\tgetStackedData() {\n\t\tconst options = this.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst dataGroupNames = this.getDataGroupNames();\n\t\tconst dataValuesGroupedByKeys = this.getDataValuesGroupedByKeys();\n\n\t\treturn stack()\n\t\t\t.keys(dataGroupNames)(dataValuesGroupedByKeys)\n\t\t\t.map((series, i) => {\n\t\t\t\t// Add data group names to each series\n\t\t\t\treturn Object.keys(series)\n\t\t\t\t\t.filter((key: any) => !isNaN(key))\n\t\t\t\t\t.map(key => {\n\t\t\t\t\t\tconst element = series[key];\n\t\t\t\t\t\telement[groupMapsTo] = dataGroupNames[i];\n\n\t\t\t\t\t\treturn element;\n\t\t\t\t\t});\n\t\t\t});\n\t}\n\n\t/**\n\t * @return {Object} The chart's options\n\t */\n\tgetOptions() {\n\t\treturn this.state.options;\n\t}\n\n\tset(newState: any, skipUpdate = false) {\n\t\tthis.state = Object.assign({}, this.state, newState);\n\n\t\tif (!skipUpdate) {\n\t\t\tthis.update();\n\t\t}\n\t}\n\n\tget(property?: string) {\n\t\tif (property) {\n\t\t\treturn this.state[property];\n\t\t} else {\n\t\t\treturn this.state;\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * @param newOptions New options to be set\n\t */\n\tsetOptions(newOptions) {\n\t\tthis.set({\n\t\t\toptions: Tools.merge(this.getOptions(), newOptions)\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * Updates miscellanous information within the model\n\t * such as the color scales, or the legend data labels\n\t */\n\tupdate() {\n\t\tif (!this.getDisplayData()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updateAllDataGroups();\n\n\t\tthis.setColorScale();\n\t\tthis.services.events.dispatchEvent(Events.Model.UPDATE);\n\t}\n\n\tsetUpdateCallback(cb: Function) {\n\t\tthis.updateCallback = cb;\n\t}\n\n\t/*\n\t * Data labels\n\t */\n\ttoggleDataLabel(changedLabel: string) {\n\t\tconst { ACTIVE, DISABLED } = Configuration.legend.items.status;\n\t\tconst dataGroups = this.getDataGroups();\n\n\t\tconst hasDeactivatedItems = dataGroups.some(\n\t\t\tgroup => group.status === DISABLED\n\t\t);\n\t\tconst activeItems = dataGroups.filter(group => group.status === ACTIVE);\n\n\t\t// If there are deactivated items, toggle \"changedLabel\"\n\t\tif (hasDeactivatedItems) {\n\t\t\t// If the only active item is being toggled\n\t\t\t// Activate all items\n\t\t\tif (\n\t\t\t\tactiveItems.length === 1 &&\n\t\t\t\tactiveItems[0].name === changedLabel\n\t\t\t) {\n\t\t\t\t// If every item is active, then enable \"changedLabel\" and disable all other items\n\t\t\t\tdataGroups.forEach((group, i) => {\n\t\t\t\t\tdataGroups[i].status = ACTIVE;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst indexToChange = dataGroups.findIndex(\n\t\t\t\t\tgroup => group.name === changedLabel\n\t\t\t\t);\n\t\t\t\tdataGroups[indexToChange].status =\n\t\t\t\t\tdataGroups[indexToChange].status === DISABLED\n\t\t\t\t\t\t? ACTIVE\n\t\t\t\t\t\t: DISABLED;\n\t\t\t}\n\t\t} else {\n\t\t\t// If every item is active, then enable \"changedLabel\" and disable all other items\n\t\t\tdataGroups.forEach((group, i) => {\n\t\t\t\tdataGroups[i].status =\n\t\t\t\t\tgroup.name === changedLabel ? ACTIVE : DISABLED;\n\t\t\t});\n\t\t}\n\n\t\t// dispatch legend filtering event with the status of all the dataLabels\n\t\tthis.services.events.dispatchEvent(Events.Legend.ITEMS_UPDATE, {\n\t\t\tdataGroups\n\t\t});\n\n\t\t// Update model\n\t\tthis.set({\n\t\t\tdataGroups\n\t\t});\n\t}\n\n\t/**\n\t * Should the data point be filled?\n\t * @param group\n\t * @param key\n\t * @param value\n\t * @param defaultFilled the default for this chart\n\t */\n\tgetIsFilled(group: any, key?: any, data?: any, defaultFilled?: boolean) {\n\t\tconst options = this.getOptions();\n\t\tif (options.getIsFilled) {\n\t\t\treturn options.getIsFilled(group, key, data, defaultFilled);\n\t\t} else {\n\t\t\treturn defaultFilled;\n\t\t}\n\t}\n\n\tgetFillColor(group: any, key?: any, data?: any) {\n\t\tconst options = this.getOptions();\n\t\tconst defaultFillColor = this.getFillScale()(group);\n\t\tif (options.getFillColor) {\n\t\t\treturn options.getFillColor(group, key, data, defaultFillColor);\n\t\t} else {\n\t\t\treturn defaultFillColor;\n\t\t}\n\t}\n\n\tgetStrokeColor(group: any, key?: any, data?: any) {\n\t\tconst options = this.getOptions();\n\t\tconst defaultStrokeColor = this.colorScale(group);\n\t\tif (options.getStrokeColor) {\n\t\t\treturn options.getStrokeColor(group, key, data, defaultStrokeColor);\n\t\t} else {\n\t\t\treturn defaultStrokeColor;\n\t\t}\n\t}\n\n\tgetFillScale() {\n\t\treturn this.colorScale;\n\t}\n\n\t/**\n\t * Converts data provided in the older format to tabular\n\t *\n\t */\n\tprotected transformToTabularData(data) {\n\t\tconsole.warn(\n\t\t\t\"We've updated the charting data format to be tabular by default. The current format you're using is deprecated and will be removed in v1.0, read more here https://carbon-design-system.github.io/carbon-charts/?path=/story/tutorials--tabular-data-format\"\n\t\t);\n\t\tconst tabularData = [];\n\t\tconst { datasets, labels } = data;\n\n\t\t// Loop through all datasets\n\t\tdatasets.forEach(dataset => {\n\t\t\t// Update each data point to the new format\n\t\t\tdataset.data.forEach((datum, i) => {\n\t\t\t\tlet group;\n\n\t\t\t\tconst datasetLabel = Tools.getProperty(dataset, \"label\");\n\t\t\t\tif (datasetLabel === null) {\n\t\t\t\t\tconst correspondingLabel = Tools.getProperty(labels, i);\n\t\t\t\t\tif (correspondingLabel) {\n\t\t\t\t\t\tgroup = correspondingLabel;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgroup = \"Ungrouped\";\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tgroup = datasetLabel;\n\t\t\t\t}\n\n\t\t\t\tconst updatedDatum = {\n\t\t\t\t\tgroup,\n\t\t\t\t\tkey: labels[i]\n\t\t\t\t};\n\n\t\t\t\tif (isNaN(datum)) {\n\t\t\t\t\tupdatedDatum[\"value\"] = datum.value;\n\t\t\t\t\tupdatedDatum[\"date\"] = datum.date;\n\t\t\t\t} else {\n\t\t\t\t\tupdatedDatum[\"value\"] = datum;\n\t\t\t\t}\n\n\t\t\t\ttabularData.push(updatedDatum);\n\t\t\t});\n\t\t});\n\n\t\treturn tabularData;\n\t}\n\n\tprotected getTabularData(data) {\n\t\t// if data is not an array\n\t\tif (!Array.isArray(data)) {\n\t\t\treturn this.transformToTabularData(data);\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tprotected sanitize(data) {\n\t\treturn this.getTabularData(data);\n\t}\n\n\t/*\n\t * Data groups\n\t */\n\tprotected updateAllDataGroups() {\n\t\t// allDataGroups is used to generate a color scale that applies\n\t\t// to all the groups. Now when the data updates, you might remove a group,\n\t\t// and then bring it back in a newer data update, therefore\n\t\t// the order of the groups in allDataGroups matters so that you'd never\n\t\t// have an incorrect color assigned to a group.\n\n\t\t// Also, a new group should only be added to allDataGroups if\n\t\t// it doesn't currently exist\n\n\t\tif (!this.allDataGroups) {\n\t\t\tthis.allDataGroups = this.getDataGroupNames();\n\t\t} else {\n\t\t\t// Loop through current data groups\n\t\t\tthis.getDataGroupNames().forEach(dataGroupName => {\n\t\t\t\t// If group name hasn't been stored yet, store it\n\t\t\t\tif (this.allDataGroups.indexOf(dataGroupName) === -1) {\n\t\t\t\t\tthis.allDataGroups.push(dataGroupName);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected generateDataGroups(data) {\n\t\tconst { groupMapsTo } = this.getOptions().data;\n\t\tconst { ACTIVE } = Configuration.legend.items.status;\n\n\t\tconst uniqueDataGroups = map(data, datum => datum[groupMapsTo]).keys();\n\t\treturn uniqueDataGroups.map(groupName => ({\n\t\t\tname: groupName,\n\t\t\tstatus: ACTIVE\n\t\t}));\n\t}\n\n\t/*\n\t * Fill scales\n\t */\n\tprotected setColorScale() {\n\t\tlet defaultColors = colorPalettes.DEFAULT;\n\n\t\tconst options = this.getOptions();\n\t\tconst userProvidedScale = Tools.getProperty(options, \"color\", \"scale\");\n\n\t\t// If there is no valid user provided scale, use the default set of colors\n\t\tif (\n\t\t\tuserProvidedScale === null ||\n\t\t\tObject.keys(userProvidedScale).length === 0\n\t\t) {\n\t\t\tthis.colorScale = scaleOrdinal()\n\t\t\t\t.range(defaultColors)\n\t\t\t\t.domain(this.allDataGroups);\n\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * Go through allDataGroups. If a data group has a color value provided\n\t\t * by the user, add that to the color range\n\t\t * If not, add a default color\n\t\t */\n\t\tconst colorRange = [];\n\t\tlet colorIndex = 0;\n\t\tthis.allDataGroups.forEach(dataGroup => {\n\t\t\tif (userProvidedScale[dataGroup]) {\n\t\t\t\tcolorRange.push(userProvidedScale[dataGroup]);\n\t\t\t} else {\n\t\t\t\tcolorRange.push(defaultColors[colorIndex]);\n\t\t\t}\n\n\t\t\tif (colorIndex === defaultColors.length - 1) {\n\t\t\t\tcolorIndex = 0;\n\t\t\t} else {\n\t\t\t\tcolorIndex++;\n\t\t\t}\n\t\t});\n\n\t\tthis.colorScale = scaleOrdinal()\n\t\t\t.range(colorRange)\n\t\t\t.domain(this.allDataGroups);\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/charts",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.25",
|
|
4
4
|
"description": "Carbon charting components",
|
|
5
5
|
"main": "./bundle.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"test": "karma start --single-run",
|
|
14
14
|
"test:watch": "karma start --no-single-run",
|
|
15
15
|
"clean": "rm -rf dist demo/bundle",
|
|
16
|
+
"format": "prettier . --write \"**/*.{scss,css,js,ts,md}\"",
|
|
16
17
|
"start": "yarn run storybook",
|
|
17
18
|
"storybook": "start-storybook -p 9006 -c .storybook -s ./.storybook/assets"
|
|
18
19
|
},
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
"lerna": "3.13.4",
|
|
97
98
|
"marked": "0.8.2",
|
|
98
99
|
"mini-css-extract-plugin": "0.9.0",
|
|
100
|
+
"prettier": "2.0.5",
|
|
99
101
|
"raw-loader": "0.5.1",
|
|
100
102
|
"react-docgen-typescript-loader": "^3.6.0",
|
|
101
103
|
"rollup": "1.27.10",
|
|
@@ -113,7 +115,7 @@
|
|
|
113
115
|
"typescript": "3.7.5",
|
|
114
116
|
"url-loader": "0.6.2",
|
|
115
117
|
"webpack": "4.41.0",
|
|
116
|
-
"webpack-cli": "3.3.
|
|
118
|
+
"webpack-cli": "3.3.11",
|
|
117
119
|
"webpack-dev-server": "3.7.0"
|
|
118
120
|
},
|
|
119
121
|
"publishConfig": {
|
package/polyfills.js
CHANGED
|
@@ -4,7 +4,11 @@ if (typeof window !== "undefined") {
|
|
|
4
4
|
return false;
|
|
5
5
|
}
|
|
6
6
|
function CustomEvent(event, params) {
|
|
7
|
-
params = params || {
|
|
7
|
+
params = params || {
|
|
8
|
+
bubbles: false,
|
|
9
|
+
cancelable: false,
|
|
10
|
+
detail: undefined
|
|
11
|
+
};
|
|
8
12
|
var evt = document.createEvent("CustomEvent");
|
|
9
13
|
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
|
10
14
|
return evt;
|
|
@@ -14,7 +18,8 @@ if (typeof window !== "undefined") {
|
|
|
14
18
|
})();
|
|
15
19
|
// Avoid multiple instances of babel-polyfill
|
|
16
20
|
function idempotentBabelPolyfill() {
|
|
17
|
-
if ((typeof global !== "undefined" && !global["_babelPolyfill"]) ||
|
|
21
|
+
if ((typeof global !== "undefined" && !global["_babelPolyfill"]) ||
|
|
22
|
+
!window["_babelPolyfill"]) {
|
|
18
23
|
return require("babel-polyfill");
|
|
19
24
|
}
|
|
20
25
|
return null;
|
package/polyfills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["polyfills.ts"],"names":[],"mappings":"AAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAClC,CAAC;QACA,IAAI,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["polyfills.ts"],"names":[],"mappings":"AAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAClC,CAAC;QACA,IAAI,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,EAAE;YAChD,OAAO,KAAK,CAAC;SACb;QAED,SAAS,WAAW,CAAC,KAAK,EAAE,MAAM;YACjC,MAAM,GAAG,MAAM,IAAI;gBAClB,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,SAAS;aACjB,CAAC;YACF,IAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YAChD,GAAG,CAAC,eAAe,CAClB,KAAK,EACL,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,MAAM,CACb,CAAC;YACF,OAAO,GAAG,CAAC;QACZ,CAAC;QAED,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC;QAClD,MAAM,CAAC,aAAa,CAAC,GAAG,WAAkB,CAAC;IAC5C,CAAC,CAAC,EAAE,CAAC;IAEL,6CAA6C;IAC7C,SAAS,uBAAuB;QAC/B,IACC,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YAC5D,CAAC,MAAM,CAAC,gBAAgB,CAAC,EACxB;YACD,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC;SACjC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAED,uBAAuB,EAAE,CAAC;CAC1B","sourcesContent":["if (typeof window !== \"undefined\") {\n\t(function() {\n\t\tif (typeof window[\"CustomEvent\"] === \"function\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction CustomEvent(event, params) {\n\t\t\tparams = params || {\n\t\t\t\tbubbles: false,\n\t\t\t\tcancelable: false,\n\t\t\t\tdetail: undefined\n\t\t\t};\n\t\t\tconst evt = document.createEvent(\"CustomEvent\");\n\t\t\tevt.initCustomEvent(\n\t\t\t\tevent,\n\t\t\t\tparams.bubbles,\n\t\t\t\tparams.cancelable,\n\t\t\t\tparams.detail\n\t\t\t);\n\t\t\treturn evt;\n\t\t}\n\n\t\tCustomEvent.prototype = window[\"Event\"].prototype;\n\t\twindow[\"CustomEvent\"] = CustomEvent as any;\n\t})();\n\n\t// Avoid multiple instances of babel-polyfill\n\tfunction idempotentBabelPolyfill() {\n\t\tif (\n\t\t\t(typeof global !== \"undefined\" && !global[\"_babelPolyfill\"]) ||\n\t\t\t!window[\"_babelPolyfill\"]\n\t\t) {\n\t\t\treturn require(\"babel-polyfill\");\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tidempotentBabelPolyfill();\n}\n"]}
|