@carbon/charts 0.30.17 → 0.30.21
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 +32 -0
- package/build/demo/data/create-codesandbox.d.ts +37 -0
- package/build/demo/data/index.d.ts +6 -0
- package/build/demo/data/line.d.ts +21 -0
- package/build/demo/data/radar.d.ts +42 -0
- package/build/src/charts/index.d.ts +1 -0
- package/build/src/charts/radar.d.ts +6 -0
- package/build/src/components/axes/grid.d.ts +0 -4
- package/build/src/components/axes/ruler.d.ts +17 -0
- package/build/src/components/essentials/tooltip-radar.d.ts +4 -0
- package/build/src/components/graphs/radar.d.ts +22 -0
- package/build/src/components/index.d.ts +2 -0
- package/build/src/configuration.d.ts +2 -1
- package/build/src/interfaces/charts.d.ts +22 -0
- package/build/src/interfaces/enums.d.ts +16 -0
- package/build/src/interfaces/events.d.ts +9 -0
- package/build/src/services/angle-utils.d.ts +205 -0
- package/build/src/tools.d.ts +3 -0
- package/build/stories/tutorials/getting-started/angular.d.ts +1 -0
- package/build/stories/tutorials/getting-started/react.d.ts +1 -0
- package/build/stories/tutorials/getting-started/vanilla.d.ts +1 -0
- package/build/stories/tutorials/getting-started/vue.d.ts +1 -0
- package/build/stories/tutorials/index.d.ts +5 -0
- package/build/stories/tutorials/tabular-data-format.d.ts +1 -0
- package/bundle.js +1 -1
- package/charts/bubble.js +2 -1
- package/charts/bubble.js.map +1 -1
- package/charts/index.d.ts +1 -0
- package/charts/index.js +1 -0
- package/charts/index.js.map +1 -1
- package/charts/line.js +2 -1
- package/charts/line.js.map +1 -1
- package/charts/radar.d.ts +6 -0
- package/charts/radar.js +51 -0
- package/charts/radar.js.map +1 -0
- package/charts/scatter.js +2 -1
- package/charts/scatter.js.map +1 -1
- package/components/axes/grid.d.ts +0 -4
- package/components/axes/grid.js +0 -39
- package/components/axes/grid.js.map +1 -1
- package/components/axes/ruler.d.ts +17 -0
- package/components/axes/ruler.js +177 -0
- package/components/axes/ruler.js.map +1 -0
- package/components/essentials/tooltip-radar.d.ts +4 -0
- package/components/essentials/tooltip-radar.js +42 -0
- package/components/essentials/tooltip-radar.js.map +1 -0
- package/components/graphs/bubble.js +2 -0
- package/components/graphs/bubble.js.map +1 -1
- package/components/graphs/radar.d.ts +22 -0
- package/components/graphs/radar.js +397 -0
- package/components/graphs/radar.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/configuration.d.ts +2 -1
- package/configuration.js +30 -2
- package/configuration.js.map +1 -1
- package/demo/data/bundle.js +1 -1
- package/demo/data/create-codesandbox.d.ts +29 -0
- package/demo/data/create-codesandbox.js +49 -0
- package/demo/data/create-codesandbox.js.map +1 -1
- package/demo/data/index.d.ts +6 -0
- package/demo/data/index.js +34 -1
- package/demo/data/index.js.map +1 -1
- package/demo/data/line.d.ts +21 -0
- package/demo/data/line.js +58 -0
- package/demo/data/line.js.map +1 -1
- package/demo/data/radar.d.ts +42 -0
- package/demo/data/radar.js +101 -0
- package/demo/data/radar.js.map +1 -0
- package/demo/styles.css +88 -0
- 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 +29 -15
- package/interfaces/charts.d.ts +22 -0
- package/interfaces/charts.js.map +1 -1
- package/interfaces/enums.d.ts +16 -0
- package/interfaces/enums.js +18 -0
- package/interfaces/enums.js.map +1 -1
- package/interfaces/events.d.ts +9 -0
- package/interfaces/events.js +10 -0
- package/interfaces/events.js.map +1 -1
- package/package.json +1 -1
- package/services/angle-utils.d.ts +16 -0
- package/services/angle-utils.js +55 -0
- package/services/angle-utils.js.map +1 -0
- package/styles/components/_ruler.scss +21 -0
- package/styles/components/index.scss +1 -0
- package/styles/graphs/_radar.scss +22 -0
- package/styles/graphs/index.scss +1 -0
- package/styles-g10.css +24 -0
- 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 +24 -0
- 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 +24 -0
- 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 +24 -0
- package/styles.css.map +1 -1
- package/styles.min.css +1 -1
- package/styles.min.css.map +1 -1
- package/tools.d.ts +3 -0
- package/tools.js +4 -1
- package/tools.js.map +1 -1
- package/tsconfig.tsbuildinfo +136 -29
package/charts/bubble.js
CHANGED
|
@@ -16,7 +16,7 @@ import { AxisChart } from "../axis-chart";
|
|
|
16
16
|
import * as Configuration from "../configuration";
|
|
17
17
|
import { Tools } from "../tools";
|
|
18
18
|
// Components
|
|
19
|
-
import { Grid, Bubble, TwoDimensionalAxes, TooltipScatter } from "../components/index";
|
|
19
|
+
import { Grid, Ruler, Bubble, TwoDimensionalAxes, TooltipScatter } from "../components/index";
|
|
20
20
|
var BubbleChart = /** @class */ (function (_super) {
|
|
21
21
|
__extends(BubbleChart, _super);
|
|
22
22
|
function BubbleChart(holder, chartConfigs) {
|
|
@@ -33,6 +33,7 @@ var BubbleChart = /** @class */ (function (_super) {
|
|
|
33
33
|
var graphFrameComponents = [
|
|
34
34
|
new TwoDimensionalAxes(this.model, this.services),
|
|
35
35
|
new Grid(this.model, this.services),
|
|
36
|
+
new Ruler(this.model, this.services),
|
|
36
37
|
new Bubble(this.model, this.services)
|
|
37
38
|
];
|
|
38
39
|
var components = this.getAxisChartComponents(graphFrameComponents);
|
package/charts/bubble.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bubble.js","sourceRoot":"","sources":["bubble.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAKlD,OAAO,EAAE,KAAK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C,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC/D,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,kBAAC;AAAD,CAAC,AA9BD,CAAiC,SAAS,GA8BzC","sourcesContent":["// Internal Imports\nimport { AxisChart } from \"../axis-chart\";\nimport * as Configuration from \"../configuration\";\nimport {\n\tChartConfig,\n\tBubbleChartOptions\n} from \"../interfaces/index\";\nimport { Tools } from \"../tools\";\n\n// Components\nimport {\n\tGrid,\n\tRuler,\n\tBubble,\n\tTwoDimensionalAxes,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tTooltip,\n\tLegend,\n\tLayoutComponent,\n\tTooltipScatter\n} from \"../components/index\";\n\nexport class BubbleChart extends AxisChart {\n\tconstructor(holder: Element, chartConfigs: ChartConfig<BubbleChartOptions>) {\n\t\tsuper(holder, chartConfigs);\n\n\t\t// Merge the default options for this chart\n\t\t// With the user provided options\n\t\tthis.model.setOptions(\n\t\t\tTools.mergeDefaultChartOptions(\n\t\t\t\tConfiguration.options.bubbleChart,\n\t\t\t\tchartConfigs.options\n\t\t\t)\n\t\t);\n\n\t\t// Initialize data, services, components etc.\n\t\tthis.init(holder, chartConfigs);\n\t}\n\n\tgetComponents() {\n\t\t// Specify what to render inside the graph-frame\n\t\tconst graphFrameComponents = [\n\t\t\tnew TwoDimensionalAxes(this.model, this.services),\n\t\t\tnew Grid(this.model, this.services),\n\t\t\tnew Ruler(this.model, this.services),\n\t\t\tnew Bubble(this.model, this.services)\n\t\t];\n\n\t\tconst components: any[] = this.getAxisChartComponents(graphFrameComponents);\n\t\tcomponents.push(new TooltipScatter(this.model, this.services));\n\t\treturn components;\n\t}\n}\n"]}
|
package/charts/index.d.ts
CHANGED
package/charts/index.js
CHANGED
package/charts/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC","sourcesContent":["export * from \"./bar-simple\";\nexport * from \"./bar-grouped\";\nexport * from \"./bar-stacked\";\nexport * from \"./bubble\";\nexport * from \"./line\";\nexport * from \"./scatter\";\nexport * from \"./pie\";\nexport * from \"./donut\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC","sourcesContent":["export * from \"./bar-simple\";\nexport * from \"./bar-grouped\";\nexport * from \"./bar-stacked\";\nexport * from \"./bubble\";\nexport * from \"./line\";\nexport * from \"./scatter\";\nexport * from \"./pie\";\nexport * from \"./donut\";\nexport * from \"./radar\";\n"]}
|
package/charts/line.js
CHANGED
|
@@ -16,7 +16,7 @@ import { AxisChart } from "../axis-chart";
|
|
|
16
16
|
import * as Configuration from "../configuration";
|
|
17
17
|
import { Tools } from "../tools";
|
|
18
18
|
// Components
|
|
19
|
-
import { Grid, Line, Scatter, TwoDimensionalAxes, TooltipScatter } from "../components/index";
|
|
19
|
+
import { Grid, Line, Ruler, Scatter, TwoDimensionalAxes, TooltipScatter } from "../components/index";
|
|
20
20
|
var LineChart = /** @class */ (function (_super) {
|
|
21
21
|
__extends(LineChart, _super);
|
|
22
22
|
function LineChart(holder, chartConfigs) {
|
|
@@ -33,6 +33,7 @@ var LineChart = /** @class */ (function (_super) {
|
|
|
33
33
|
var graphFrameComponents = [
|
|
34
34
|
new TwoDimensionalAxes(this.model, this.services),
|
|
35
35
|
new Grid(this.model, this.services),
|
|
36
|
+
new Ruler(this.model, this.services),
|
|
36
37
|
new Line(this.model, this.services),
|
|
37
38
|
new Scatter(this.model, this.services)
|
|
38
39
|
];
|
package/charts/line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.js","sourceRoot":"","sources":["line.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAKlD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,kBAAkB,EAKlB,cAAc,EACd,MAAM,qBAAqB,CAAC;AAE7B;IAA+B,6BAAS;IACvC,mBAAY,MAAe,EAAE,YAA2C;QAAxE,YACC,kBAAM,MAAM,EAAE,YAAY,CAAC,SAa3B;QAXA,2CAA2C;QAC3C,iCAAiC;QACjC,KAAI,CAAC,KAAK,CAAC,UAAU,CACpB,KAAK,CAAC,wBAAwB,CAC7B,aAAa,CAAC,OAAO,CAAC,SAAS,EAC/B,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QAEF,6CAA6C;QAC7C,KAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;;IACjC,CAAC;IAED,iCAAa,GAAb;QACC,gDAAgD;QAChD,IAAM,oBAAoB,GAAG;YAC5B,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACjD,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACnC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAA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,EAAE,IAAI,CAAC,QAAQ,CAAC;YACnC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACpC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACnC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;SACtC,CAAC;QAEF,IAAM,UAAU,GAAU,IAAI,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,CAAC;QAC5E,UAAU,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC/D,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,gBAAC;AAAD,CAAC,AA/BD,CAA+B,SAAS,GA+BvC","sourcesContent":["// Internal Imports\nimport { AxisChart } from \"../axis-chart\";\nimport * as Configuration from \"../configuration\";\nimport {\n\tChartConfig,\n\tLineChartOptions\n} from \"../interfaces/index\";\nimport { Tools } from \"../tools\";\n\n// Components\nimport {\n\tGrid,\n\tLine,\n\tRuler,\n\tScatter,\n\tTwoDimensionalAxes,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tTooltip,\n\tLegend,\n\tLayoutComponent,\n\tTooltipScatter\n} from \"../components/index\";\n\nexport class LineChart extends AxisChart {\n\tconstructor(holder: Element, chartConfigs: ChartConfig<LineChartOptions>) {\n\t\tsuper(holder, chartConfigs);\n\n\t\t// Merge the default options for this chart\n\t\t// With the user provided options\n\t\tthis.model.setOptions(\n\t\t\tTools.mergeDefaultChartOptions(\n\t\t\t\tConfiguration.options.lineChart,\n\t\t\t\tchartConfigs.options\n\t\t\t)\n\t\t);\n\n\t\t// Initialize data, services, components etc.\n\t\tthis.init(holder, chartConfigs);\n\t}\n\n\tgetComponents() {\n\t\t// Specify what to render inside the graph-frame\n\t\tconst graphFrameComponents = [\n\t\t\tnew TwoDimensionalAxes(this.model, this.services),\n\t\t\tnew Grid(this.model, this.services),\n\t\t\tnew Ruler(this.model, this.services),\n\t\t\tnew Line(this.model, this.services),\n\t\t\tnew Scatter(this.model, this.services)\n\t\t];\n\n\t\tconst components: any[] = this.getAxisChartComponents(graphFrameComponents);\n\t\tcomponents.push(new TooltipScatter(this.model, this.services));\n\t\treturn components;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Chart } from "../chart";
|
|
2
|
+
import { ChartConfig, RadarChartOptions } from "../interfaces/index";
|
|
3
|
+
export declare class RadarChart extends Chart {
|
|
4
|
+
constructor(holder: Element, chartConfigs: ChartConfig<RadarChartOptions>, extending?: boolean);
|
|
5
|
+
getComponents(): any[];
|
|
6
|
+
}
|
package/charts/radar.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
// Internal Imports
|
|
15
|
+
import { Chart } from "../chart";
|
|
16
|
+
import * as Configuration from "../configuration";
|
|
17
|
+
import { Tools } from "../tools";
|
|
18
|
+
// Components
|
|
19
|
+
import { TooltipRadar } from "../components/index";
|
|
20
|
+
import { Radar } from "../components/graphs/radar";
|
|
21
|
+
var RadarChart = /** @class */ (function (_super) {
|
|
22
|
+
__extends(RadarChart, _super);
|
|
23
|
+
// TODO - Optimize the use of "extending"
|
|
24
|
+
function RadarChart(holder, chartConfigs, extending) {
|
|
25
|
+
if (extending === void 0) { extending = false; }
|
|
26
|
+
var _this = _super.call(this, holder, chartConfigs) || this;
|
|
27
|
+
// TODO - Optimize the use of "extending"
|
|
28
|
+
if (extending) {
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
// Merge the default options for this chart
|
|
32
|
+
// With the user provided options
|
|
33
|
+
_this.model.setOptions(Tools.mergeDefaultChartOptions(Configuration.options.radarChart, chartConfigs.options));
|
|
34
|
+
// Initialize data, services, components etc.
|
|
35
|
+
_this.init(holder, chartConfigs);
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
RadarChart.prototype.getComponents = function () {
|
|
39
|
+
// Specify what to render inside the graph-frame
|
|
40
|
+
var graphFrameComponents = [
|
|
41
|
+
new Radar(this.model, this.services)
|
|
42
|
+
];
|
|
43
|
+
// get the base chart components and export with tooltip
|
|
44
|
+
var components = this.getChartComponents(graphFrameComponents);
|
|
45
|
+
components.push(new TooltipRadar(this.model, this.services));
|
|
46
|
+
return components;
|
|
47
|
+
};
|
|
48
|
+
return RadarChart;
|
|
49
|
+
}(Chart));
|
|
50
|
+
export { RadarChart };
|
|
51
|
+
//# sourceMappingURL=../../src/charts/radar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radar.js","sourceRoot":"","sources":["radar.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAKlD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EAIN,YAAY,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD;IAAgC,8BAAK;IACpC,yCAAyC;IACzC,oBAAY,MAAe,EAAE,YAA4C,EAAE,SAAiB;QAAjB,0BAAA,EAAA,iBAAiB;QAA5F,YACC,kBAAM,MAAM,EAAE,YAAY,CAAC,SAkB3B;QAhBA,yCAAyC;QACzC,IAAI,SAAS,EAAE;;SAEd;QAED,2CAA2C;QAC3C,iCAAiC;QACjC,KAAI,CAAC,KAAK,CAAC,UAAU,CACpB,KAAK,CAAC,wBAAwB,CAC7B,aAAa,CAAC,OAAO,CAAC,UAAU,EAChC,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QAEF,6CAA6C;QAC7C,KAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;;IACjC,CAAC;IAED,kCAAa,GAAb;QACC,gDAAgD;QAChD,IAAM,oBAAoB,GAAG;YAC5B,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;SACpC,CAAC;QAEF,wDAAwD;QACxD,IAAM,UAAU,GAAU,IAAI,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;QACxE,UAAU,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,iBAAC;AAAD,CAAC,AAlCD,CAAgC,KAAK,GAkCpC","sourcesContent":["// Internal Imports\nimport { Chart } from \"../chart\";\nimport * as Configuration from \"../configuration\";\nimport {\n\tChartConfig,\n\tRadarChartOptions\n} from \"../interfaces/index\";\nimport { Tools } from \"../tools\";\n\n// Components\nimport {\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tLegend,\n\tLayoutComponent,\n\tTooltipRadar\n} from \"../components/index\";\nimport { Radar } from \"../components/graphs/radar\";\n\nexport class RadarChart extends Chart {\n\t// TODO - Optimize the use of \"extending\"\n\tconstructor(holder: Element, chartConfigs: ChartConfig<RadarChartOptions>, extending = false) {\n\t\tsuper(holder, chartConfigs);\n\n\t\t// TODO - Optimize the use of \"extending\"\n\t\tif (extending) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Merge the default options for this chart\n\t\t// With the user provided options\n\t\tthis.model.setOptions(\n\t\t\tTools.mergeDefaultChartOptions(\n\t\t\t\tConfiguration.options.radarChart,\n\t\t\t\tchartConfigs.options\n\t\t\t)\n\t\t);\n\n\t\t// Initialize data, services, components etc.\n\t\tthis.init(holder, chartConfigs);\n\t}\n\n\tgetComponents() {\n\t\t// Specify what to render inside the graph-frame\n\t\tconst graphFrameComponents = [\n\t\t\tnew Radar(this.model, this.services)\n\t\t];\n\n\t\t// get the base chart components and export with tooltip\n\t\tconst components: any[] = this.getChartComponents(graphFrameComponents);\n\t\tcomponents.push(new TooltipRadar(this.model, this.services));\n\t\treturn components;\n\t}\n}\n"]}
|
package/charts/scatter.js
CHANGED
|
@@ -16,7 +16,7 @@ import { AxisChart } from "../axis-chart";
|
|
|
16
16
|
import * as Configuration from "../configuration";
|
|
17
17
|
import { Tools } from "../tools";
|
|
18
18
|
// Components
|
|
19
|
-
import { Grid, Scatter, TwoDimensionalAxes, TooltipScatter } from "../components/index";
|
|
19
|
+
import { Grid, Ruler, Scatter, TwoDimensionalAxes, TooltipScatter } from "../components/index";
|
|
20
20
|
var ScatterChart = /** @class */ (function (_super) {
|
|
21
21
|
__extends(ScatterChart, _super);
|
|
22
22
|
function ScatterChart(holder, chartConfigs) {
|
|
@@ -33,6 +33,7 @@ var ScatterChart = /** @class */ (function (_super) {
|
|
|
33
33
|
var graphFrameComponents = [
|
|
34
34
|
new TwoDimensionalAxes(this.model, this.services),
|
|
35
35
|
new Grid(this.model, this.services),
|
|
36
|
+
new Ruler(this.model, this.services),
|
|
36
37
|
new Scatter(this.model, this.services)
|
|
37
38
|
];
|
|
38
39
|
var components = this.getAxisChartComponents(graphFrameComponents);
|
package/charts/scatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scatter.js","sourceRoot":"","sources":["scatter.ts"],"names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AO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;SACtC,CAAC;QAEF,IAAM,UAAU,GAAU,IAAI,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,CAAC;QAC5E,UAAU,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC/D,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,mBAAC;AAAD,CAAC,AA9BD,CAAkC,SAAS,GA8B1C","sourcesContent":["// Internal Imports\nimport { AxisChart } from \"../axis-chart\";\nimport * as Configuration from \"../configuration\";\nimport {\n\tChartConfig,\n\tScatterChartOptions\n} from \"../interfaces/index\";\nimport { Tools } from \"../tools\";\n\n// Components\nimport {\n\tGrid,\n\tRuler,\n\tScatter,\n\tTwoDimensionalAxes,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tTooltip,\n\tLegend,\n\tLayoutComponent,\n\tTooltipScatter\n} from \"../components/index\";\n\nexport class ScatterChart extends AxisChart {\n\tconstructor(holder: Element, chartConfigs: ChartConfig<ScatterChartOptions>) {\n\t\tsuper(holder, chartConfigs);\n\n\t\t// Merge the default options for this chart\n\t\t// With the user provided options\n\t\tthis.model.setOptions(\n\t\t\tTools.mergeDefaultChartOptions(\n\t\t\t\tConfiguration.options.scatterChart,\n\t\t\t\tchartConfigs.options\n\t\t\t)\n\t\t);\n\n\t\t// Initialize data, services, components etc.\n\t\tthis.init(holder, chartConfigs);\n\t}\n\n\tgetComponents() {\n\t\t// Specify what to render inside the graph-frame\n\t\tconst graphFrameComponents = [\n\t\t\tnew TwoDimensionalAxes(this.model, this.services),\n\t\t\tnew Grid(this.model, this.services),\n\t\t\tnew Ruler(this.model, this.services),\n\t\t\tnew Scatter(this.model, this.services)\n\t\t];\n\n\t\tconst components: any[] = this.getAxisChartComponents(graphFrameComponents);\n\t\tcomponents.push(new TooltipScatter(this.model, this.services));\n\t\treturn components;\n\t}\n}\n"]}
|
|
@@ -15,10 +15,6 @@ export declare class Grid extends Component {
|
|
|
15
15
|
* @param position mouse positon
|
|
16
16
|
*/
|
|
17
17
|
getActiveGridline(position: any): any;
|
|
18
|
-
/**
|
|
19
|
-
* Adds the listener on the X grid to trigger multiple point tooltips along the x axis.
|
|
20
|
-
*/
|
|
21
|
-
addGridEventListeners(): void;
|
|
22
18
|
drawBackdrop(): void;
|
|
23
19
|
cleanGrid(g: any): void;
|
|
24
20
|
}
|
package/components/axes/grid.js
CHANGED
|
@@ -17,8 +17,6 @@ import { Tools } from "../../tools";
|
|
|
17
17
|
import { DOMUtils } from "../../services";
|
|
18
18
|
// D3 Imports
|
|
19
19
|
import { axisBottom, axisLeft } from "d3-axis";
|
|
20
|
-
import { mouse, select } from "d3-selection";
|
|
21
|
-
import { TooltipTypes, Events } from "../../interfaces";
|
|
22
20
|
var Grid = /** @class */ (function (_super) {
|
|
23
21
|
__extends(Grid, _super);
|
|
24
22
|
function Grid() {
|
|
@@ -33,9 +31,6 @@ var Grid = /** @class */ (function (_super) {
|
|
|
33
31
|
DOMUtils.appendOrSelect(this.backdrop, "g.y.grid");
|
|
34
32
|
this.drawXGrid();
|
|
35
33
|
this.drawYGrid();
|
|
36
|
-
if (Tools.getProperty(this.model.getOptions(), "tooltip", "gridline", "enabled")) {
|
|
37
|
-
this.addGridEventListeners();
|
|
38
|
-
}
|
|
39
34
|
};
|
|
40
35
|
Grid.prototype.drawXGrid = function () {
|
|
41
36
|
var svg = this.parent;
|
|
@@ -132,40 +127,6 @@ var Grid = /** @class */ (function (_super) {
|
|
|
132
127
|
});
|
|
133
128
|
return xGridlines;
|
|
134
129
|
};
|
|
135
|
-
/**
|
|
136
|
-
* Adds the listener on the X grid to trigger multiple point tooltips along the x axis.
|
|
137
|
-
*/
|
|
138
|
-
Grid.prototype.addGridEventListeners = function () {
|
|
139
|
-
var self = this;
|
|
140
|
-
var svg = this.parent;
|
|
141
|
-
var grid = DOMUtils.appendOrSelect(svg, "rect.chart-grid-backdrop");
|
|
142
|
-
grid.on("mousemove mouseover", function () {
|
|
143
|
-
var chartContainer = self.services.domUtils.getMainSVG();
|
|
144
|
-
var pos = mouse(chartContainer);
|
|
145
|
-
var hoveredElement = select(this);
|
|
146
|
-
// remove the styling on the lines
|
|
147
|
-
var allgridlines = svg.selectAll(".x.grid .tick");
|
|
148
|
-
allgridlines.classed("active", false);
|
|
149
|
-
var activeGridline = self.getActiveGridline(pos);
|
|
150
|
-
if (activeGridline.empty()) {
|
|
151
|
-
return self.services.events.dispatchEvent(Events.Tooltip.HIDE);
|
|
152
|
-
}
|
|
153
|
-
// set active class to control dasharray and theme colors
|
|
154
|
-
activeGridline.classed("active", true);
|
|
155
|
-
// get the items that should be highlighted
|
|
156
|
-
var itemsToHighlight = self.services.cartesianScales.getDataFromDomain(activeGridline.datum());
|
|
157
|
-
self.services.events.dispatchEvent(Events.Tooltip.SHOW, {
|
|
158
|
-
hoveredElement: hoveredElement,
|
|
159
|
-
multidata: itemsToHighlight,
|
|
160
|
-
type: TooltipTypes.GRIDLINE
|
|
161
|
-
});
|
|
162
|
-
})
|
|
163
|
-
.on("mouseout", function () {
|
|
164
|
-
svg.selectAll(".x.grid .tick")
|
|
165
|
-
.classed("active", false);
|
|
166
|
-
self.services.events.dispatchEvent(Events.Tooltip.HIDE);
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
130
|
Grid.prototype.drawBackdrop = function () {
|
|
170
131
|
var svg = this.parent;
|
|
171
132
|
var mainXScale = this.services.cartesianScales.getMainXScale();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","sourceRoot":"","sources":["grid.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1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AC,CAAC;IAC1B,CAAC;IAED,wBAAS,GAAT,UAAU,CAAC;QACV,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACxC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;aACjB,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAE3C,wBAAwB;QACxB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IACF,WAAC;AAAD,CAAC,AAhND,CAA0B,SAAS,GAgNlC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { Tools } from \"../../tools\";\nimport { DOMUtils } from \"../../services\";\n\n// D3 Imports\nimport { axisBottom, axisLeft } from \"d3-axis\";\nimport { mouse, select } from \"d3-selection\";\nimport { TooltipTypes, Events } from \"../../interfaces\";\n\nexport class Grid extends Component {\n\ttype = \"grid\";\n\n\tbackdrop: any;\n\n\trender() {\n\t\t// Draw the backdrop\n\t\tthis.drawBackdrop();\n\t\tDOMUtils.appendOrSelect(this.backdrop, \"g.x.grid\");\n\t\tDOMUtils.appendOrSelect(this.backdrop, \"g.y.grid\");\n\n\t\tthis.drawXGrid();\n\t\tthis.drawYGrid();\n\n\t\tif (Tools.getProperty(this.model.getOptions(), \"tooltip\", \"gridline\", \"enabled\")) {\n\t\t\tthis.addGridEventListeners();\n\t\t}\n\t}\n\n\tdrawXGrid() {\n\t\tconst svg = this.parent;\n\n\t\tconst height = this.backdrop.attr(\"height\");\n\n\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\tconst xGrid = axisBottom(mainXScale)\n\t\t\t.tickSizeInner(-height)\n\t\t\t.tickSizeOuter(0);\n\n\t\t// Determine number of ticks\n\t\tconst numberOfTicks = Tools.getProperty(this.model.getOptions(), \"grid\", \"x\", \"numberOfTicks\");\n\t\txGrid.ticks(numberOfTicks);\n\n\t\tconst g = svg.select(\".x.grid\")\n\t\t\t.attr(\"transform\", `translate(${-this.backdrop.attr(\"x\")}, ${height})`)\n\t\t\t.call(xGrid);\n\n\t\tthis.cleanGrid(g);\n\t}\n\n\tdrawYGrid() {\n\t\tconst svg = this.parent;\n\t\tconst width = this.backdrop.attr(\"width\");\n\n\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\t\tconst yGrid = axisLeft(mainYScale)\n\t\t\t.tickSizeInner(-width)\n\t\t\t.tickSizeOuter(0);\n\n\t\t// Determine number of ticks\n\t\tconst numberOfTicks = Tools.getProperty(this.model.getOptions(), \"grid\", \"y\", \"numberOfTicks\");\n\t\tyGrid.ticks(numberOfTicks);\n\n\t\tconst g = svg.select(\".y.grid\")\n\t\t\t.attr(\"transform\", `translate(0, ${-this.backdrop.attr(\"y\")})`)\n\t\t\t.call(yGrid);\n\n\t\tthis.cleanGrid(g);\n\t}\n\n\t/**\n\t * Returns the threshold for the gridline tooltips based on the mouse location.\n\t * Calculated based on the mouse position between the two closest gridlines or edges of chart.\n\t */\n\tgetGridlineThreshold(mousePos) {\n\t\t// use the space between axis grid ticks to adjust the threshold for the tooltips\n\t\tconst svg = this.parent;\n\n\t\t// sort in ascending x translation value order\n\t\tconst gridlinesX = svg.selectAll(\".x.grid .tick\").nodes()\n\t\t.sort((a, b) => {\n\t\t\treturn Number(Tools.getTranslationValues(a).tx) - Number(Tools.getTranslationValues(b).tx);\n\t\t});\n\n\t\t// find the 2 gridlines on either side of the mouse\n\t\tlet floor = -1; let ceiling;\n\t\tgridlinesX.forEach((line: HTMLElement, i: any) => {\n\t\t\tif (mousePos[0] >= +Tools.getTranslationValues(line).tx) {\n\t\t\t\tfloor ++;\n\t\t\t}\n\t\t});\n\t\tceiling = (floor + 1 < gridlinesX.length) ? floor + 1 : gridlinesX.length;\n\n\t\t// get the 'step' between chart gridlines\n\t\tconst line1 = gridlinesX[floor];\n\t\tconst line2 = gridlinesX[ceiling];\n\t\tlet lineSpacing;\n\n\t\t// if the mouse is on edge of charts (mouseX < first gridline || mouseX > last gridline)\n\t\t// we can use the chart edge to determind the threshold for the gridlines\n\t\tif (!line1) {\n\t\t\t// we are between the first gridline and the chart edge\n\t\t\tlineSpacing = +Tools.getTranslationValues(line2).tx;\n\t\t} else if (!line2) {\n\t\t\t// we need to use the chart right bounds in case there isnt a domain axis\n\t\t\tconst gridElement = svg.select(\"rect.chart-grid-backdrop\").node();\n\t\t\tconst width = DOMUtils.getSVGElementSize(gridElement).width;\n\n\t\t\tlineSpacing = width - +Tools.getTranslationValues(line1).tx;\n\t\t} else {\n\t\t\t// there are two gridlines to use\n\t\t\tlineSpacing = +Tools.getTranslationValues(line2).tx - +Tools.getTranslationValues(line1).tx;\n\t\t}\n\t\tconst { threshold } = this.model.getOptions().tooltip.gridline;\n\t\t// return the threshold\n\t\treturn lineSpacing * threshold;\n\t}\n\n\t/**\n\t * Returns the active gridlines based on the gridline threshold and mouse position.\n\t * @param position mouse positon\n\t */\n\tgetActiveGridline(position) {\n\t\tconst userSpecifiedThreshold = Tools.getProperty(this.model.getOptions, \"tooltip\", \"gridline\", \"threshold\");\n\t\tconst threshold = userSpecifiedThreshold ? userSpecifiedThreshold : this.getGridlineThreshold(position);\n\t\tconst svg = this.parent;\n\n\t\tconst xGridlines = svg.selectAll(\".x.grid .tick\")\n\t\t.filter(function() {\n\t\t\tconst translations = Tools.getTranslationValues(this);\n\n\t\t\t// threshold for when to display a gridline tooltip\n\t\t\tconst bounds = {\n\t\t\t\tmin: Number(translations.tx) - threshold,\n\t\t\t\tmax: Number(translations.tx) + threshold\n\t\t\t};\n\n\t\t\treturn bounds.min <= position[0] && position[0] <= bounds.max;\n\t\t});\n\n\t\treturn xGridlines;\n\t}\n\n\t/**\n\t * Adds the listener on the X grid to trigger multiple point tooltips along the x axis.\n\t */\n\taddGridEventListeners() {\n\t\tconst self = this;\n\t\tconst svg = this.parent;\n\t\tconst grid = DOMUtils.appendOrSelect(svg, \"rect.chart-grid-backdrop\");\n\n\t\tgrid.on(\"mousemove mouseover\", function() {\n\t\t\tconst chartContainer = self.services.domUtils.getMainSVG();\n\t\t\tconst pos = mouse(chartContainer);\n\t\t\tconst hoveredElement = select(this);\n\n\t\t\t// remove the styling on the lines\n\t\t\tconst allgridlines = svg.selectAll(\".x.grid .tick\");\n\t\t\tallgridlines.classed(\"active\", false);\n\n\t\t\tconst activeGridline = self.getActiveGridline(pos);\n\t\t\tif (activeGridline.empty()) {\n\t\t\t\treturn self.services.events.dispatchEvent(Events.Tooltip.HIDE);\n\t\t\t}\n\n\t\t\t// set active class to control dasharray and theme colors\n\t\t\tactiveGridline.classed(\"active\", true);\n\n\t\t\t// get the items that should be highlighted\n\t\t\tconst itemsToHighlight = self.services.cartesianScales.getDataFromDomain(activeGridline.datum());\n\n\t\t\tself.services.events.dispatchEvent(Events.Tooltip.SHOW, {\n\t\t\t\thoveredElement,\n\t\t\t\tmultidata: itemsToHighlight,\n\t\t\t\ttype: TooltipTypes.GRIDLINE\n\t\t\t});\n\t\t})\n\t\t.on(\"mouseout\", function() {\n\t\t\tsvg.selectAll(\".x.grid .tick\")\n\t\t\t\t.classed(\"active\", false);\n\n\t\t\tself.services.events.dispatchEvent(Events.Tooltip.HIDE);\n\t\t});\n\t}\n\n\tdrawBackdrop() {\n\t\tconst svg = this.parent;\n\n\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tconst [yScaleEnd, yScaleStart] = mainYScale.range();\n\n\t\t// Get height from the grid\n\t\tthis.backdrop = DOMUtils.appendOrSelect(svg, \"svg.chart-grid-backdrop\");\n\t\tconst backdropRect = DOMUtils.appendOrSelect(this.backdrop, \"rect.chart-grid-backdrop\");\n\n\t\tthis.backdrop.merge(backdropRect)\n\t\t\t.attr(\"x\", xScaleStart)\n\t\t\t.attr(\"y\", yScaleStart)\n\t\t\t.attr(\"width\", xScaleEnd - xScaleStart)\n\t\t\t.attr(\"height\", yScaleEnd - yScaleStart)\n\t\t\t.lower();\n\n\t\tbackdropRect.attr(\"width\", \"100%\")\n\t\t\t.attr(\"height\", \"100%\");\n\t}\n\n\tcleanGrid(g) {\n\t\tconst options = this.model.getOptions();\n\t\tg.selectAll(\"line\")\n\t\t\t.attr(\"stroke\", options.grid.strokeColor);\n\n\t\t// Remove extra elements\n\t\tg.selectAll(\"text\").remove();\n\t\tg.select(\".domain\").remove();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["grid.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI/C;IAA0B,wBAAS;IAAnC;QAAA,qEAkKC;QAjKA,UAAI,GAAG,MAAM,CAAC;;IAiKf,CAAC;IA7JA,qBAAM,GAAN;QACC,oBAAoB;QACpB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACnD,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAEnD,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;IAED,wBAAS,GAAT;QACC,IAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QAExB,IAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE5C,IA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IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;aAChC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,wBAAS,GAAT,UAAU,CAAC;QACV,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACxC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;aACjB,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAE3C,wBAAwB;QACxB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IACF,WAAC;AAAD,CAAC,AAlKD,CAA0B,SAAS,GAkKlC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { Tools } from \"../../tools\";\nimport { DOMUtils } from \"../../services\";\n\n// D3 Imports\nimport { axisBottom, axisLeft } from \"d3-axis\";\nimport { mouse, select } from \"d3-selection\";\nimport { TooltipTypes, Events } from \"../../interfaces\";\n\nexport class Grid extends Component {\n\ttype = \"grid\";\n\n\tbackdrop: any;\n\n\trender() {\n\t\t// Draw the backdrop\n\t\tthis.drawBackdrop();\n\t\tDOMUtils.appendOrSelect(this.backdrop, \"g.x.grid\");\n\t\tDOMUtils.appendOrSelect(this.backdrop, \"g.y.grid\");\n\n\t\tthis.drawXGrid();\n\t\tthis.drawYGrid();\n\t}\n\n\tdrawXGrid() {\n\t\tconst svg = this.parent;\n\n\t\tconst height = this.backdrop.attr(\"height\");\n\n\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\tconst xGrid = axisBottom(mainXScale)\n\t\t\t.tickSizeInner(-height)\n\t\t\t.tickSizeOuter(0);\n\n\t\t// Determine number of ticks\n\t\tconst numberOfTicks = Tools.getProperty(this.model.getOptions(), \"grid\", \"x\", \"numberOfTicks\");\n\t\txGrid.ticks(numberOfTicks);\n\n\t\tconst g = svg.select(\".x.grid\")\n\t\t\t.attr(\"transform\", `translate(${-this.backdrop.attr(\"x\")}, ${height})`)\n\t\t\t.call(xGrid);\n\n\t\tthis.cleanGrid(g);\n\t}\n\n\tdrawYGrid() {\n\t\tconst svg = this.parent;\n\t\tconst width = this.backdrop.attr(\"width\");\n\n\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\t\tconst yGrid = axisLeft(mainYScale)\n\t\t\t.tickSizeInner(-width)\n\t\t\t.tickSizeOuter(0);\n\n\t\t// Determine number of ticks\n\t\tconst numberOfTicks = Tools.getProperty(this.model.getOptions(), \"grid\", \"y\", \"numberOfTicks\");\n\t\tyGrid.ticks(numberOfTicks);\n\n\t\tconst g = svg.select(\".y.grid\")\n\t\t\t.attr(\"transform\", `translate(0, ${-this.backdrop.attr(\"y\")})`)\n\t\t\t.call(yGrid);\n\n\t\tthis.cleanGrid(g);\n\t}\n\n\t/**\n\t * Returns the threshold for the gridline tooltips based on the mouse location.\n\t * Calculated based on the mouse position between the two closest gridlines or edges of chart.\n\t */\n\tgetGridlineThreshold(mousePos) {\n\t\t// use the space between axis grid ticks to adjust the threshold for the tooltips\n\t\tconst svg = this.parent;\n\n\t\t// sort in ascending x translation value order\n\t\tconst gridlinesX = svg.selectAll(\".x.grid .tick\").nodes()\n\t\t.sort((a, b) => {\n\t\t\treturn Number(Tools.getTranslationValues(a).tx) - Number(Tools.getTranslationValues(b).tx);\n\t\t});\n\n\t\t// find the 2 gridlines on either side of the mouse\n\t\tlet floor = -1; let ceiling;\n\t\tgridlinesX.forEach((line: HTMLElement, i: any) => {\n\t\t\tif (mousePos[0] >= +Tools.getTranslationValues(line).tx) {\n\t\t\t\tfloor ++;\n\t\t\t}\n\t\t});\n\t\tceiling = (floor + 1 < gridlinesX.length) ? floor + 1 : gridlinesX.length;\n\n\t\t// get the 'step' between chart gridlines\n\t\tconst line1 = gridlinesX[floor];\n\t\tconst line2 = gridlinesX[ceiling];\n\t\tlet lineSpacing;\n\n\t\t// if the mouse is on edge of charts (mouseX < first gridline || mouseX > last gridline)\n\t\t// we can use the chart edge to determind the threshold for the gridlines\n\t\tif (!line1) {\n\t\t\t// we are between the first gridline and the chart edge\n\t\t\tlineSpacing = +Tools.getTranslationValues(line2).tx;\n\t\t} else if (!line2) {\n\t\t\t// we need to use the chart right bounds in case there isnt a domain axis\n\t\t\tconst gridElement = svg.select(\"rect.chart-grid-backdrop\").node();\n\t\t\tconst width = DOMUtils.getSVGElementSize(gridElement).width;\n\n\t\t\tlineSpacing = width - +Tools.getTranslationValues(line1).tx;\n\t\t} else {\n\t\t\t// there are two gridlines to use\n\t\t\tlineSpacing = +Tools.getTranslationValues(line2).tx - +Tools.getTranslationValues(line1).tx;\n\t\t}\n\t\tconst { threshold } = this.model.getOptions().tooltip.gridline;\n\t\t// return the threshold\n\t\treturn lineSpacing * threshold;\n\t}\n\n\t/**\n\t * Returns the active gridlines based on the gridline threshold and mouse position.\n\t * @param position mouse positon\n\t */\n\tgetActiveGridline(position) {\n\t\tconst userSpecifiedThreshold = Tools.getProperty(this.model.getOptions, \"tooltip\", \"gridline\", \"threshold\");\n\t\tconst threshold = userSpecifiedThreshold ? userSpecifiedThreshold : this.getGridlineThreshold(position);\n\t\tconst svg = this.parent;\n\n\t\tconst xGridlines = svg.selectAll(\".x.grid .tick\")\n\t\t.filter(function() {\n\t\t\tconst translations = Tools.getTranslationValues(this);\n\n\t\t\t// threshold for when to display a gridline tooltip\n\t\t\tconst bounds = {\n\t\t\t\tmin: Number(translations.tx) - threshold,\n\t\t\t\tmax: Number(translations.tx) + threshold\n\t\t\t};\n\n\t\t\treturn bounds.min <= position[0] && position[0] <= bounds.max;\n\t\t});\n\n\t\treturn xGridlines;\n\t}\n\n\tdrawBackdrop() {\n\t\tconst svg = this.parent;\n\n\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tconst [yScaleEnd, yScaleStart] = mainYScale.range();\n\n\t\t// Get height from the grid\n\t\tthis.backdrop = DOMUtils.appendOrSelect(svg, \"svg.chart-grid-backdrop\");\n\t\tconst backdropRect = DOMUtils.appendOrSelect(this.backdrop, \"rect.chart-grid-backdrop\");\n\n\t\tthis.backdrop.merge(backdropRect)\n\t\t\t.attr(\"x\", xScaleStart)\n\t\t\t.attr(\"y\", yScaleStart)\n\t\t\t.attr(\"width\", xScaleEnd - xScaleStart)\n\t\t\t.attr(\"height\", yScaleEnd - yScaleStart)\n\t\t\t.lower();\n\n\t\tbackdropRect.attr(\"width\", \"100%\")\n\t\t\t.attr(\"height\", \"100%\");\n\t}\n\n\tcleanGrid(g) {\n\t\tconst options = this.model.getOptions();\n\t\tg.selectAll(\"line\")\n\t\t\t.attr(\"stroke\", options.grid.strokeColor);\n\n\t\t// Remove extra elements\n\t\tg.selectAll(\"text\").remove();\n\t\tg.select(\".domain\").remove();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Component } from "../component";
|
|
2
|
+
import { Selection } from "d3-selection";
|
|
3
|
+
declare type GenericSvgSelection = Selection<SVGElement, any, SVGElement, any>;
|
|
4
|
+
export declare class Ruler extends Component {
|
|
5
|
+
type: string;
|
|
6
|
+
backdrop: GenericSvgSelection;
|
|
7
|
+
elementsToHighlight: GenericSvgSelection;
|
|
8
|
+
render(): void;
|
|
9
|
+
showRuler([x, y]: [number, number]): void;
|
|
10
|
+
hideRuler(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Adds the listener on the X grid to trigger multiple point tooltips along the x axis.
|
|
13
|
+
*/
|
|
14
|
+
addBackdropEventListeners(): void;
|
|
15
|
+
drawBackdrop(): void;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
// Internal Imports
|
|
15
|
+
import { Component } from "../component";
|
|
16
|
+
import { DOMUtils } from "../../services";
|
|
17
|
+
import { TooltipTypes, CartesianOrientations } from "../../interfaces";
|
|
18
|
+
import { Tools } from "../../tools";
|
|
19
|
+
// D3 Imports
|
|
20
|
+
import { mouse } from "d3-selection";
|
|
21
|
+
var THRESHOLD = 5;
|
|
22
|
+
/** check if x is inside threshold area extents */
|
|
23
|
+
function pointIsWithinThreshold(dx, x) {
|
|
24
|
+
return dx > x - THRESHOLD && dx < x + THRESHOLD;
|
|
25
|
+
}
|
|
26
|
+
var Ruler = /** @class */ (function (_super) {
|
|
27
|
+
__extends(Ruler, _super);
|
|
28
|
+
function Ruler() {
|
|
29
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
30
|
+
_this.type = "ruler";
|
|
31
|
+
return _this;
|
|
32
|
+
}
|
|
33
|
+
Ruler.prototype.render = function () {
|
|
34
|
+
this.drawBackdrop();
|
|
35
|
+
this.addBackdropEventListeners();
|
|
36
|
+
};
|
|
37
|
+
Ruler.prototype.showRuler = function (_a) {
|
|
38
|
+
var _this = this;
|
|
39
|
+
var x = _a[0], y = _a[1];
|
|
40
|
+
var svg = this.parent;
|
|
41
|
+
var orientation = this.services.cartesianScales.getOrientation();
|
|
42
|
+
var mouseCoordinate = orientation === CartesianOrientations.HORIZONTAL ? y : x;
|
|
43
|
+
var ruler = DOMUtils.appendOrSelect(svg, "g.ruler");
|
|
44
|
+
var rulerLine = DOMUtils.appendOrSelect(ruler, "line.ruler-line");
|
|
45
|
+
var dataPointElements = svg.selectAll("[role=graphics-symbol]");
|
|
46
|
+
var displayData = this.model.getDisplayData();
|
|
47
|
+
var rangeScale = this.services.cartesianScales.getRangeScale();
|
|
48
|
+
var _b = rangeScale.range(), yScaleEnd = _b[0], yScaleStart = _b[1];
|
|
49
|
+
var scaledData = displayData.map(function (d) { return ({
|
|
50
|
+
domainValue: _this.services.cartesianScales.getDomainValue(d),
|
|
51
|
+
originalData: d
|
|
52
|
+
}); });
|
|
53
|
+
/**
|
|
54
|
+
* Find matches, reduce is used instead of filter
|
|
55
|
+
* to only get elements which belong to the same axis coordinate
|
|
56
|
+
*/
|
|
57
|
+
var dataPointsMatchingRulerLine = scaledData
|
|
58
|
+
.filter(function (d) { return pointIsWithinThreshold(d.domainValue, mouseCoordinate); })
|
|
59
|
+
.reduce(function (accum, currentValue) {
|
|
60
|
+
if (accum.length === 0) {
|
|
61
|
+
accum.push(currentValue);
|
|
62
|
+
return accum;
|
|
63
|
+
}
|
|
64
|
+
// store the first element of the accumulator array to compare it with current element being processed
|
|
65
|
+
var sampleAccumValue = accum[0].domainValue;
|
|
66
|
+
var distanceToCurrentValue = Math.abs(mouseCoordinate - currentValue.domainValue);
|
|
67
|
+
var distanceToAccumValue = Math.abs(mouseCoordinate - sampleAccumValue);
|
|
68
|
+
if (distanceToCurrentValue > distanceToAccumValue) {
|
|
69
|
+
// if distance with current value is bigger than already existing value in the accumulator, skip current iteration
|
|
70
|
+
return accum;
|
|
71
|
+
}
|
|
72
|
+
else if (distanceToCurrentValue < distanceToAccumValue) {
|
|
73
|
+
// currentValue data point is closer to mouse inside the threshold area, so reinstantiate array
|
|
74
|
+
accum = [currentValue];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// currentValue is equal to already stored values, which means there's another match on the same coordinate
|
|
78
|
+
accum.push(currentValue);
|
|
79
|
+
}
|
|
80
|
+
return accum;
|
|
81
|
+
}, []);
|
|
82
|
+
// some data point match
|
|
83
|
+
if (dataPointsMatchingRulerLine.length > 0) {
|
|
84
|
+
var rangeIdentifier_1 = this.services.cartesianScales.getRangeIdentifier();
|
|
85
|
+
var tooltipData = dataPointsMatchingRulerLine
|
|
86
|
+
.map(function (d) { return d.originalData; })
|
|
87
|
+
.filter(function (d) {
|
|
88
|
+
var value = d[rangeIdentifier_1];
|
|
89
|
+
return value !== null && value !== undefined;
|
|
90
|
+
});
|
|
91
|
+
// get elements on which we should trigger mouse events
|
|
92
|
+
var domainValuesMatchingRulerLine_1 = dataPointsMatchingRulerLine.map(function (d) { return d.domainValue; });
|
|
93
|
+
var elementsToHighlight = dataPointElements.filter(function (d) {
|
|
94
|
+
var domainValue = _this.services.cartesianScales.getDomainValue(d);
|
|
95
|
+
return domainValuesMatchingRulerLine_1.includes(domainValue);
|
|
96
|
+
});
|
|
97
|
+
/** if we pass from a trigger area to another one
|
|
98
|
+
* mouseout on previous elements won't get dispatched
|
|
99
|
+
* so we need to do it manually
|
|
100
|
+
*/
|
|
101
|
+
if (this.elementsToHighlight &&
|
|
102
|
+
this.elementsToHighlight.size() > 0 &&
|
|
103
|
+
!Tools.isEqual(this.elementsToHighlight, elementsToHighlight)) {
|
|
104
|
+
this.hideRuler();
|
|
105
|
+
}
|
|
106
|
+
elementsToHighlight.dispatch("mouseover");
|
|
107
|
+
// set current hovered elements
|
|
108
|
+
this.elementsToHighlight = elementsToHighlight;
|
|
109
|
+
this.services.events.dispatchEvent("show-tooltip", {
|
|
110
|
+
hoveredElement: rulerLine,
|
|
111
|
+
multidata: tooltipData,
|
|
112
|
+
type: TooltipTypes.GRIDLINE
|
|
113
|
+
});
|
|
114
|
+
ruler.attr("opacity", 1);
|
|
115
|
+
// line snaps to matching point
|
|
116
|
+
var sampleMatch = dataPointsMatchingRulerLine[0];
|
|
117
|
+
if (orientation === "horizontal") {
|
|
118
|
+
rulerLine.attr("x1", yScaleStart)
|
|
119
|
+
.attr("x2", yScaleEnd)
|
|
120
|
+
.attr("y1", sampleMatch.domainValue)
|
|
121
|
+
.attr("y2", sampleMatch.domainValue);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
rulerLine.attr("y1", yScaleStart)
|
|
125
|
+
.attr("y2", yScaleEnd)
|
|
126
|
+
.attr("x1", sampleMatch.domainValue)
|
|
127
|
+
.attr("x2", sampleMatch.domainValue);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.hideRuler();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
Ruler.prototype.hideRuler = function () {
|
|
135
|
+
var svg = this.parent;
|
|
136
|
+
var ruler = DOMUtils.appendOrSelect(svg, "g.ruler");
|
|
137
|
+
var dataPointElements = svg.selectAll("[role=graphics-symbol]");
|
|
138
|
+
dataPointElements.dispatch("mouseout");
|
|
139
|
+
this.services.events.dispatchEvent("hide-tooltip");
|
|
140
|
+
ruler.attr("opacity", 0);
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Adds the listener on the X grid to trigger multiple point tooltips along the x axis.
|
|
144
|
+
*/
|
|
145
|
+
Ruler.prototype.addBackdropEventListeners = function () {
|
|
146
|
+
var self = this;
|
|
147
|
+
this.backdrop
|
|
148
|
+
.on("mousemove mouseover", function () {
|
|
149
|
+
var pos = mouse(self.parent.node());
|
|
150
|
+
self.showRuler(pos);
|
|
151
|
+
})
|
|
152
|
+
.on("mouseout", function () {
|
|
153
|
+
self.hideRuler();
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
Ruler.prototype.drawBackdrop = function () {
|
|
157
|
+
var svg = this.parent;
|
|
158
|
+
var mainXScale = this.services.cartesianScales.getMainXScale();
|
|
159
|
+
var mainYScale = this.services.cartesianScales.getMainYScale();
|
|
160
|
+
var _a = mainXScale.range(), xScaleStart = _a[0], xScaleEnd = _a[1];
|
|
161
|
+
var _b = mainYScale.range(), yScaleEnd = _b[0], yScaleStart = _b[1];
|
|
162
|
+
// Get height from the grid
|
|
163
|
+
this.backdrop = DOMUtils.appendOrSelect(svg, "svg.chart-grid-backdrop");
|
|
164
|
+
var backdropRect = DOMUtils.appendOrSelect(this.backdrop, "rect.chart-grid-backdrop");
|
|
165
|
+
this.backdrop.merge(backdropRect)
|
|
166
|
+
.attr("x", xScaleStart)
|
|
167
|
+
.attr("y", yScaleStart)
|
|
168
|
+
.attr("width", xScaleEnd - xScaleStart)
|
|
169
|
+
.attr("height", yScaleEnd - yScaleStart)
|
|
170
|
+
.lower();
|
|
171
|
+
backdropRect.attr("width", "100%")
|
|
172
|
+
.attr("height", "100%");
|
|
173
|
+
};
|
|
174
|
+
return Ruler;
|
|
175
|
+
}(Component));
|
|
176
|
+
export { Ruler };
|
|
177
|
+
//# sourceMappingURL=../../../src/components/axes/ruler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruler.js","sourceRoot":"","sources":["ruler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,aAAa;AACb,OAAO,EAAE,KAAK,EAAa,MAAM,cAAc,CAAC;AAIhD,IAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,mDAAmD;AACnD,SAAS,sBAAsB,CAAC,EAAU,EAAE,CAAS;IACpD,OAAO,EAAE,GAAG,CAAC,GAAG,SAAS,IAAI,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;AACjD,CAAC;AAED;IAA2B,yBAAS;IAApC;QAAA,qEA0KC;QAzKA,UAAI,GAAG,OAAO,CAAC;;IAyKhB,CAAC;IArKA,s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AAE,CAAC;QACjE,IAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC;QAE3D,IAAA,uBAA6C,EAA5C,mBAAW,EAAE,iBAA+B,CAAC;QAC9C,IAAA,uBAA6C,EAA5C,iBAAS,EAAE,mBAAiC,CAAC;QAEpD,2BAA2B;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,yBAAyB,CAAC,CAAC;QACxE,IAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;QAExF,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC;aAC/B,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;aACtB,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;aACtB,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,WAAW,CAAC;aACtC,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,WAAW,CAAC;aACvC,KAAK,EAAE,CAAC;QAEV,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;aAChC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC;IACF,YAAC;AAAD,CAAC,AA1KD,CAA2B,SAAS,GA0KnC","sourcesContent":["// Internal Imports\nimport { Component } from \"../component\";\nimport { DOMUtils } from \"../../services\";\nimport { TooltipTypes, CartesianOrientations } from \"../../interfaces\";\nimport { Tools } from \"../../tools\";\n\n// D3 Imports\nimport { mouse, Selection } from \"d3-selection\";\n\ntype GenericSvgSelection = Selection<SVGElement, any, SVGElement, any>;\n\nconst THRESHOLD = 5;\n\n/** check if x is inside threshold area extents */\nfunction pointIsWithinThreshold(dx: number, x: number) {\n\treturn dx > x - THRESHOLD && dx < x + THRESHOLD;\n}\n\nexport class Ruler extends Component {\n\ttype = \"ruler\";\n\tbackdrop: GenericSvgSelection;\n\telementsToHighlight: GenericSvgSelection;\n\n\trender() {\n\t\tthis.drawBackdrop();\n\t\tthis.addBackdropEventListeners();\n\t}\n\n\tshowRuler([x, y]: [number, number]) {\n\t\tconst svg = this.parent;\n\t\tconst orientation: CartesianOrientations = this.services.cartesianScales.getOrientation();\n\t\tconst mouseCoordinate = orientation === CartesianOrientations.HORIZONTAL ? y : x;\n\t\tconst ruler = DOMUtils.appendOrSelect(svg, \"g.ruler\");\n\t\tconst rulerLine = DOMUtils.appendOrSelect(ruler, \"line.ruler-line\");\n\t\tconst dataPointElements: GenericSvgSelection = svg.selectAll(\n\t\t\t\"[role=graphics-symbol]\"\n\t\t);\n\t\tconst displayData = this.model.getDisplayData();\n\t\tconst rangeScale = this.services.cartesianScales.getRangeScale();\n\t\tconst [yScaleEnd, yScaleStart] = rangeScale.range();\n\t\tconst scaledData: {domainValue: number, originalData: any}[] = displayData.map(d => ({\n\t\t\tdomainValue: this.services.cartesianScales.getDomainValue(d),\n\t\t\toriginalData: d\n\t\t}));\n\n\t\t/**\n\t\t * Find matches, reduce is used instead of filter\n\t\t * to only get elements which belong to the same axis coordinate\n\t\t */\n\t\tconst dataPointsMatchingRulerLine: {domainValue: number, originalData: any}[] =\n\t\t\tscaledData\n\t\t\t.filter(d => pointIsWithinThreshold(d.domainValue, mouseCoordinate))\n\t\t\t.reduce((accum, currentValue) => {\n\t\t\t\tif (accum.length === 0) {\n\t\t\t\t\taccum.push(currentValue);\n\t\t\t\t\treturn accum;\n\t\t\t\t}\n\n\t\t\t\t// store the first element of the accumulator array to compare it with current element being processed\n\t\t\t\tconst sampleAccumValue = accum[0].domainValue;\n\n\t\t\t\tconst distanceToCurrentValue = Math.abs(mouseCoordinate - currentValue.domainValue);\n\t\t\t\tconst distanceToAccumValue = Math.abs(mouseCoordinate - sampleAccumValue);\n\n\t\t\t\tif (distanceToCurrentValue > distanceToAccumValue) {\n\t\t\t\t\t// if distance with current value is bigger than already existing value in the accumulator, skip current iteration\n\t\t\t\t\treturn accum;\n\t\t\t\t} else if (distanceToCurrentValue < distanceToAccumValue) {\n\t\t\t\t\t// currentValue data point is closer to mouse inside the threshold area, so reinstantiate array\n\t\t\t\t\taccum = [currentValue];\n\t\t\t\t} else {\n\t\t\t\t\t// currentValue is equal to already stored values, which means there's another match on the same coordinate\n\t\t\t\t\taccum.push(currentValue);\n\t\t\t\t}\n\n\t\t\t\treturn accum;\n\t\t\t}, []);\n\n\t\t// some data point match\n\t\tif (dataPointsMatchingRulerLine.length > 0) {\n\t\t\tconst rangeIdentifier = this.services.cartesianScales.getRangeIdentifier();\n\t\t\tconst tooltipData = dataPointsMatchingRulerLine\n\t\t\t\t.map(d => d.originalData)\n\t\t\t\t.filter(d => {\n\t\t\t\t\tconst value = d[rangeIdentifier];\n\t\t\t\t\treturn value !== null && value !== undefined;\n\t\t\t\t});\n\n\t\t\t// get elements on which we should trigger mouse events\n\t\t\tconst domainValuesMatchingRulerLine = dataPointsMatchingRulerLine.map(d => d.domainValue);\n\t\t\tconst elementsToHighlight = dataPointElements.filter(d => {\n\t\t\t\tconst domainValue = this.services.cartesianScales.getDomainValue(d);\n\t\t\t\treturn domainValuesMatchingRulerLine.includes(domainValue);\n\t\t\t});\n\n\t\t\t/** if we pass from a trigger area to another one\n\t\t\t * mouseout on previous elements won't get dispatched\n\t\t\t * so we need to do it manually\n\t\t\t */\n\t\t\tif (\n\t\t\t\tthis.elementsToHighlight &&\n\t\t\t\tthis.elementsToHighlight.size() > 0 &&\n\t\t\t\t!Tools.isEqual(this.elementsToHighlight, elementsToHighlight)\n\t\t\t) {\n\t\t\t\tthis.hideRuler();\n\t\t\t}\n\n\t\t\telementsToHighlight.dispatch(\"mouseover\");\n\n\t\t\t// set current hovered elements\n\t\t\tthis.elementsToHighlight = elementsToHighlight;\n\n\t\t\tthis.services.events.dispatchEvent(\"show-tooltip\", {\n\t\t\t\thoveredElement: rulerLine,\n\t\t\t\tmultidata: tooltipData,\n\t\t\t\ttype: TooltipTypes.GRIDLINE\n\t\t\t});\n\n\t\t\truler.attr(\"opacity\", 1);\n\n\t\t\t// line snaps to matching point\n\t\t\tconst sampleMatch = dataPointsMatchingRulerLine[0];\n\t\t\tif (orientation === \"horizontal\") {\n\t\t\t\trulerLine.attr(\"x1\", yScaleStart)\n\t\t\t\t\t.attr(\"x2\", yScaleEnd)\n\t\t\t\t\t.attr(\"y1\", sampleMatch.domainValue)\n\t\t\t\t\t.attr(\"y2\", sampleMatch.domainValue);\n\t\t\t} else {\n\t\t\t\trulerLine.attr(\"y1\", yScaleStart)\n\t\t\t\t\t.attr(\"y2\", yScaleEnd)\n\t\t\t\t\t.attr(\"x1\", sampleMatch.domainValue)\n\t\t\t\t\t.attr(\"x2\", sampleMatch.domainValue);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.hideRuler();\n\t\t}\n\t}\n\n\thideRuler() {\n\t\tconst svg = this.parent;\n\t\tconst ruler = DOMUtils.appendOrSelect(svg, \"g.ruler\");\n\t\tconst dataPointElements = svg.selectAll(\"[role=graphics-symbol]\");\n\n\t\tdataPointElements.dispatch(\"mouseout\");\n\t\tthis.services.events.dispatchEvent(\"hide-tooltip\");\n\t\truler.attr(\"opacity\", 0);\n\t}\n\n\t/**\n\t * Adds the listener on the X grid to trigger multiple point tooltips along the x axis.\n\t */\n\taddBackdropEventListeners() {\n\t\tconst self = this;\n\n\t\tthis.backdrop\n\t\t\t.on(\"mousemove mouseover\", function() {\n\t\t\t\tconst pos = mouse(self.parent.node());\n\n\t\t\t\tself.showRuler(pos);\n\t\t\t})\n\t\t\t.on(\"mouseout\", function() {\n\t\t\t\tself.hideRuler();\n\t\t\t});\n\t}\n\n\tdrawBackdrop() {\n\t\tconst svg = this.parent;\n\n\t\tconst mainXScale = this.services.cartesianScales.getMainXScale();\n\t\tconst mainYScale = this.services.cartesianScales.getMainYScale();\n\n\t\tconst [xScaleStart, xScaleEnd] = mainXScale.range();\n\t\tconst [yScaleEnd, yScaleStart] = mainYScale.range();\n\n\t\t// Get height from the grid\n\t\tthis.backdrop = DOMUtils.appendOrSelect(svg, \"svg.chart-grid-backdrop\");\n\t\tconst backdropRect = DOMUtils.appendOrSelect(this.backdrop, \"rect.chart-grid-backdrop\");\n\n\t\tthis.backdrop.merge(backdropRect)\n\t\t\t.attr(\"x\", xScaleStart)\n\t\t\t.attr(\"y\", yScaleStart)\n\t\t\t.attr(\"width\", xScaleEnd - xScaleStart)\n\t\t\t.attr(\"height\", yScaleEnd - yScaleStart)\n\t\t\t.lower();\n\n\t\tbackdropRect.attr(\"width\", \"100%\")\n\t\t\t.attr(\"height\", \"100%\");\n\t}\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
import { Tooltip } from "./tooltip";
|
|
15
|
+
import { Tools } from "../../tools";
|
|
16
|
+
var TooltipRadar = /** @class */ (function (_super) {
|
|
17
|
+
__extends(TooltipRadar, _super);
|
|
18
|
+
function TooltipRadar() {
|
|
19
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
20
|
+
}
|
|
21
|
+
TooltipRadar.prototype.getMultilineTooltipHTML = function (data) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
var options = this.model.getOptions();
|
|
24
|
+
var groupMapsTo = options.data.groupMapsTo;
|
|
25
|
+
var _a = options.radar.axes, angle = _a.angle, value = _a.value;
|
|
26
|
+
// sort them so they are in the same order as the graph
|
|
27
|
+
data.sort(function (a, b) { return b[value] - a[value]; });
|
|
28
|
+
return "<ul class='multi-tooltip'>" +
|
|
29
|
+
data.map(function (datum) {
|
|
30
|
+
var userProvidedValueFormatter = Tools.getProperty(options, "tooltip", "valueFormatter");
|
|
31
|
+
var formattedValue = userProvidedValueFormatter
|
|
32
|
+
? userProvidedValueFormatter(datum[value])
|
|
33
|
+
: datum[value];
|
|
34
|
+
// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.
|
|
35
|
+
var indicatorColor = _this.model.getStrokeColor(datum[groupMapsTo]);
|
|
36
|
+
return "\n\t\t\t\t<li>\n\t\t\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t\t\t<a style=\"background-color:" + indicatorColor + "\" class=\"tooltip-color\"></a>\n\t\t\t\t\t\t<p class=\"label\">" + datum[groupMapsTo] + "</p>\n\t\t\t\t\t\t<p class=\"value\">" + formattedValue + "</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>";
|
|
37
|
+
}).join("") + "</ul>";
|
|
38
|
+
};
|
|
39
|
+
return TooltipRadar;
|
|
40
|
+
}(Tooltip));
|
|
41
|
+
export { TooltipRadar };
|
|
42
|
+
//# sourceMappingURL=../../../src/components/essentials/tooltip-radar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip-radar.js","sourceRoot":"","sources":["tooltip-radar.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC;IAAkC,gCAAO;IAAzC;;IA6BA,CAAC;IA5BA,8CAAuB,GAAvB,UAAwB,IAAS;QAAjC,iBA2BC;QA1BA,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QAChC,IAAA,sCAAW,CAAkB;QAC/B,IAAA,uBAAqC,EAAnC,gBAAK,EAAE,gBAA4B,CAAC;QAE5C,uDAAuD;QACvD,IAAI,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAnB,CAAmB,CAAC,CAAC;QAEzC,OAAQ,4BAA4B;YACnC,IAAI,CAAC,GAAG,CAAC,UAAA,KAAK;gBACb,IAAM,0BAA0B,GAAG,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;gBAC3F,IAAM,cAAc,GAAG,0BAA0B;oBAChD,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBAC1C,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAEhB,2GAA2G;gBAC3G,IAAM,cAAc,GAAG,KAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;gBAErE,OAAO,0GAGwB,cAAc,wEACxB,KAAK,CAAC,WAAW,CAAC,6CAClB,cAAc,0CAE7B,CAAC;YACR,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;IACxB,CAAC;IACF,mBAAC;AAAD,CAAC,AA7BD,CAAkC,OAAO,GA6BxC","sourcesContent":["import { Tooltip } from \"./tooltip\";\nimport { Tools } from \"../../tools\";\n\nexport class TooltipRadar extends Tooltip {\n\tgetMultilineTooltipHTML(data: any) {\n\t\tconst options = this.model.getOptions();\n\t\tconst { groupMapsTo } = options.data;\n\t\tconst { angle, value } = options.radar.axes;\n\n\t\t// sort them so they are in the same order as the graph\n\t\tdata.sort((a, b) => b[value] - a[value]);\n\n\t\treturn \"<ul class='multi-tooltip'>\" +\n\t\t\tdata.map(datum => {\n\t\t\t\tconst userProvidedValueFormatter = Tools.getProperty(options, \"tooltip\", \"valueFormatter\");\n\t\t\t\tconst formattedValue = userProvidedValueFormatter\n\t\t\t\t\t? userProvidedValueFormatter(datum[value])\n\t\t\t\t\t: datum[value];\n\n\t\t\t\t// For the tooltip color, we always want the normal stroke color, not dynamically determined by data value.\n\t\t\t\tconst indicatorColor = this.model.getStrokeColor(datum[groupMapsTo]);\n\n\t\t\t\treturn `\n\t\t\t\t<li>\n\t\t\t\t\t<div class=\"datapoint-tooltip\">\n\t\t\t\t\t\t<a style=\"background-color:${indicatorColor}\" class=\"tooltip-color\"></a>\n\t\t\t\t\t\t<p class=\"label\">${datum[groupMapsTo]}</p>\n\t\t\t\t\t\t<p class=\"value\">${formattedValue}</p>\n\t\t\t\t\t</div>\n\t\t\t\t</li>`;\n\t\t\t}).join(\"\") + \"</ul>\";\n\t}\n}\n"]}
|
|
@@ -14,6 +14,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
// Internal Imports
|
|
15
15
|
import { Scatter } from "./scatter";
|
|
16
16
|
import { DOMUtils } from "../../services";
|
|
17
|
+
import { Roles } from "../../interfaces";
|
|
17
18
|
import { extent } from "d3-array";
|
|
18
19
|
import { scaleLinear } from "d3-scale";
|
|
19
20
|
var Bubble = /** @class */ (function (_super) {
|
|
@@ -47,6 +48,7 @@ var Bubble = /** @class */ (function (_super) {
|
|
|
47
48
|
var domainIdentifier = this.services.cartesianScales.getDomainIdentifier();
|
|
48
49
|
selection.raise()
|
|
49
50
|
.classed("dot", true)
|
|
51
|
+
.attr("role", Roles.GRAPHICS_SYMBOL)
|
|
50
52
|
.attr("cx", function (d, i) { return _this.services.cartesianScales.getDomainValue(d, i); })
|
|
51
53
|
.transition(this.services.transitions.getTransition("bubble-update-enter", animate))
|
|
52
54
|
.attr("cy", function (d, i) { return _this.services.cartesianScales.getRangeValue(d, i); })
|