mdt-charts 1.9.7 → 1.9.11

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.
Files changed (150) hide show
  1. package/README.md +190 -190
  2. package/dist/index.html +363 -48
  3. package/dist/listeners.89e1e272264c0e680de8.js +278 -0
  4. package/dist/main.f8b6bc6fee33cef1116c.js +228 -0
  5. package/dist/src_engine_engine_ts.ccee2a280374e0083541.js +759 -0
  6. package/dist/vendors-node_modules_chroma-js_chroma_js-node_modules_d3-array_src_max_js-node_modules_d3-arr-c3fc24.b32acc465b8557229277.js +1869 -0
  7. package/package.json +57 -57
  8. package/dist/bundle.js +0 -2
  9. package/dist/bundle.js.LICENSE.txt +0 -56
  10. package/lib/config/config.d.ts +0 -146
  11. package/lib/config/config.js +0 -1
  12. package/lib/designer/designerConfig.d.ts +0 -71
  13. package/lib/designer/designerConfig.js +0 -1
  14. package/lib/engine/block/block.d.ts +0 -35
  15. package/lib/engine/block/block.js +0 -110
  16. package/lib/engine/block/blockHelper.d.ts +0 -12
  17. package/lib/engine/block/blockHelper.js +0 -19
  18. package/lib/engine/contentManager.d.ts +0 -9
  19. package/lib/engine/contentManager.js +0 -29
  20. package/lib/engine/elementHighlighter/elementHighlighter.d.ts +0 -30
  21. package/lib/engine/elementHighlighter/elementHighlighter.js +0 -197
  22. package/lib/engine/elementHighlighter/selectHighlighter.d.ts +0 -11
  23. package/lib/engine/elementHighlighter/selectHighlighter.js +0 -95
  24. package/lib/engine/engine.d.ts +0 -20
  25. package/lib/engine/engine.js +0 -64
  26. package/lib/engine/features/aggregator/aggregator.d.ts +0 -22
  27. package/lib/engine/features/aggregator/aggregator.js +0 -95
  28. package/lib/engine/features/axis/axis.d.ts +0 -12
  29. package/lib/engine/features/axis/axis.js +0 -118
  30. package/lib/engine/features/axis/axisDomHelper.d.ts +0 -7
  31. package/lib/engine/features/axis/axisDomHelper.js +0 -24
  32. package/lib/engine/features/axis/axisHelper.d.ts +0 -9
  33. package/lib/engine/features/axis/axisHelper.js +0 -53
  34. package/lib/engine/features/axis/axisLabelDomHelper.d.ts +0 -17
  35. package/lib/engine/features/axis/axisLabelDomHelper.js +0 -143
  36. package/lib/engine/features/axis/axisLabelsEventManager.d.ts +0 -6
  37. package/lib/engine/features/axis/axisLabelsEventManager.js +0 -36
  38. package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +0 -23
  39. package/lib/engine/features/embeddedLabels/embeddedLabels.js +0 -147
  40. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +0 -8
  41. package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +0 -30
  42. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +0 -27
  43. package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +0 -65
  44. package/lib/engine/features/gridLine/gidLineHelper.d.ts +0 -13
  45. package/lib/engine/features/gridLine/gidLineHelper.js +0 -30
  46. package/lib/engine/features/gridLine/gridLine.d.ts +0 -11
  47. package/lib/engine/features/gridLine/gridLine.js +0 -67
  48. package/lib/engine/features/legend/legend.d.ts +0 -22
  49. package/lib/engine/features/legend/legend.js +0 -109
  50. package/lib/engine/features/legend/legendDomHelper.d.ts +0 -8
  51. package/lib/engine/features/legend/legendDomHelper.js +0 -48
  52. package/lib/engine/features/legend/legendEventsManager.d.ts +0 -12
  53. package/lib/engine/features/legend/legendEventsManager.js +0 -47
  54. package/lib/engine/features/legend/legendHelper.d.ts +0 -21
  55. package/lib/engine/features/legend/legendHelper.js +0 -97
  56. package/lib/engine/features/markDots/markDot.d.ts +0 -20
  57. package/lib/engine/features/markDots/markDot.js +0 -68
  58. package/lib/engine/features/markDots/markDotsHelper.d.ts +0 -6
  59. package/lib/engine/features/markDots/markDotsHelper.js +0 -16
  60. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
  61. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
  62. package/lib/engine/features/scale/scale.d.ts +0 -16
  63. package/lib/engine/features/scale/scale.js +0 -74
  64. package/lib/engine/features/tipBox/tipBox.d.ts +0 -11
  65. package/lib/engine/features/tipBox/tipBox.js +0 -32
  66. package/lib/engine/features/tipBox/tipBoxHelper.d.ts +0 -16
  67. package/lib/engine/features/tipBox/tipBoxHelper.js +0 -48
  68. package/lib/engine/features/title/title.d.ts +0 -9
  69. package/lib/engine/features/title/title.js +0 -35
  70. package/lib/engine/features/tolltip/tooltip.d.ts +0 -19
  71. package/lib/engine/features/tolltip/tooltip.js +0 -180
  72. package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +0 -17
  73. package/lib/engine/features/tolltip/tooltipComponentsManager.js +0 -127
  74. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +0 -36
  75. package/lib/engine/features/tolltip/tooltipDomHelper.js +0 -114
  76. package/lib/engine/features/tolltip/tooltipHelper.d.ts +0 -16
  77. package/lib/engine/features/tolltip/tooltipHelper.js +0 -99
  78. package/lib/engine/filterManager/filterEventManager.d.ts +0 -33
  79. package/lib/engine/filterManager/filterEventManager.js +0 -127
  80. package/lib/engine/helpers/domHelper.d.ts +0 -30
  81. package/lib/engine/helpers/domHelper.js +0 -68
  82. package/lib/engine/helpers/helper.d.ts +0 -30
  83. package/lib/engine/helpers/helper.js +0 -89
  84. package/lib/engine/helpers/namesHelper.d.ts +0 -5
  85. package/lib/engine/helpers/namesHelper.js +0 -9
  86. package/lib/engine/intervalNotation/gantt.d.ts +0 -10
  87. package/lib/engine/intervalNotation/gantt.js +0 -62
  88. package/lib/engine/intervalNotation/intervalManager.d.ts +0 -7
  89. package/lib/engine/intervalNotation/intervalManager.js +0 -30
  90. package/lib/engine/polarNotation/donut/DonutHelper.d.ts +0 -15
  91. package/lib/engine/polarNotation/donut/DonutHelper.js +0 -58
  92. package/lib/engine/polarNotation/donut/donut.d.ts +0 -32
  93. package/lib/engine/polarNotation/donut/donut.js +0 -124
  94. package/lib/engine/polarNotation/polarManager.d.ts +0 -10
  95. package/lib/engine/polarNotation/polarManager.js +0 -55
  96. package/lib/engine/transitionManager.d.ts +0 -19
  97. package/lib/engine/transitionManager.js +0 -64
  98. package/lib/engine/twoDimensionalNotation/area/area.d.ts +0 -17
  99. package/lib/engine/twoDimensionalNotation/area/area.js +0 -131
  100. package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +0 -9
  101. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +0 -40
  102. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +0 -34
  103. package/lib/engine/twoDimensionalNotation/bar/bar.js +0 -216
  104. package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +0 -24
  105. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +0 -103
  106. package/lib/engine/twoDimensionalNotation/line/line.d.ts +0 -17
  107. package/lib/engine/twoDimensionalNotation/line/line.js +0 -132
  108. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +0 -8
  109. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +0 -28
  110. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +0 -11
  111. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +0 -101
  112. package/lib/engine/valueFormatter.d.ts +0 -6
  113. package/lib/engine/valueFormatter.js +0 -8
  114. package/lib/main.d.ts +0 -79
  115. package/lib/main.js +0 -85
  116. package/lib/model/chartStyleModel.d.ts +0 -16
  117. package/lib/model/chartStyleModel.js +0 -67
  118. package/lib/model/dataManagerModel.d.ts +0 -22
  119. package/lib/model/dataManagerModel.js +0 -137
  120. package/lib/model/featuresModel/axisModel.d.ts +0 -18
  121. package/lib/model/featuresModel/axisModel.js +0 -111
  122. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +0 -7
  123. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +0 -86
  124. package/lib/model/featuresModel/legendModel/legendModel.d.ts +0 -13
  125. package/lib/model/featuresModel/legendModel/legendModel.js +0 -78
  126. package/lib/model/featuresModel/otherComponents.d.ts +0 -6
  127. package/lib/model/featuresModel/otherComponents.js +0 -12
  128. package/lib/model/featuresModel/scaleModel.d.ts +0 -17
  129. package/lib/model/featuresModel/scaleModel.js +0 -100
  130. package/lib/model/featuresModel/titleModel.d.ts +0 -4
  131. package/lib/model/featuresModel/titleModel.js +0 -14
  132. package/lib/model/featuresModel/tooltipModel.d.ts +0 -4
  133. package/lib/model/featuresModel/tooltipModel.js +0 -7
  134. package/lib/model/marginModel.d.ts +0 -19
  135. package/lib/model/marginModel.js +0 -126
  136. package/lib/model/model.d.ts +0 -220
  137. package/lib/model/model.js +0 -1
  138. package/lib/model/modelBuilder.d.ts +0 -16
  139. package/lib/model/modelBuilder.js +0 -128
  140. package/lib/model/modelHelper.d.ts +0 -7
  141. package/lib/model/modelHelper.js +0 -41
  142. package/lib/model/notations/intervalModel.d.ts +0 -8
  143. package/lib/model/notations/intervalModel.js +0 -93
  144. package/lib/model/notations/polarModel.d.ts +0 -7
  145. package/lib/model/notations/polarModel.js +0 -27
  146. package/lib/model/notations/twoDimensionalModel.d.ts +0 -19
  147. package/lib/model/notations/twoDimensionalModel.js +0 -85
  148. package/lib/style/charts-main.css +0 -240
  149. package/lib/style/charts-main.less +0 -240
  150. package/test.html +0 -196
@@ -1,132 +0,0 @@
1
- import { stack } from 'd3-shape';
2
- import { select } from 'd3-selection';
3
- import { MarkDot } from "../../features/markDots/markDot";
4
- import { LineHelper } from './lineHelper';
5
- import { DomHelper } from '../../helpers/domHelper';
6
- import { Helper } from '../../helpers/helper';
7
- export class Line {
8
- static render(block, scales, data, keyField, margin, keyAxisOrient, chart) {
9
- if (chart.isSegmented)
10
- this.renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart);
11
- else
12
- this.renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart);
13
- }
14
- static update(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
15
- let promises;
16
- if (chart.isSegmented) {
17
- promises = this.updateSegmeneted(block, scales, newData, keyField, margin, keyAxisOrient, chart);
18
- }
19
- else {
20
- promises = this.updateGrouped(block, scales, newData, keyField, margin, keyAxisOrient, chart);
21
- }
22
- return promises;
23
- }
24
- static updateColors(block, chart) {
25
- chart.data.valueFields.forEach((_vf, valueIndex) => {
26
- const path = block.getChartGroup(chart.index)
27
- .select(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueIndex}`);
28
- DomHelper.setChartStyle(path, chart.style, valueIndex, 'stroke');
29
- MarkDot.updateColors(block, chart, valueIndex);
30
- });
31
- }
32
- static renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart) {
33
- chart.data.valueFields.forEach((valueField, valueIndex) => {
34
- const lineGenerator = LineHelper.getLineGenerator(keyAxisOrient, scales, keyField.name, valueField.name, margin);
35
- const path = block.getChartGroup(chart.index)
36
- .append('path')
37
- .attr('d', lineGenerator(data))
38
- .attr('class', this.lineChartClass)
39
- .style('fill', 'none')
40
- .style('clip-path', `url(#${block.getClipPathId()})`)
41
- .style('pointer-events', 'none');
42
- DomHelper.setCssClasses(path, Helper.getCssClassesWithElementIndex(chart.cssClasses, valueIndex));
43
- DomHelper.setChartStyle(path, chart.style, valueIndex, 'stroke');
44
- MarkDot.render(block, data, keyAxisOrient, scales, margin, keyField.name, valueIndex, valueField.name, chart);
45
- });
46
- }
47
- static renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart) {
48
- const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(data);
49
- const lineGenerator = LineHelper.getSegmentedLineGenerator(keyAxisOrient, scales, keyField.name, margin);
50
- const lines = block.getChartGroup(chart.index)
51
- .selectAll(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
52
- .data(stackedData)
53
- .enter()
54
- .append('path')
55
- .attr('d', d => lineGenerator(d))
56
- .attr('class', this.lineChartClass)
57
- .style('fill', 'none')
58
- .style('clip-path', `url(#${block.getClipPathId()})`)
59
- .style('pointer-events', 'none');
60
- lines.each(function (d, i) {
61
- DomHelper.setCssClasses(select(this), Helper.getCssClassesWithElementIndex(chart.cssClasses, i));
62
- });
63
- this.setSegmentColor(lines, chart.style.elementColors);
64
- stackedData.forEach((dataset, stackIndex) => {
65
- MarkDot.render(block, dataset, keyAxisOrient, scales, margin, keyField.name, stackIndex, '1', chart);
66
- });
67
- }
68
- static updateGrouped(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
69
- const promises = [];
70
- chart.data.valueFields.forEach((valueField, valueFieldIndex) => {
71
- const lineGenerator = LineHelper.getLineGenerator(keyAxisOrient, scales, keyField.name, valueField.name, margin);
72
- const lineObject = block.getChartGroup(chart.index)
73
- .select(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueFieldIndex}`);
74
- const prom = this.updateGroupedPath(block, lineObject, lineGenerator, newData);
75
- promises.push(prom);
76
- MarkDot.update(block, newData, keyAxisOrient, scales, margin, keyField.name, valueFieldIndex, valueField.name, chart);
77
- });
78
- return promises;
79
- }
80
- static updateSegmeneted(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
81
- const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(newData);
82
- const lineGenerator = LineHelper.getSegmentedLineGenerator(keyAxisOrient, scales, keyField.name, margin);
83
- const lines = block.getChartGroup(chart.index)
84
- .selectAll(`path.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
85
- .data(stackedData);
86
- const prom = this.updateSegmentedPath(block, lines, lineGenerator);
87
- lines.each((dataset, index) => {
88
- MarkDot.update(block, dataset, keyAxisOrient, scales, margin, keyField.name, index, '1', chart);
89
- });
90
- return [prom];
91
- }
92
- static updateGroupedPath(block, lineObject, lineGenerator, newData) {
93
- return new Promise(resolve => {
94
- if (lineObject.size() === 0) {
95
- resolve('');
96
- return;
97
- }
98
- let lineHandler = lineObject;
99
- if (block.transitionManager.durations.chartUpdate > 0)
100
- lineHandler = lineHandler.interrupt()
101
- .transition()
102
- .duration(block.transitionManager.durations.chartUpdate)
103
- .on('end', () => resolve(''));
104
- lineHandler
105
- .attr('d', lineGenerator(newData));
106
- if (block.transitionManager.durations.chartUpdate <= 0)
107
- resolve('');
108
- });
109
- }
110
- static updateSegmentedPath(block, linesObjects, lineGenerator) {
111
- return new Promise(resolve => {
112
- if (linesObjects.size() === 0) {
113
- resolve('');
114
- return;
115
- }
116
- let linesHandler = linesObjects;
117
- if (block.transitionManager.durations.chartUpdate > 0)
118
- linesHandler = linesHandler.interrupt()
119
- .transition()
120
- .duration(block.transitionManager.durations.chartUpdate)
121
- .on('end', () => resolve(''));
122
- linesHandler
123
- .attr('d', d => lineGenerator(d));
124
- if (block.transitionManager.durations.chartUpdate <= 0)
125
- resolve('');
126
- });
127
- }
128
- static setSegmentColor(segments, colorPalette) {
129
- segments.style('stroke', (d, i) => colorPalette[i % colorPalette.length]);
130
- }
131
- }
132
- Line.lineChartClass = 'line';
@@ -1,8 +0,0 @@
1
- import { Line as ILine } from 'd3-shape';
2
- import { MdtChartsDataRow } from '../../../config/config';
3
- import { Orient, BlockMargin } from "../../../model/model";
4
- import { Scales } from "../../features/scale/scale";
5
- export declare class LineHelper {
6
- static getLineGenerator(keyAxisOrient: Orient, scales: Scales, keyFieldName: string, valueFieldName: string, margin: BlockMargin): ILine<MdtChartsDataRow>;
7
- static getSegmentedLineGenerator(keyAxisOrient: Orient, scales: Scales, keyFieldName: string, margin: BlockMargin): ILine<MdtChartsDataRow>;
8
- }
@@ -1,28 +0,0 @@
1
- import { line } from 'd3-shape';
2
- import { Scale } from "../../features/scale/scale";
3
- export class LineHelper {
4
- static getLineGenerator(keyAxisOrient, scales, keyFieldName, valueFieldName, margin) {
5
- if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top') {
6
- return line()
7
- .x(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.left)
8
- .y(d => scales.value(d[valueFieldName]) + margin.top);
9
- }
10
- if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
11
- return line()
12
- .x(d => scales.value(d[valueFieldName]) + margin.left)
13
- .y(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.top);
14
- }
15
- }
16
- static getSegmentedLineGenerator(keyAxisOrient, scales, keyFieldName, margin) {
17
- if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top') {
18
- return line()
19
- .x(d => Scale.getScaledValue(scales.key, d.data[keyFieldName]) + margin.left)
20
- .y(d => scales.value(d[1]) + margin.top);
21
- }
22
- if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
23
- return line()
24
- .x(d => scales.value(d[1]) + margin.left)
25
- .y(d => Scale.getScaledValue(scales.key, d.data[keyFieldName]) + margin.top);
26
- }
27
- }
28
- }
@@ -1,11 +0,0 @@
1
- import { MdtChartsDataSource } from "../../config/config";
2
- import { Model } from "../../model/model";
3
- import { Block } from "../block/block";
4
- import Engine from "../engine";
5
- export declare class TwoDimensionalManager {
6
- static render(engine: Engine, model: Model): void;
7
- static updateData(block: Block, model: Model, data: MdtChartsDataSource): void;
8
- static updateColors(block: Block, model: Model): void;
9
- private static renderCharts;
10
- private static updateCharts;
11
- }
@@ -1,101 +0,0 @@
1
- import { ElementHighlighter } from "../elementHighlighter/elementHighlighter";
2
- import { Axis } from "../features/axis/axis";
3
- import { EmbeddedLabels } from "../features/embeddedLabels/embeddedLabels";
4
- import { GridLine } from "../features/gridLine/gridLine";
5
- import { Legend } from "../features/legend/legend";
6
- import { RecordOverflowAlert } from "../features/recordOverflowAlert/recordOverflowAlert";
7
- import { Scale } from "../features/scale/scale";
8
- import { TipBox } from "../features/tipBox/tipBox";
9
- import { Title } from "../features/title/title";
10
- import { Tooltip } from "../features/tolltip/tooltip";
11
- import { Helper } from "../helpers/helper";
12
- import { Area } from "./area/area";
13
- import { Bar } from "./bar/bar";
14
- import { BarHelper } from "./bar/barHelper";
15
- import { Line } from "./line/line";
16
- export class TwoDimensionalManager {
17
- static render(engine, model) {
18
- const options = model.options;
19
- const scales = Scale.getScales(options.scale.key, options.scale.value, model.chartSettings.bar);
20
- engine.block.scales = scales;
21
- engine.block.renderSvg(model.blockCanvas.size);
22
- Axis.render(engine.block, scales, options.scale, options.axis, model.blockCanvas.size);
23
- GridLine.render(engine.block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, options.scale.key);
24
- this.renderCharts(engine.block, options.charts, scales, engine.data, options.data, model.chartBlock.margin, options.axis.key.orient, model.chartSettings.bar, model.blockCanvas.size);
25
- engine.block.filterEventManager.registerEventFor2D(scales.key, model.chartBlock.margin, model.blockCanvas.size, options);
26
- engine.block.filterEventManager.event2DUpdate(options);
27
- Title.render(engine.block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
28
- Legend.render(engine.block, engine.data, options, model);
29
- Tooltip.render(engine.block, model, engine.data, model.otherComponents.tooltipBlock, scales);
30
- if (model.dataSettings.scope.hidedRecordsAmount !== 0)
31
- RecordOverflowAlert.render(engine.block, model.dataSettings.scope.hidedRecordsAmount, 'top', options.orient);
32
- engine.block.getSvg()
33
- .on('click', (e) => {
34
- if (e.target === engine.block.getSvg().node())
35
- engine.block.filterEventManager.clearKeysFor2D(options);
36
- });
37
- }
38
- static updateData(block, model, data) {
39
- block.transitionManager.interruptTransitions();
40
- block.filterEventManager.updateData(data[model.options.data.dataSource]);
41
- TipBox.clearEvents(block);
42
- Tooltip.hide(block);
43
- const options = model.options;
44
- ElementHighlighter.remove2DChartsFullHighlighting(block, options.charts);
45
- const scales = Scale.getScales(options.scale.key, options.scale.value, model.chartSettings.bar);
46
- const keyDomainEquality = Helper.checkDomainsEquality(block.scales.key.domain(), scales.key.domain());
47
- block.scales = scales;
48
- Axis.update(block, scales, options.scale, options.axis, model.blockCanvas.size, keyDomainEquality);
49
- GridLine.update(block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, options.scale.key);
50
- const promises = this.updateCharts(block, options.charts, scales, data, model.options.data, model.chartBlock.margin, options.axis.key.orient, model.blockCanvas.size, model.chartSettings.bar);
51
- Promise.all(promises)
52
- .then(() => {
53
- block.filterEventManager.event2DUpdate(options);
54
- block.filterEventManager.registerEventFor2D(scales.key, model.chartBlock.margin, model.blockCanvas.size, options);
55
- Tooltip.render(block, model, data, model.otherComponents.tooltipBlock, scales);
56
- });
57
- RecordOverflowAlert.update(block, model.dataSettings.scope.hidedRecordsAmount, 'top', options.orient);
58
- }
59
- static updateColors(block, model) {
60
- Legend.updateColors(block, model.options);
61
- model.options.charts.forEach(chart => {
62
- if (chart.type === 'bar')
63
- Bar.updateColors(block, chart);
64
- else if (chart.type === 'line')
65
- Line.updateColors(block, chart);
66
- else if (chart.type === 'area')
67
- Area.updateColors(block, chart);
68
- });
69
- }
70
- static renderCharts(block, charts, scales, data, dataOptions, margin, keyAxisOrient, barSettings, blockSize) {
71
- block.renderChartClipPath(margin, blockSize);
72
- block.renderChartsBlock();
73
- charts.forEach((chart) => {
74
- if (chart.type === 'bar')
75
- Bar.render(block, scales, data[dataOptions.dataSource], dataOptions.keyField, margin, keyAxisOrient, chart, blockSize, barSettings, BarHelper.getBarsInGroupAmount(charts), chart.isSegmented, charts.findIndex(ch => ch.type === 'bar'));
76
- else if (chart.type === 'line')
77
- Line.render(block, scales, data[dataOptions.dataSource], dataOptions.keyField, margin, keyAxisOrient, chart);
78
- else if (chart.type === 'area')
79
- Area.render(block, scales, data[dataOptions.dataSource], dataOptions.keyField, margin, keyAxisOrient, chart, blockSize);
80
- });
81
- EmbeddedLabels.raiseGroups(block);
82
- }
83
- static updateCharts(block, charts, scales, data, dataOptions, margin, keyAxisOrient, blockSize, barSettings) {
84
- block.updateChartClipPath(margin, blockSize);
85
- let promises = [];
86
- charts.forEach((chart) => {
87
- let proms;
88
- if (chart.type === 'bar') {
89
- proms = Bar.update(block, data[dataOptions.dataSource], scales, margin, keyAxisOrient, chart, blockSize, BarHelper.getBarsInGroupAmount(charts), dataOptions.keyField, charts.findIndex(ch => ch.type === 'bar'), barSettings, chart.isSegmented);
90
- }
91
- else if (chart.type === 'line') {
92
- proms = Line.update(block, scales, data[dataOptions.dataSource], dataOptions.keyField, margin, keyAxisOrient, chart);
93
- }
94
- else if (chart.type === 'area') {
95
- proms = Area.update(block, scales, data[dataOptions.dataSource], dataOptions.keyField, margin, chart, keyAxisOrient, blockSize);
96
- }
97
- promises.push(...proms);
98
- });
99
- return promises;
100
- }
101
- }
@@ -1,6 +0,0 @@
1
- import { Formatter } from '../designer/designerConfig';
2
- export declare class ValueFormatter {
3
- private static format;
4
- static formatField(fieldFormat: string, value: any): string;
5
- static setFormatFunction(formatFunction: Formatter): void;
6
- }
@@ -1,8 +0,0 @@
1
- export class ValueFormatter {
2
- static formatField(fieldFormat, value) {
3
- return this.format(value, { type: fieldFormat });
4
- }
5
- static setFormatFunction(formatFunction) {
6
- this.format = formatFunction;
7
- }
8
- }
package/lib/main.d.ts DELETED
@@ -1,79 +0,0 @@
1
- import { MdtChartsConfig, MdtChartsDataSource, NewSize, Size } from "./config/config";
2
- import { DesignerConfig } from "./designer/designerConfig";
3
- import { FilterCallback } from "./engine/filterManager/filterEventManager";
4
- export interface IChart {
5
- /**
6
- * Рендер графика
7
- * @param parentElement родительский элемент для графика
8
- */
9
- render(parentElement: HTMLElement): void;
10
- /**
11
- * Удаление графика со страницы
12
- */
13
- destroy(): void;
14
- /**
15
- * Обновление графика для новых данных
16
- * @param data Новые данные
17
- */
18
- updateData(data: MdtChartsDataSource): void;
19
- /**
20
- * Изменение размера блока с графиком
21
- * @param newSize Новый размер
22
- */
23
- updateSize(newSize: Size): void;
24
- /**
25
- * Обновление цветов графиков на основе новых базовых цветов
26
- * @param newColors Новые базовые цвета
27
- */
28
- updateColors(newColors: string[]): void;
29
- }
30
- export declare class Chart implements IChart {
31
- static chartCounter: number;
32
- private config;
33
- private designerConfig;
34
- private model;
35
- private data;
36
- private parentElement;
37
- private isResizable;
38
- private engine;
39
- private resizeHandler;
40
- /**
41
- * @param config Объект конфигуратора
42
- * @param designerConfig Объект конфигуратора дизайнера
43
- * @param data Данные
44
- * @param isResizable Флаг подстройки размера блока графика под родительский элемент
45
- * @param filterCallback Функция коллбэк, вызываемая во время клика на элемент графика. Предназначена для обеспечения кросс-фильтрации
46
- * @param selectedIds Id выделенных записей
47
- */
48
- constructor(config: MdtChartsConfig, designerConfig: DesignerConfig, data: MdtChartsDataSource, isResizable?: boolean, filterCallback?: FilterCallback, selectedIds?: number[]);
49
- /**
50
- * Рендер графика
51
- * @param parentElement родительский элемент для графика
52
- */
53
- render(parentElement: HTMLElement): void;
54
- /**
55
- * Удаление графика со страницы
56
- */
57
- destroy(): void;
58
- /**
59
- * Обновление графика для новых данных
60
- * @param data Новые данные
61
- */
62
- updateData(data: MdtChartsDataSource): void;
63
- /**
64
- * Изменение размера блока с графиком
65
- * @param newSize Новый размер
66
- */
67
- updateSize(newSize: Partial<NewSize>): void;
68
- /**
69
- * Обновление цветов графиков на основе новых базовых цветов
70
- * @param newColors Новые базовые цвета
71
- */
72
- updateColors(newColors: string[]): void;
73
- private registerResizeEvent;
74
- private removeResizeEvent;
75
- private resizeListener;
76
- }
77
- export * from "./config/config";
78
- export * from "./designer/designerConfig";
79
- export { FilterCallback } from "./engine/filterManager/filterEventManager";
package/lib/main.js DELETED
@@ -1,85 +0,0 @@
1
- import Engine from "./engine/engine";
2
- import { assembleModel, getPreparedData } from "./model/modelBuilder";
3
- export class Chart {
4
- /**
5
- * @param config Объект конфигуратора
6
- * @param designerConfig Объект конфигуратора дизайнера
7
- * @param data Данные
8
- * @param isResizable Флаг подстройки размера блока графика под родительский элемент
9
- * @param filterCallback Функция коллбэк, вызываемая во время клика на элемент графика. Предназначена для обеспечения кросс-фильтрации
10
- * @param selectedIds Id выделенных записей
11
- */
12
- constructor(config, designerConfig, data, isResizable = false, filterCallback = null, selectedIds = []) {
13
- this.resizeHandler = this.resizeListener.bind(this);
14
- Chart.chartCounter++;
15
- this.config = config;
16
- this.designerConfig = designerConfig;
17
- this.data = data;
18
- this.isResizable = isResizable;
19
- this.model = assembleModel(this.config, this.data, this.designerConfig);
20
- this.engine = new Engine(Chart.chartCounter, filterCallback, selectedIds);
21
- }
22
- /**
23
- * Рендер графика
24
- * @param parentElement родительский элемент для графика
25
- */
26
- render(parentElement) {
27
- this.parentElement = parentElement;
28
- this.engine.render(this.model, getPreparedData(this.model, this.data, this.config), this.parentElement);
29
- if (this.isResizable)
30
- this.registerResizeEvent();
31
- }
32
- /**
33
- * Удаление графика со страницы
34
- */
35
- destroy() {
36
- this.engine.destroy();
37
- if (this.isResizable)
38
- this.removeResizeEvent();
39
- }
40
- /**
41
- * Обновление графика для новых данных
42
- * @param data Новые данные
43
- */
44
- updateData(data) {
45
- this.model = assembleModel(this.config, data, this.designerConfig);
46
- this.data = data;
47
- this.engine.updateData(this.model, getPreparedData(this.model, this.data, this.config));
48
- }
49
- /**
50
- * Изменение размера блока с графиком
51
- * @param newSize Новый размер
52
- */
53
- updateSize(newSize) {
54
- if (newSize.height)
55
- this.config.canvas.size.height = newSize.height;
56
- if (newSize.width)
57
- this.config.canvas.size.width = newSize.width;
58
- this.model = assembleModel(this.config, this.data, this.designerConfig);
59
- this.engine.updateFullBlock(this.model, getPreparedData(this.model, this.data, this.config));
60
- }
61
- /**
62
- * Обновление цветов графиков на основе новых базовых цветов
63
- * @param newColors Новые базовые цвета
64
- */
65
- updateColors(newColors) {
66
- this.designerConfig.chartStyle.baseColors = [...newColors];
67
- this.model = assembleModel(this.config, this.data, this.designerConfig);
68
- this.engine.updateColors(this.model);
69
- }
70
- registerResizeEvent() {
71
- window.addEventListener('resize', this.resizeHandler);
72
- }
73
- removeResizeEvent() {
74
- window.removeEventListener('resize', this.resizeHandler);
75
- }
76
- resizeListener() {
77
- this.updateSize({
78
- height: null,
79
- width: this.parentElement.offsetWidth
80
- });
81
- }
82
- }
83
- Chart.chartCounter = 0;
84
- export * from "./config/config";
85
- export * from "./designer/designerConfig";
@@ -1,16 +0,0 @@
1
- import { TwoDimensionalChartType } from "../config/config";
2
- import { ChartStyleConfig } from "../designer/designerConfig";
3
- import { ChartStyle } from "./model";
4
- export declare class ChartStyleModel {
5
- private static safeColorsAmount;
6
- private static standartColors;
7
- static getCssClasses(chartIndex: number): string[];
8
- static get2DChartStyle(chartsAmount: number, chartType: TwoDimensionalChartType, chartsFieldsAmounts: number[], chartIndex: number, isSegmented: boolean, styleConfig: ChartStyleConfig): ChartStyle;
9
- static getChartStyle(elementsAmount: number, styleConfig: ChartStyleConfig): ChartStyle;
10
- private static getChartColors;
11
- private static getChartOpacity;
12
- private static getColorSet;
13
- private static checkAndGet;
14
- private static getStartIndex;
15
- private static resetColor;
16
- }
@@ -1,67 +0,0 @@
1
- import * as chroma from "chroma-js";
2
- import { ModelHelper } from "./modelHelper";
3
- export class ChartStyleModel {
4
- static getCssClasses(chartIndex) {
5
- const cssClasses = [`chart-${chartIndex}`];
6
- return cssClasses;
7
- }
8
- static get2DChartStyle(chartsAmount, chartType, chartsFieldsAmounts, chartIndex, isSegmented, styleConfig) {
9
- const startIndex = this.getStartIndex(chartIndex, chartsFieldsAmounts);
10
- const baseColors = this.checkAndGet(styleConfig.baseColors);
11
- const palette = this.getColorSet(baseColors, ModelHelper.getSum(chartsFieldsAmounts));
12
- return {
13
- elementColors: this.getChartColors(palette, chartsFieldsAmounts[chartIndex], startIndex, chartType),
14
- opacity: this.getChartOpacity(chartsAmount, chartType, chartsFieldsAmounts[chartIndex], isSegmented)
15
- };
16
- }
17
- static getChartStyle(elementsAmount, styleConfig) {
18
- const baseColors = this.checkAndGet(styleConfig.baseColors);
19
- return {
20
- elementColors: this.getColorSet(baseColors, elementsAmount),
21
- opacity: 1
22
- };
23
- }
24
- static getChartColors(palette, elementsAmount, startIndex, chartType) {
25
- const selectedColors = palette.slice(startIndex, startIndex + elementsAmount);
26
- if (chartType !== 'line')
27
- return selectedColors;
28
- for (let i = 0; i < selectedColors.length; i++) {
29
- selectedColors[i] = chroma.mix(selectedColors[i], 'white', 0.2).saturate(3).hex();
30
- }
31
- return selectedColors;
32
- }
33
- static getChartOpacity(chartsLength, chartType, chartsValueFieldAmount, isSegmented) {
34
- if (chartType === 'area' && (chartsLength > 1 || chartsValueFieldAmount > 1) && !isSegmented)
35
- return 0.5; // combined area with other charts has 0.5 opacity
36
- return 1;
37
- }
38
- static getColorSet(baseColors, elementsAmount) {
39
- return chroma.scale(baseColors)
40
- .mode('rgb')
41
- .domain([0, 0.55, 0.75, 1])
42
- .colors(elementsAmount <= 1 ? 2 : elementsAmount);
43
- }
44
- static checkAndGet(baseColors) {
45
- if (baseColors.length === 0 || baseColors.filter(color => color === 'rgba(0, 0, 0, 0)' || !color).length > 0) {
46
- return this.standartColors;
47
- }
48
- return baseColors;
49
- }
50
- static getStartIndex(chartIndex, chartsFieldsAmounts) {
51
- let startIndex = 0;
52
- for (let i = 0; i < chartIndex; i++) {
53
- startIndex += chartsFieldsAmounts[i];
54
- }
55
- return startIndex;
56
- }
57
- static resetColor(index, baseColor) {
58
- let color = chroma(baseColor)
59
- .luminance(0.5)
60
- .saturate(1.5 + Math.floor(index / this.safeColorsAmount) * 0.5);
61
- color = chroma(color)
62
- .set('hsv.h', chroma(color).get('hsv.h') + Math.floor(index / this.safeColorsAmount) * 4);
63
- return color.hex();
64
- }
65
- }
66
- ChartStyleModel.safeColorsAmount = 8;
67
- ChartStyleModel.standartColors = ["#209DE3", "#FF3131", "#FFBA00", "#20B078"];
@@ -1,22 +0,0 @@
1
- import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
2
- import { DesignerConfig } from "../designer/designerConfig";
3
- import { BlockMargin, DataScope, LegendBlockModel } from "./model";
4
- export declare class DataManagerModel {
5
- static getPreparedData(data: MdtChartsDataSource, allowableKeys: string[], config: MdtChartsConfig): MdtChartsDataSource;
6
- static getDataScope(config: MdtChartsConfig, margin: BlockMargin, data: MdtChartsDataSource, designerConfig: DesignerConfig, legendBlock: LegendBlockModel): DataScope;
7
- static getDataValuesByKeyField(data: MdtChartsDataSource, dataSourceName: string, keyFieldName: string): string[];
8
- private static getDataScopeFor2D;
9
- private static getDataScopeForPolar;
10
- /**
11
- * Выводит количество элементов (преимущественно баров) в одной группе. Группа - один ключ
12
- * @param configOptions
13
- * @param chartsLength
14
- */
15
- private static getElementsInGroupAmount;
16
- private static getBarChartsInGroupAmount;
17
- private static getScopedData;
18
- private static getScopedChartData;
19
- private static setDataType;
20
- private static getTypedData;
21
- private static getDataLimitByItemSize;
22
- }