mdt-charts 1.12.15 → 1.12.18

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 (70) hide show
  1. package/lib/config/config.d.ts +42 -8
  2. package/lib/engine/block/block.d.ts +4 -13
  3. package/lib/engine/block/block.js +12 -61
  4. package/lib/engine/block/blockHtml.d.ts +14 -0
  5. package/lib/engine/block/blockHtml.js +18 -0
  6. package/lib/engine/block/blockSvg.d.ts +26 -0
  7. package/lib/engine/block/blockSvg.js +69 -0
  8. package/lib/engine/cardsNotation/card/card.d.ts +30 -0
  9. package/lib/engine/cardsNotation/card/card.js +97 -0
  10. package/lib/engine/cardsNotation/card/cardChange.d.ts +21 -0
  11. package/lib/engine/cardsNotation/card/cardChange.js +72 -0
  12. package/lib/engine/cardsNotation/card/cardElementsStyler.d.ts +6 -0
  13. package/lib/engine/cardsNotation/card/cardElementsStyler.js +11 -0
  14. package/lib/engine/cardsNotation/card/cardService.d.ts +11 -0
  15. package/lib/engine/cardsNotation/card/cardService.js +12 -0
  16. package/lib/engine/cardsNotation/cardsManager.d.ts +11 -0
  17. package/lib/engine/cardsNotation/cardsManager.js +14 -0
  18. package/lib/engine/contentManager/contentManager.d.ts +6 -4
  19. package/lib/engine/contentManager/contentManager.js +9 -9
  20. package/lib/engine/contentManager/contentManagerFactory.d.ts +1 -1
  21. package/lib/engine/contentManager/contentManagerFactory.js +3 -1
  22. package/lib/engine/engine.d.ts +4 -3
  23. package/lib/engine/engine.js +9 -5
  24. package/lib/engine/features/embeddedLabels/embeddedLabels.js +6 -6
  25. package/lib/engine/features/legend/legend.js +1 -1
  26. package/lib/engine/features/markDots/markDot.js +4 -4
  27. package/lib/engine/features/tolltip/tooltip.d.ts +2 -2
  28. package/lib/engine/features/tolltip/tooltip.js +0 -3
  29. package/lib/engine/features/tolltip/tooltipComponentsManager.js +2 -2
  30. package/lib/engine/helpers/fontResizer/fontResizer.d.ts +16 -0
  31. package/lib/engine/helpers/fontResizer/fontResizer.js +21 -0
  32. package/lib/engine/helpers/fontResizer/fontResizerService.d.ts +6 -0
  33. package/lib/engine/helpers/fontResizer/fontResizerService.js +12 -0
  34. package/lib/engine/helpers/namesHelper.js +1 -1
  35. package/lib/engine/intervalNotation/gantt.js +2 -2
  36. package/lib/engine/intervalNotation/intervalManager.js +2 -4
  37. package/lib/engine/polarNotation/polarManager.d.ts +5 -5
  38. package/lib/engine/polarNotation/polarManager.js +1 -1
  39. package/lib/engine/twoDimensionalNotation/area/area.js +7 -7
  40. package/lib/engine/twoDimensionalNotation/bar/bar.js +11 -11
  41. package/lib/engine/twoDimensionalNotation/line/line.d.ts +1 -1
  42. package/lib/engine/twoDimensionalNotation/line/line.js +9 -9
  43. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +5 -5
  44. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +4 -4
  45. package/lib/main.js +1 -1
  46. package/lib/model/chartStyleModel/chartStyleModel.d.ts +1 -1
  47. package/lib/model/chartStyleModel/chartStyleModel.js +2 -2
  48. package/lib/model/chartStyleModel/colorRange.d.ts +7 -0
  49. package/lib/model/chartStyleModel/colorRange.js +30 -0
  50. package/lib/model/dataManagerModel/dataManagerModel.js +5 -0
  51. package/lib/model/dataManagerModel/notations/cardsDataManagerModel.d.ts +5 -0
  52. package/lib/model/dataManagerModel/notations/cardsDataManagerModel.js +10 -0
  53. package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +2 -1
  54. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +5 -4
  55. package/lib/model/margin/twoDim/twoDimMarginModel.js +1 -1
  56. package/lib/model/model.d.ts +25 -8
  57. package/lib/model/modelBuilder.js +4 -0
  58. package/lib/model/modelInstance/dataModel/dataRepository.d.ts +1 -0
  59. package/lib/model/modelInstance/dataModel/dataRepository.js +3 -0
  60. package/lib/model/notations/cards/cardsChangeService.d.ts +10 -0
  61. package/lib/model/notations/cards/cardsChangeService.js +50 -0
  62. package/lib/model/notations/cards/cardsModel.d.ts +8 -0
  63. package/lib/model/notations/cards/cardsModel.js +19 -0
  64. package/lib/model/notations/cards/cardsModelService.d.ts +6 -0
  65. package/lib/model/notations/cards/cardsModelService.js +10 -0
  66. package/lib/optionsServices/publicOptionsService.d.ts +1 -1
  67. package/lib/optionsServices/validators/sizeValidator.d.ts +1 -1
  68. package/lib/style/charts-main.css +75 -5
  69. package/lib/style/charts-main.less +75 -5
  70. package/package.json +1 -1
@@ -14,7 +14,7 @@ export class Line {
14
14
  static update(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
15
15
  let promises;
16
16
  if (chart.isSegmented) {
17
- promises = this.updateSegmeneted(block, scales, newData, keyField, margin, keyAxisOrient, chart);
17
+ promises = this.updateSegmented(block, scales, newData, keyField, margin, keyAxisOrient, chart);
18
18
  }
19
19
  else {
20
20
  promises = this.updateGrouped(block, scales, newData, keyField, margin, keyAxisOrient, chart);
@@ -23,7 +23,7 @@ export class Line {
23
23
  }
24
24
  static updateColors(block, chart) {
25
25
  chart.data.valueFields.forEach((_vf, valueIndex) => {
26
- const path = block.getChartGroup(chart.index)
26
+ const path = block.svg.getChartGroup(chart.index)
27
27
  .select(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueIndex}`);
28
28
  DomHelper.setChartStyle(path, chart.style, valueIndex, 'stroke');
29
29
  MarkDot.updateColors(block, chart, valueIndex);
@@ -32,12 +32,12 @@ export class Line {
32
32
  static renderGrouped(block, scales, data, keyField, margin, keyAxisOrient, chart) {
33
33
  chart.data.valueFields.forEach((valueField, valueIndex) => {
34
34
  const lineGenerator = LineHelper.getLineGenerator(keyAxisOrient, scales, keyField.name, valueField.name, margin);
35
- const path = block.getChartGroup(chart.index)
35
+ const path = block.svg.getChartGroup(chart.index)
36
36
  .append('path')
37
37
  .attr('d', lineGenerator(data))
38
38
  .attr('class', this.lineChartClass)
39
39
  .style('fill', 'none')
40
- .style('clip-path', `url(#${block.getClipPathId()})`)
40
+ .style('clip-path', `url(#${block.svg.getClipPathId()})`)
41
41
  .style('pointer-events', 'none');
42
42
  DomHelper.setCssClasses(path, Helper.getCssClassesWithElementIndex(chart.cssClasses, valueIndex));
43
43
  DomHelper.setChartStyle(path, chart.style, valueIndex, 'stroke');
@@ -47,7 +47,7 @@ export class Line {
47
47
  static renderSegmented(block, scales, data, keyField, margin, keyAxisOrient, chart) {
48
48
  const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(data);
49
49
  const lineGenerator = LineHelper.getSegmentedLineGenerator(keyAxisOrient, scales, keyField.name, margin);
50
- const lines = block.getChartGroup(chart.index)
50
+ const lines = block.svg.getChartGroup(chart.index)
51
51
  .selectAll(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
52
52
  .data(stackedData)
53
53
  .enter()
@@ -55,7 +55,7 @@ export class Line {
55
55
  .attr('d', d => lineGenerator(d))
56
56
  .attr('class', this.lineChartClass)
57
57
  .style('fill', 'none')
58
- .style('clip-path', `url(#${block.getClipPathId()})`)
58
+ .style('clip-path', `url(#${block.svg.getClipPathId()})`)
59
59
  .style('pointer-events', 'none');
60
60
  lines.each(function (d, i) {
61
61
  DomHelper.setCssClasses(select(this), Helper.getCssClassesWithElementIndex(chart.cssClasses, i));
@@ -69,7 +69,7 @@ export class Line {
69
69
  const promises = [];
70
70
  chart.data.valueFields.forEach((valueField, valueFieldIndex) => {
71
71
  const lineGenerator = LineHelper.getLineGenerator(keyAxisOrient, scales, keyField.name, valueField.name, margin);
72
- const lineObject = block.getChartGroup(chart.index)
72
+ const lineObject = block.svg.getChartGroup(chart.index)
73
73
  .select(`.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}.chart-element-${valueFieldIndex}`);
74
74
  const prom = this.updateGroupedPath(block, lineObject, lineGenerator, newData);
75
75
  promises.push(prom);
@@ -77,10 +77,10 @@ export class Line {
77
77
  });
78
78
  return promises;
79
79
  }
80
- static updateSegmeneted(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
80
+ static updateSegmented(block, scales, newData, keyField, margin, keyAxisOrient, chart) {
81
81
  const stackedData = stack().keys(chart.data.valueFields.map(field => field.name))(newData);
82
82
  const lineGenerator = LineHelper.getSegmentedLineGenerator(keyAxisOrient, scales, keyField.name, margin);
83
- const lines = block.getChartGroup(chart.index)
83
+ const lines = block.svg.getChartGroup(chart.index)
84
84
  .selectAll(`path.${this.lineChartClass}${Helper.getCssClassesLine(chart.cssClasses)}`)
85
85
  .data(stackedData);
86
86
  const prom = this.updateSegmentedPath(block, lines, lineGenerator);
@@ -1,12 +1,12 @@
1
1
  import { MdtChartsDataSource } from "../../config/config";
2
- import { Model } from "../../model/model";
2
+ import { Model, TwoDimensionalOptionsModel } from "../../model/model";
3
3
  import { Block } from "../block/block";
4
4
  import { ChartContentManager } from "../contentManager/contentManagerFactory";
5
- import Engine from "../engine";
5
+ import { Engine } from "../engine";
6
6
  export declare class TwoDimensionalManager implements ChartContentManager {
7
- render(engine: Engine, model: Model): void;
8
- updateData(block: Block, model: Model, data: MdtChartsDataSource): void;
9
- updateColors(block: Block, model: Model): void;
7
+ render(engine: Engine, model: Model<TwoDimensionalOptionsModel>): void;
8
+ updateData(block: Block, model: Model<TwoDimensionalOptionsModel>, data: MdtChartsDataSource): void;
9
+ updateColors(block: Block, model: Model<TwoDimensionalOptionsModel>): void;
10
10
  private renderCharts;
11
11
  private updateCharts;
12
12
  }
@@ -18,7 +18,7 @@ export class TwoDimensionalManager {
18
18
  const options = model.options;
19
19
  const scales = Scale.getScales(options.scale.key, options.scale.value, options.chartSettings.bar);
20
20
  engine.block.scales = scales;
21
- engine.block.renderSvg(model.blockCanvas.size);
21
+ engine.block.svg.render(model.blockCanvas.size);
22
22
  Axis.render(engine.block, scales, options.scale, options.axis, model.blockCanvas.size);
23
23
  GridLine.render(engine.block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
24
24
  this.renderCharts(engine.block, options.charts, scales, engine.data, options.data, model.chartBlock.margin, options.axis.key.orient, options.chartSettings.bar, model.blockCanvas.size);
@@ -75,8 +75,8 @@ export class TwoDimensionalManager {
75
75
  });
76
76
  }
77
77
  renderCharts(block, charts, scales, data, dataOptions, margin, keyAxisOrient, barSettings, blockSize) {
78
- block.renderChartClipPath(margin, blockSize);
79
- block.renderChartsBlock();
78
+ block.svg.renderChartClipPath(margin, blockSize);
79
+ block.svg.renderChartsBlock();
80
80
  charts.forEach((chart) => {
81
81
  if (chart.type === 'bar')
82
82
  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'));
@@ -88,7 +88,7 @@ export class TwoDimensionalManager {
88
88
  EmbeddedLabels.raiseGroups(block);
89
89
  }
90
90
  updateCharts(block, charts, scales, data, dataOptions, margin, keyAxisOrient, blockSize, barSettings) {
91
- block.updateChartClipPath(margin, blockSize);
91
+ block.svg.updateChartClipPath(margin, blockSize);
92
92
  let promises = [];
93
93
  charts.forEach((chart) => {
94
94
  let proms;
package/lib/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import Engine from "./engine/engine";
1
+ import { Engine } from "./engine/engine";
2
2
  import { assembleModel, getPreparedData } from "./model/modelBuilder";
3
3
  import { PublicOptionsService } from "./optionsServices/publicOptionsService";
4
4
  export class Chart {
@@ -1,7 +1,7 @@
1
1
  import { ChartStyleConfig } from "../../designer/designerConfig";
2
2
  import { ChartStyle } from "../model";
3
3
  export declare class ChartStyleModelService {
4
- private static standartColors;
4
+ private static standardColors;
5
5
  static getCssClasses(chartIndex: number): string[];
6
6
  static getChartStyle(elementsAmount: number, styleConfig: ChartStyleConfig): ChartStyle;
7
7
  static getColorSet(baseColors: string[], elementsAmount: number): string[];
@@ -19,9 +19,9 @@ export class ChartStyleModelService {
19
19
  }
20
20
  static checkAndGet(baseColors) {
21
21
  if (baseColors.length === 0 || baseColors.filter(color => color === 'rgba(0, 0, 0, 0)' || !color).length > 0) {
22
- return this.standartColors;
22
+ return this.standardColors;
23
23
  }
24
24
  return baseColors;
25
25
  }
26
26
  }
27
- ChartStyleModelService.standartColors = ["#209DE3", "#FF3131", "#FFBA00", "#20B078"];
27
+ ChartStyleModelService.standardColors = ["#209DE3", "#FF3131", "#FFBA00", "#20B078"];
@@ -0,0 +1,7 @@
1
+ import { MdtChartsColorRangeItem } from "../../config/config";
2
+ export declare class ColorRangeManager {
3
+ private sortedRange;
4
+ constructor(range: MdtChartsColorRangeItem[]);
5
+ getColorByValue(value: number): string;
6
+ }
7
+ export declare function sortColorRange(colorRange: MdtChartsColorRangeItem[]): MdtChartsColorRangeItem[];
@@ -0,0 +1,30 @@
1
+ export class ColorRangeManager {
2
+ constructor(range) {
3
+ this.sortedRange = sortColorRange(range);
4
+ }
5
+ getColorByValue(value) {
6
+ for (let i = 0; i < this.sortedRange.length; i++) {
7
+ const currentItem = this.sortedRange[i];
8
+ const nextItem = this.sortedRange[i + 1];
9
+ if (!nextItem)
10
+ return currentItem.color;
11
+ if (currentItem.value == null && value < nextItem.value)
12
+ return currentItem.color;
13
+ if (currentItem.value === value)
14
+ return currentItem.color;
15
+ if (value >= currentItem.value && value < nextItem.value)
16
+ return currentItem.color;
17
+ }
18
+ }
19
+ }
20
+ export function sortColorRange(colorRange) {
21
+ const range = [...colorRange];
22
+ range.sort((a, b) => {
23
+ if (a.value == null)
24
+ return -1;
25
+ return a.value < b.value
26
+ ? -1
27
+ : (a.value == b.value ? 0 : 1);
28
+ });
29
+ return range;
30
+ }
@@ -4,6 +4,7 @@ import { ModelHelper } from "../helpers/modelHelper";
4
4
  import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polar/polarModel";
5
5
  import { DataManagerModelService } from "./dataManagerModelService";
6
6
  import { LegendPolarMarginCalculator } from "../featuresModel/legendModel/polarMarginCalculator";
7
+ import { CardsDataManagerModel } from "./notations/cardsDataManagerModel";
7
8
  export class DataManagerModel {
8
9
  static getPreparedData(data, allowableKeys, config) {
9
10
  const scopedData = this.getScopedData(data, allowableKeys, config);
@@ -17,6 +18,10 @@ export class DataManagerModel {
17
18
  else if (config.options.type === 'polar') {
18
19
  this.initDataScopeForPolar(config.options, modelInstance, data, legendBlock, designerConfig.canvas.legendBlock);
19
20
  }
21
+ else if (config.options.type === "card") {
22
+ const manager = new CardsDataManagerModel();
23
+ manager.initDataScope(modelInstance, data, config.options);
24
+ }
20
25
  this.initScopedData(data, modelInstance, config);
21
26
  }
22
27
  static initScopedData(data, modelInstance, config) {
@@ -0,0 +1,5 @@
1
+ import { MdtChartsCardsOptions, MdtChartsDataSource } from "../../../config/config";
2
+ import { ModelInstance } from "../../modelInstance/modelInstance";
3
+ export declare class CardsDataManagerModel {
4
+ initDataScope(modelInstance: ModelInstance, data: MdtChartsDataSource, configOptions: MdtChartsCardsOptions): void;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { DataManagerModel } from "../dataManagerModel";
2
+ export class CardsDataManagerModel {
3
+ initDataScope(modelInstance, data, configOptions) {
4
+ const firstKey = DataManagerModel.getDataValuesByKeyField(data, configOptions.data.dataSource, configOptions.data.keyField.name)[0];
5
+ modelInstance.dataModel.initScope({
6
+ allowableKeys: [firstKey],
7
+ hidedRecordsAmount: 0
8
+ });
9
+ }
10
+ }
@@ -1,7 +1,8 @@
1
+ import { Legend } from "../../../config/config";
1
2
  import { LegendBlockModel } from "../../model";
2
3
  import { ModelInstance } from "../../modelInstance/modelInstance";
3
4
  export declare class TwoDimLegendModel {
4
- recalcMarginWith2DLegend(modelInstance: ModelInstance, legendBlockModel: LegendBlockModel): void;
5
+ recalcMarginWith2DLegend(modelInstance: ModelInstance, legendBlockModel: LegendBlockModel, legendOptions: Legend): void;
5
6
  private getLegendSize;
6
7
  private getLegendModel;
7
8
  }
@@ -1,8 +1,8 @@
1
1
  import { LegendModel } from "./legendModel";
2
2
  export class TwoDimLegendModel {
3
- recalcMarginWith2DLegend(modelInstance, legendBlockModel) {
3
+ recalcMarginWith2DLegend(modelInstance, legendBlockModel, legendOptions) {
4
4
  const canvasModel = modelInstance.canvasModel;
5
- const legendPosition = this.getLegendModel().position;
5
+ const legendPosition = this.getLegendModel(legendOptions).position;
6
6
  modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
7
7
  if (legendPosition !== 'off') {
8
8
  const legendSize = this.getLegendSize();
@@ -16,9 +16,10 @@ export class TwoDimLegendModel {
16
16
  const heightOfLegendItemWithoutWordWrapping = 20;
17
17
  return heightOfLegendItemWithoutWordWrapping;
18
18
  }
19
- getLegendModel() {
19
+ getLegendModel(legendOptions) {
20
+ const position = legendOptions.show ? "top" : "off";
20
21
  return {
21
- position: "top"
22
+ position
22
23
  };
23
24
  }
24
25
  }
@@ -12,7 +12,7 @@ export class TwoDimMarginModel {
12
12
  }
13
13
  recalcMargin(designerConfig, options, otherComponents, data, modelInstance) {
14
14
  const canvasModel = modelInstance.canvasModel;
15
- this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock);
15
+ this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock, options.legend);
16
16
  const labelSize = this.getHorizontalMarginByAxisLabels(designerConfig.canvas.axisLabel.maxSize.main, options.axis, data, options);
17
17
  this.recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel, options.orientation, options.axis);
18
18
  // Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
@@ -1,4 +1,4 @@
1
- import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition } from "../config/config";
1
+ import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition, MdtChartsIconElement, MdtChartsCardValue, MdtChartsColorName } from "../config/config";
2
2
  import { DataType, DonutOptionsCanvas, Formatter, TooltipSettings, Transitions } from "../designer/designerConfig";
3
3
  declare type AxisType = "key" | "value";
4
4
  export declare type Orient = "top" | "bottom" | "left" | "right";
@@ -10,7 +10,8 @@ export declare type DataOptions = {
10
10
  [option: string]: any;
11
11
  };
12
12
  export declare type UnitsFromConfig = "%" | "px";
13
- export interface Model<O = TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel> {
13
+ export declare type OptionsModel = TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel | CardsOptionsModel;
14
+ export interface Model<O = OptionsModel> {
14
15
  blockCanvas: BlockCanvas;
15
16
  chartBlock: ChartBlockModel;
16
17
  options: O;
@@ -31,14 +32,16 @@ export interface BlockMargin {
31
32
  left: number;
32
33
  right: number;
33
34
  }
34
- interface OptionsModel {
35
- legend: ILegendModel;
35
+ interface BasicOptionsModel {
36
36
  data: OptionsModelData;
37
+ tooltip: TooltipOptions;
38
+ }
39
+ interface GraphicNotationOptionsModel extends BasicOptionsModel {
40
+ legend: ILegendModel;
37
41
  title: string;
38
42
  selectable: boolean;
39
- tooltip: TooltipOptions;
40
43
  }
41
- export interface TwoDimensionalOptionsModel extends OptionsModel {
44
+ export interface TwoDimensionalOptionsModel extends GraphicNotationOptionsModel {
42
45
  type: "2d";
43
46
  scale: IScaleModel;
44
47
  axis: IAxisModel;
@@ -47,12 +50,12 @@ export interface TwoDimensionalOptionsModel extends OptionsModel {
47
50
  orient: ChartOrientation;
48
51
  chartSettings: TwoDimChartElementsSettings;
49
52
  }
50
- export interface PolarOptionsModel extends OptionsModel {
53
+ export interface PolarOptionsModel extends GraphicNotationOptionsModel {
51
54
  type: "polar";
52
55
  charts: PolarChartModel[];
53
56
  chartCanvas: DonutChartSettings;
54
57
  }
55
- export interface IntervalOptionsModel extends OptionsModel {
58
+ export interface IntervalOptionsModel extends GraphicNotationOptionsModel {
56
59
  type: "interval";
57
60
  scale: IScaleModel;
58
61
  axis: IAxisModel;
@@ -61,6 +64,14 @@ export interface IntervalOptionsModel extends OptionsModel {
61
64
  orient: ChartOrientation;
62
65
  chartSettings: TwoDimChartElementsSettings;
63
66
  }
67
+ export interface CardsOptionsModel extends BasicOptionsModel {
68
+ type: "card";
69
+ title: string;
70
+ description?: string;
71
+ icon?: MdtChartsIconElement;
72
+ value: MdtChartsCardValue;
73
+ change?: CardsChangeModel;
74
+ }
64
75
  export interface ILegendModel {
65
76
  position: LegendPosition;
66
77
  }
@@ -156,6 +167,12 @@ export interface DonutThicknessOptions {
156
167
  value: number;
157
168
  unit: DonutThicknessUnit;
158
169
  }
170
+ export interface CardsChangeModel {
171
+ value: MdtChartsCardValue;
172
+ description?: string;
173
+ color: MdtChartsColorName;
174
+ icon?: MdtChartsIconElement;
175
+ }
159
176
  interface ChartModel {
160
177
  tooltip: TooltipModel;
161
178
  cssClasses: string[];
@@ -6,6 +6,7 @@ import { IntervalModel } from './notations/intervalModel';
6
6
  import { OtherComponentsModel } from './featuresModel/otherComponents';
7
7
  import { ConfigValidator } from './configsValidator/configValidator';
8
8
  import { ModelInstance } from './modelInstance/modelInstance';
9
+ import { CardsModelInstance } from './notations/cards/cardsModel';
9
10
  export var AxisType;
10
11
  (function (AxisType) {
11
12
  AxisType[AxisType["Key"] = 0] = "Key";
@@ -41,6 +42,9 @@ function getOptions(config, designerConfig, modelInstance) {
41
42
  else if (config.options.type === 'interval') {
42
43
  return IntervalModel.getOptions(config.options, designerConfig, modelInstance);
43
44
  }
45
+ else if (config.options.type === "card") {
46
+ return CardsModelInstance.getOptions(config.options, modelInstance);
47
+ }
44
48
  }
45
49
  function getDataSettings(dataScope, designerConfig) {
46
50
  return {
@@ -6,6 +6,7 @@ export declare class DataRepositoryModel {
6
6
  initSourceName(sourceName: string): void;
7
7
  initRawFullSource(rawSource: MdtChartsDataSource): void;
8
8
  getRawRows(): import("../../../config/config").MdtChartsDataRow[];
9
+ getFirstRow(): import("../../../config/config").MdtChartsDataRow;
9
10
  initScopedFullSource(scopedSource: MdtChartsDataSource): void;
10
11
  getScopedFullSource(): MdtChartsDataSource;
11
12
  getScopedRows(): import("../../../config/config").MdtChartsDataRow[];
@@ -8,6 +8,9 @@ export class DataRepositoryModel {
8
8
  getRawRows() {
9
9
  return this.rawFullSource[this.sourceName];
10
10
  }
11
+ getFirstRow() {
12
+ return this.rawFullSource[this.sourceName][0];
13
+ }
11
14
  initScopedFullSource(scopedSource) {
12
15
  this.scopedFullSource = scopedSource;
13
16
  }
@@ -0,0 +1,10 @@
1
+ import { MdtChartsCardOptionByValue, MdtChartsCardsChange, MdtChartsColorName, MdtChartsColorRangeItem, MdtChartsDataRow } from "../../../config/config";
2
+ import { CardsChangeModel } from "../../model";
3
+ export declare const DEFAULT_CARD_CHANGE_COLOR: MdtChartsCardOptionByValue<MdtChartsColorName>;
4
+ export declare const DEFAULT_CARD_CHANGE_RANGE: MdtChartsColorRangeItem[];
5
+ export declare class CardsChangeService {
6
+ getChangeModel(dataRow: MdtChartsDataRow, changeOptions: MdtChartsCardsChange): CardsChangeModel;
7
+ private getColor;
8
+ private getIcon;
9
+ private getOptionsByValue;
10
+ }
@@ -0,0 +1,50 @@
1
+ import { ColorRangeManager } from "../../chartStyleModel/colorRange";
2
+ export const DEFAULT_CARD_CHANGE_COLOR = {
3
+ aboveZero: "#20b078",
4
+ equalZero: "#000",
5
+ belowZero: "#ff3131"
6
+ };
7
+ export const DEFAULT_CARD_CHANGE_RANGE = [
8
+ {
9
+ color: DEFAULT_CARD_CHANGE_COLOR.belowZero
10
+ },
11
+ {
12
+ color: DEFAULT_CARD_CHANGE_COLOR.equalZero,
13
+ value: 0
14
+ },
15
+ {
16
+ color: DEFAULT_CARD_CHANGE_COLOR.aboveZero,
17
+ value: 0
18
+ }
19
+ ];
20
+ export class CardsChangeService {
21
+ getChangeModel(dataRow, changeOptions) {
22
+ var _a;
23
+ if (!changeOptions || !((_a = changeOptions.value) === null || _a === void 0 ? void 0 : _a.field))
24
+ return void 0;
25
+ const value = dataRow[changeOptions.value.field];
26
+ return {
27
+ description: changeOptions.description,
28
+ value: Object.assign({}, changeOptions.value),
29
+ color: this.getColor(value, changeOptions.color),
30
+ icon: this.getIcon(value, changeOptions.icon)
31
+ };
32
+ }
33
+ getColor(changeValue, colorOptions) {
34
+ const range = (colorOptions === null || colorOptions === void 0 ? void 0 : colorOptions.length) ? colorOptions : DEFAULT_CARD_CHANGE_RANGE;
35
+ const rangeManager = new ColorRangeManager(range);
36
+ return rangeManager.getColorByValue(changeValue);
37
+ }
38
+ getIcon(changeValue, iconOptions) {
39
+ if (!iconOptions)
40
+ return void 0;
41
+ return this.getOptionsByValue(changeValue, iconOptions);
42
+ }
43
+ getOptionsByValue(value, optionsByValues) {
44
+ if (value < 0)
45
+ return optionsByValues.belowZero;
46
+ if (value > 0)
47
+ return optionsByValues.aboveZero;
48
+ return optionsByValues.equalZero;
49
+ }
50
+ }
@@ -0,0 +1,8 @@
1
+ import { MdtChartsCardsOptions } from "../../../config/config";
2
+ import { CardsOptionsModel } from "../../model";
3
+ import { ModelInstance } from "../../modelInstance/modelInstance";
4
+ export declare class CardsModel {
5
+ private service;
6
+ getOptions(options: MdtChartsCardsOptions, modelInstance: ModelInstance): CardsOptionsModel;
7
+ }
8
+ export declare const CardsModelInstance: CardsModel;
@@ -0,0 +1,19 @@
1
+ import { CardsModelService } from "./cardsModelService";
2
+ export class CardsModel {
3
+ constructor() {
4
+ this.service = new CardsModelService();
5
+ }
6
+ getOptions(options, modelInstance) {
7
+ return {
8
+ type: "card",
9
+ title: options.title,
10
+ description: options.description,
11
+ data: options.data,
12
+ tooltip: options.tooltip,
13
+ icon: options.icon,
14
+ value: Object.assign({}, options.value),
15
+ change: this.service.getCardsChangeModel(options, modelInstance)
16
+ };
17
+ }
18
+ }
19
+ export const CardsModelInstance = new CardsModel();
@@ -0,0 +1,6 @@
1
+ import { MdtChartsCardsOptions } from "../../../config/config";
2
+ import { ModelInstance } from "../../modelInstance/modelInstance";
3
+ export declare class CardsModelService {
4
+ private changeService;
5
+ getCardsChangeModel(options: MdtChartsCardsOptions, modelInstance: ModelInstance): import("../../model").CardsChangeModel;
6
+ }
@@ -0,0 +1,10 @@
1
+ import { CardsChangeService } from "./cardsChangeService";
2
+ export class CardsModelService {
3
+ constructor() {
4
+ this.changeService = new CardsChangeService();
5
+ }
6
+ getCardsChangeModel(options, modelInstance) {
7
+ const data = modelInstance.dataModel.repository.getFirstRow();
8
+ return this.changeService.getChangeModel(data, options.change);
9
+ }
10
+ }
@@ -1,4 +1,4 @@
1
- import { Size } from "../main";
1
+ import { Size } from "../config/config";
2
2
  declare class PublicOptionsServiceClass {
3
3
  validateSize(size: Partial<Size>): boolean;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { Size } from "../../main";
1
+ import { Size } from "../../config/config";
2
2
  export declare class SizeValidator {
3
3
  validate(size: Partial<Size>): boolean;
4
4
  private validateSide;
@@ -30,12 +30,12 @@
30
30
 
31
31
 
32
32
  /*========================================================================== Common classes */
33
- .charts-opacity-inactive {
33
+ .mdt-charts-opacity-inactive {
34
34
  opacity: 0.6;
35
35
  }
36
36
 
37
37
  /* EXTENDED FOR SPECIFIC STYLES */
38
- .legend-item.charts-opacity-inactive {
38
+ .legend-item.mdt-charts-opacity-inactive {
39
39
  opacity: 0.45;
40
40
  }
41
41
 
@@ -188,10 +188,10 @@
188
188
 
189
189
 
190
190
  /*========================================================================= Additional */
191
- .charts-axis .domain {
191
+ .mdt-charts-axis .domain {
192
192
  stroke: #D2D2D2;
193
193
  }
194
- .charts-axis .tick line:first-of-type {
194
+ .mdt-charts-axis .tick line:first-of-type {
195
195
  stroke: #D2D2D2;
196
196
  }
197
197
 
@@ -261,6 +261,76 @@
261
261
  }
262
262
 
263
263
  /* Mark dots */
264
- .charts-dot-hidden {
264
+ .mdt-charts-dot-hidden {
265
265
  display: none;
266
+ }
267
+
268
+ /* Card */
269
+ .mdt-charts-html-chart {
270
+ width: 100%;
271
+ height: 100%;
272
+ }
273
+
274
+ .mdt-charts-card-wrapper {
275
+ width: 100%;
276
+ height: 100%;
277
+ }
278
+
279
+ .mdt-charts-card-wrapper * {
280
+ box-sizing: border-box;
281
+ }
282
+
283
+ .mdt-charts-card-content {
284
+ width: 100%;
285
+ height: 100%;
286
+ display: flex;
287
+ flex-direction: column;
288
+ justify-content: space-between;
289
+ }
290
+
291
+ .mdt-charts-card-header {
292
+ display: flex;
293
+ justify-content: space-between;
294
+ flex: 1;
295
+ font-size: 1.3em;
296
+ }
297
+
298
+ .mdt-charts-card-title {
299
+ margin: 0;
300
+ white-space: nowrap;
301
+ overflow: hidden;
302
+ text-overflow: ellipsis;
303
+ }
304
+
305
+ .mdt-charts-card-description-wrapper {
306
+ overflow: hidden;
307
+ text-overflow: ellipsis;
308
+ }
309
+
310
+ .mdt-charts-card-description {
311
+ margin: 0;
312
+ overflow: hidden;
313
+ text-overflow: ellipsis;
314
+ opacity: 0.6;
315
+ }
316
+
317
+ .mdt-charts-card-value-wrapper {
318
+ flex: 2;
319
+ display: flex;
320
+ align-items: center;
321
+ }
322
+
323
+ .mdt-charts-card-change-content {
324
+ display: flex;
325
+ font-size: 0.9em;
326
+ }
327
+
328
+ .mdt-charts-card-change-content-item:not(:last-of-type) {
329
+ margin-right: 0.5em;
330
+ }
331
+
332
+ .mdt-charts-card-change-description-wrapper {
333
+ white-space: nowrap;
334
+ overflow: hidden;
335
+ text-overflow: ellipsis;
266
336
  }