mdt-charts 1.12.0 → 1.12.4

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 (60) hide show
  1. package/lib/config/config.d.ts +24 -12
  2. package/lib/designer/designerConfig.d.ts +3 -5
  3. package/lib/engine/features/aggregator/aggregator.d.ts +9 -7
  4. package/lib/engine/features/aggregator/aggregator.js +51 -37
  5. package/lib/engine/features/legend/legend.d.ts +10 -1
  6. package/lib/engine/features/legend/legend.js +10 -22
  7. package/lib/engine/features/legend/legendHelper.d.ts +4 -5
  8. package/lib/engine/features/legend/legendHelper.js +19 -23
  9. package/lib/engine/features/legend/legendHelperService.d.ts +12 -0
  10. package/lib/engine/features/legend/legendHelperService.js +30 -0
  11. package/lib/engine/polarNotation/donut/donut.js +1 -1
  12. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +0 -1
  13. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +9 -17
  14. package/lib/engine/polarNotation/polarManager.js +1 -1
  15. package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +4 -4
  16. package/lib/model/dataManagerModel/dataManagerModel.d.ts +8 -0
  17. package/lib/model/dataManagerModel/dataManagerModel.js +26 -13
  18. package/lib/model/featuresModel/axisModel.d.ts +5 -4
  19. package/lib/model/featuresModel/axisModel.js +13 -11
  20. package/lib/model/featuresModel/axisModelService.d.ts +4 -0
  21. package/lib/model/featuresModel/axisModelService.js +11 -0
  22. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +4 -2
  23. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +42 -29
  24. package/lib/model/featuresModel/legendModel/legendModel.d.ts +1 -2
  25. package/lib/model/featuresModel/legendModel/legendModel.js +15 -15
  26. package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +11 -0
  27. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +42 -0
  28. package/lib/model/featuresModel/scaleModel.d.ts +6 -6
  29. package/lib/model/featuresModel/titleModel.js +4 -4
  30. package/lib/model/marginModel.d.ts +3 -2
  31. package/lib/model/marginModel.js +6 -3
  32. package/lib/model/model.d.ts +19 -8
  33. package/lib/model/modelBuilder.js +8 -9
  34. package/lib/model/modelInstance/dataModel/dataModel.d.ts +14 -0
  35. package/lib/model/modelInstance/dataModel/dataModel.js +26 -0
  36. package/lib/model/modelInstance/dataModel/dataRepository.d.ts +12 -0
  37. package/lib/model/modelInstance/dataModel/dataRepository.js +20 -0
  38. package/lib/model/modelInstance/modelInstance.d.ts +3 -3
  39. package/lib/model/modelInstance/modelInstance.js +6 -4
  40. package/lib/model/notations/intervalModel.d.ts +2 -2
  41. package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +12 -0
  42. package/lib/model/notations/polar/donut/donutAggregatorService.js +25 -0
  43. package/lib/model/notations/polar/donut/donutModel.d.ts +10 -0
  44. package/lib/model/notations/polar/donut/donutModel.js +32 -0
  45. package/lib/model/notations/polar/donut/donutThicknessService.d.ts +9 -0
  46. package/lib/model/notations/polar/donut/donutThicknessService.js +30 -0
  47. package/lib/model/notations/polar/polarModel.d.ts +15 -0
  48. package/lib/model/notations/polar/polarModel.js +53 -0
  49. package/lib/model/notations/polarModel.d.ts +3 -1
  50. package/lib/model/notations/polarModel.js +12 -1
  51. package/lib/model/notations/twoDimensionalModel.d.ts +6 -6
  52. package/lib/model/notations/twoDimensionalModel.js +3 -3
  53. package/lib/style/charts-main.css +29 -9
  54. package/lib/style/charts-main.less +29 -9
  55. package/package.json +2 -2
  56. package/tsconfig.production.json +23 -0
  57. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
  58. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
  59. package/lib/model/dataManagerModel.d.ts +0 -23
  60. package/lib/model/dataManagerModel.js +0 -139
@@ -14,9 +14,10 @@ export declare type MdtChartsDataRow = {
14
14
  export interface MdtChartsDataSource {
15
15
  [source: string]: MdtChartsDataRow[];
16
16
  }
17
+ export declare type AxisLabelPosition = "straight" | "rotated";
17
18
  export interface MdtChartsConfig {
18
19
  canvas: ChartBlockCanvas;
19
- options: MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions | IntervalOptions;
20
+ options: MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions | MdtChartsIntervalOptions;
20
21
  }
21
22
  export interface ChartBlockCanvas {
22
23
  size: Size;
@@ -41,14 +42,14 @@ export interface MdtChartsTwoDimensionalOptions extends Options {
41
42
  type: '2d';
42
43
  axis: TwoDimensionalAxis;
43
44
  additionalElements: AdditionalElements;
44
- charts: TwoDimensionalChart[];
45
+ charts: MdtChartsTwoDimensionalChart[];
45
46
  orientation: ChartOrientation;
46
47
  }
47
48
  export interface MdtChartsPolarOptions extends Options {
48
49
  type: 'polar';
49
50
  chart: PolarChart;
50
51
  }
51
- export interface IntervalOptions extends Options {
52
+ export interface MdtChartsIntervalOptions extends Options {
52
53
  type: 'interval';
53
54
  axis: IntervalAxis;
54
55
  chart: IntervalChart;
@@ -67,10 +68,10 @@ export interface MdtChartsField {
67
68
  name: string;
68
69
  format: DataType;
69
70
  }
70
- export interface ValueField extends MdtChartsField {
71
+ export interface MdtChartsValueField extends MdtChartsField {
71
72
  title: string;
72
73
  }
73
- export interface TwoDimValueField extends ValueField {
74
+ export interface TwoDimValueField extends MdtChartsValueField {
74
75
  color?: string;
75
76
  }
76
77
  export interface TooltipOptions {
@@ -106,6 +107,10 @@ export interface NumberDomain {
106
107
  end: number;
107
108
  }
108
109
  export interface DiscreteAxisOptions extends AxisOptions {
110
+ labels?: MdtChartsDiscreteAxisLabel;
111
+ }
112
+ export interface MdtChartsDiscreteAxisLabel {
113
+ position?: AxisLabelPosition;
109
114
  }
110
115
  export interface IntervalAxis {
111
116
  key: DiscreteAxisOptions;
@@ -119,7 +124,7 @@ interface ChartSettings {
119
124
  interface Tooltip {
120
125
  show: boolean;
121
126
  }
122
- export interface TwoDimensionalChart extends ChartSettings {
127
+ export interface MdtChartsTwoDimensionalChart extends ChartSettings {
123
128
  type: TwoDimensionalChartType;
124
129
  data: TwoDimensionalChartData;
125
130
  embeddedLabels: EmbeddedLabelType;
@@ -129,7 +134,7 @@ export interface TwoDimensionalChart extends ChartSettings {
129
134
  export interface PolarChart extends ChartSettings {
130
135
  type: PolarChartType;
131
136
  data: PolarChartData;
132
- aggregator: MdtChartsPolarChartAggregator;
137
+ aggregator?: MdtChartsDonutAggregator;
133
138
  }
134
139
  export interface IntervalChart extends ChartSettings {
135
140
  type: IntervalChartType;
@@ -143,14 +148,21 @@ interface MarkersOptions {
143
148
  }
144
149
  export declare type MdtChartsColorField = string;
145
150
  export interface PolarChartData {
146
- valueField: ValueField;
151
+ valueField: MdtChartsValueField;
147
152
  colorField?: MdtChartsColorField;
148
153
  }
149
- export interface MdtChartsPolarChartAggregator {
150
- text: string;
154
+ export interface MdtChartsDonutAggregator {
155
+ content?: (model: MdtChartsAggregatorModel) => MdtChartsAggregatorContent;
156
+ }
157
+ export interface MdtChartsAggregatorModel {
158
+ data: MdtChartsDataRow[];
159
+ }
160
+ export interface MdtChartsAggregatorContent {
161
+ value: string | number;
162
+ title: string;
151
163
  }
152
164
  interface IntervalChartData {
153
- valueField1: ValueField;
154
- valueField2: ValueField;
165
+ valueField1: MdtChartsValueField;
166
+ valueField2: MdtChartsValueField;
155
167
  }
156
168
  export {};
@@ -4,7 +4,6 @@ export declare type DataTypeOptions = {
4
4
  };
5
5
  export declare type Formatter = (value: any, options?: any) => string;
6
6
  export declare type TooltipPosition = 'followCursor' | 'fixed';
7
- export declare type MdtChartsDonutThicknessUnit = "px" | "%";
8
7
  export interface DesignerConfig {
9
8
  canvas: Canvas;
10
9
  dataFormat: DataFormat;
@@ -50,10 +49,9 @@ export interface DonutOptionsCanvas {
50
49
  thickness: MdtChartsDonutThicknessOptions;
51
50
  }
52
51
  export interface MdtChartsDonutThicknessOptions {
53
- min: number;
54
- max: number;
55
- value: number;
56
- unit: MdtChartsDonutThicknessUnit;
52
+ min: number | string;
53
+ max: number | string;
54
+ value?: number | string;
57
55
  }
58
56
  interface DataFormat {
59
57
  formatters: Formatter;
@@ -1,23 +1,25 @@
1
- import { MdtChartsDataRow } from '../../../config/config';
2
1
  import { DataType } from '../../../designer/designerConfig';
3
- import { DonutChartAggreagorModel, Field } from "../../../model/model";
2
+ import { DonutAggregatorModel, Field } from "../../../model/model";
4
3
  import { Block } from "../../block/block";
5
4
  import { Translate } from "../../polarNotation/donut/donut";
6
5
  export interface AggregatorInfo {
7
6
  name: string;
8
- value: number;
7
+ value: number | string;
9
8
  format: DataType;
10
- margin: number;
9
+ marginInPercent: number;
11
10
  }
12
11
  export declare class Aggregator {
13
12
  static readonly aggregatorValueClass = "aggregator-value";
14
- private static readonly aggregatorNameClass;
13
+ private static readonly aggregatorTitleClass;
15
14
  private static readonly aggregatorObjectClass;
16
- static render(block: Block, data: MdtChartsDataRow[], valueField: Field, innerRadius: number, translate: Translate, fontSize: number, settings: DonutChartAggreagorModel): void;
17
- static update(block: Block, data: MdtChartsDataRow[], valueField: Field, settings: DonutChartAggreagorModel): void;
15
+ static render(block: Block, valueField: Field, innerRadius: number, translate: Translate, fontSize: number, settings: DonutAggregatorModel): void;
16
+ static update(block: Block, valueField: Field, settings: DonutAggregatorModel): void;
17
+ private static buildConfig;
18
18
  private static renderText;
19
+ private static formatValue;
19
20
  private static updateText;
20
21
  private static reCalculateAggregatorFontSize;
22
+ private static setTitleFontSize;
21
23
  private static renderAggregatorObject;
22
24
  private static renderWrapper;
23
25
  }
@@ -1,76 +1,90 @@
1
- import { sum } from 'd3-array';
2
1
  import { interpolateNumber } from 'd3-interpolate';
3
2
  import { Helper } from '../../helpers/helper';
4
3
  import { ValueFormatter } from '../../valueFormatter';
5
4
  export class Aggregator {
6
- static render(block, data, valueField, innerRadius, translate, fontSize, settings) {
7
- const aggregator = {
8
- name: settings.text,
9
- value: sum(data.map(d => d[valueField.name])),
10
- format: valueField.format,
11
- margin: settings.margin
12
- };
13
- this.renderText(block, innerRadius, aggregator, translate, fontSize);
5
+ static render(block, valueField, innerRadius, translate, fontSize, settings) {
6
+ const aggregator = this.buildConfig(valueField, settings);
7
+ this.renderText(block, innerRadius, aggregator, fontSize, translate);
8
+ }
9
+ static update(block, valueField, settings) {
10
+ const aggregator = this.buildConfig(valueField, settings);
11
+ this.updateText(block, aggregator, typeof aggregator.value === "string");
14
12
  }
15
- static update(block, data, valueField, settings) {
16
- const aggregator = {
17
- name: 'Сумма',
18
- value: sum(data.map(d => d[valueField.name])),
13
+ static buildConfig(valueField, settings) {
14
+ return {
15
+ name: settings.content.title,
16
+ value: settings.content.value,
19
17
  format: valueField.format,
20
- margin: settings.margin
18
+ marginInPercent: settings.margin
21
19
  };
22
- this.updateText(block, aggregator);
23
20
  }
24
- static renderText(block, innerRadius, aggregatorInfo, translate, fontSize) {
25
- if (innerRadius > 50) {
21
+ static renderText(block, innerRadius, aggregatorInfo, fontSize, translate) {
22
+ if (innerRadius > 30) {
26
23
  const aggregatorObject = this.renderAggregatorObject(block, innerRadius, translate);
27
24
  const wrapper = this.renderWrapper(aggregatorObject);
28
25
  wrapper
29
26
  .append('div')
30
27
  .attr('class', this.aggregatorValueClass)
28
+ .attr('title', this.formatValue(aggregatorInfo.format, aggregatorInfo.value))
31
29
  .style('text-align', 'center')
32
30
  .style('font-size', `${fontSize}px`)
33
- .text(ValueFormatter.formatField(aggregatorInfo.format, aggregatorInfo.value));
34
- wrapper
31
+ .text(this.formatValue(aggregatorInfo.format, aggregatorInfo.value));
32
+ const titleBlock = wrapper
35
33
  .append('div')
36
- .attr('class', this.aggregatorNameClass)
34
+ .attr('class', this.aggregatorTitleClass)
37
35
  .attr('title', aggregatorInfo.name)
38
36
  .style('text-align', 'center')
39
- .style('font-size', '18px')
40
37
  .text(aggregatorInfo.name);
41
- this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, aggregatorInfo.margin);
38
+ this.setTitleFontSize(titleBlock, innerRadius);
39
+ this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, aggregatorInfo.marginInPercent);
42
40
  }
43
41
  }
44
- static updateText(block, newAggregator) {
42
+ static formatValue(format, value) {
43
+ if (typeof value === "string")
44
+ return value;
45
+ return ValueFormatter.formatField(format, value);
46
+ }
47
+ static updateText(block, newAggregator, withoutAnimation) {
45
48
  const aggregatorObject = block.getSvg()
46
49
  .select(`.${this.aggregatorObjectClass}`);
47
50
  const thisClass = this;
48
- block.getSvg()
49
- .select(`.${this.aggregatorValueClass}`)
51
+ const valueBlock = block.getSvg()
52
+ .select(`.${this.aggregatorValueClass}`);
53
+ if (withoutAnimation) {
54
+ valueBlock.text(this.formatValue(newAggregator.format, newAggregator.value));
55
+ return;
56
+ }
57
+ valueBlock
50
58
  .interrupt()
51
59
  .transition()
52
60
  .duration(block.transitionManager.durations.chartUpdate)
53
61
  .tween("text", function () {
62
+ const newValue = typeof newAggregator.value === "string" ? parseFloat(newAggregator.value) : newAggregator.value;
54
63
  const oldValue = Helper.parseFormattedToNumber(this.textContent, ',');
55
- const precision = Helper.calcDigitsAfterDot(newAggregator.value);
56
- const interpolateFunc = interpolateNumber(oldValue, newAggregator.value);
64
+ const precision = Helper.calcDigitsAfterDot(newValue);
65
+ const interpolateFunc = interpolateNumber(oldValue, newValue);
57
66
  return t => {
58
- this.textContent = ValueFormatter.formatField(newAggregator.format, (interpolateFunc(t)).toFixed(precision));
59
- thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.margin);
67
+ this.textContent = thisClass.formatValue(newAggregator.format, parseFloat((interpolateFunc(t)).toFixed(precision)));
68
+ thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.marginInPercent);
60
69
  };
61
70
  });
62
71
  }
63
72
  static reCalculateAggregatorFontSize(wrapperSize, block, pad) {
64
- const aggreggatorValue = block.getSvg()
73
+ const aggregatorValue = block.getSvg()
65
74
  .select(`.${this.aggregatorValueClass}`);
66
- let fontSize = parseInt(aggreggatorValue.style('font-size'));
67
- while (aggreggatorValue.node().getBoundingClientRect().width > wrapperSize - pad * 2 && fontSize > 15) {
68
- aggreggatorValue.style('font-size', `${fontSize -= 2}px`);
69
- }
70
- while (aggreggatorValue.node().getBoundingClientRect().width < wrapperSize - pad * 2 && fontSize < 60) {
71
- aggreggatorValue.style('font-size', `${fontSize += 2}px`);
75
+ const sizeCoefficient = 0.25;
76
+ let fontSize = wrapperSize * sizeCoefficient;
77
+ aggregatorValue.style('font-size', `${fontSize}px`);
78
+ const margin = pad / 100 * wrapperSize;
79
+ while (aggregatorValue.node().getBoundingClientRect().width > wrapperSize - margin * 2 && fontSize > 12) {
80
+ aggregatorValue.style('font-size', `${fontSize -= 2}px`);
72
81
  }
73
82
  }
83
+ static setTitleFontSize(aggregatorTitle, innerRadius) {
84
+ const sizeCoefficient = 0.15;
85
+ aggregatorTitle.style('font-size', `${Math.round(innerRadius * sizeCoefficient)}px`);
86
+ aggregatorTitle.style('max-height', `${sizeCoefficient * 100}%`);
87
+ }
74
88
  static renderAggregatorObject(block, innerRadius, translate) {
75
89
  return block.getSvg()
76
90
  .append('foreignObject')
@@ -94,5 +108,5 @@ export class Aggregator {
94
108
  }
95
109
  }
96
110
  Aggregator.aggregatorValueClass = 'aggregator-value';
97
- Aggregator.aggregatorNameClass = 'aggregator-name';
111
+ Aggregator.aggregatorTitleClass = 'aggregator-name';
98
112
  Aggregator.aggregatorObjectClass = 'aggregator-object';
@@ -3,12 +3,21 @@ import { MdtChartsDataSource } from "../../../config/config";
3
3
  import { IntervalOptionsModel, Model, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
4
4
  import { Block } from "../../block/block";
5
5
  import { SelectionCondition } from "../../helpers/domHelper";
6
+ export interface LegendContentRenderingOptions {
7
+ wrapperClasses: string[];
8
+ shouldCropLabels: boolean;
9
+ itemsOptions: {
10
+ wrapperClasses: string[];
11
+ markerClass: string;
12
+ labelClass: string;
13
+ };
14
+ }
6
15
  export declare class Legend {
7
16
  static readonly objectClass = "legend-object";
8
17
  static readonly labelClass = "legend-label";
9
18
  static readonly itemClass = "legend-item";
10
19
  static readonly markerClass = "legend-circle";
11
- private static readonly legendBlockClass;
20
+ static readonly legendBlockClass = "legend-block";
12
21
  static render(block: Block, data: MdtChartsDataSource, options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel, model: Model): void;
13
22
  static update(block: Block, data: MdtChartsDataSource, model: Model): void;
14
23
  static updateColors(block: Block, options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel): void;
@@ -1,4 +1,3 @@
1
- import { select } from "d3-selection";
2
1
  import { ColorReader } from "../../colorReader/colorReader";
3
2
  import { SelectionCondition } from "../../helpers/domHelper";
4
3
  import { LegendDomHelper } from "./legendDomHelper";
@@ -41,8 +40,8 @@ export class Legend {
41
40
  static setContent(block, data, options, legendObject) {
42
41
  const items = LegendHelper.getLegendItemsContent(options, data);
43
42
  const colors = LegendHelper.getMarksColor(options, data[options.data.dataSource]);
44
- const itemsDirection = LegendHelper.getLegendItemsDirection(options.type, options.legend.position);
45
- const itemBlocks = this.renderContent(legendObject, items, colors, itemsDirection, options.legend.position);
43
+ const renderingOptions = LegendHelper.getContentRenderingOptions(options.type, options.legend.position);
44
+ const itemBlocks = this.renderContent(legendObject, items, colors, renderingOptions);
46
45
  if (options.type === 'polar') {
47
46
  LegendEventsManager.setListeners(block, options.data.keyField.name, itemBlocks, options.selectable);
48
47
  }
@@ -58,36 +57,25 @@ export class Legend {
58
57
  this.fillCoordinate(legendObject, legendCoordinate);
59
58
  return legendObject;
60
59
  }
61
- static renderContent(legendObject, items, colorPalette, itemsDirection, position) {
62
- const wrapper = legendObject.append('xhtml:div')
63
- .attr('class', Legend.legendBlockClass);
64
- wrapper
65
- .style('height', '100%')
66
- .style('display', 'flex');
67
- if (itemsDirection === 'column') {
68
- wrapper.style('flex-direction', 'column');
69
- if (position === 'right')
70
- wrapper.style('justify-content', 'center');
71
- }
60
+ static renderContent(foreignObject, items, colorPalette, options) {
61
+ const wrapper = foreignObject.append('xhtml:div');
62
+ wrapper.classed(options.wrapperClasses.join(" "), true);
72
63
  const itemWrappers = wrapper
73
64
  .selectAll(`.${this.itemClass}`)
74
65
  .data(items)
75
66
  .enter()
76
67
  .append('div');
77
- const thisClass = this;
78
- itemWrappers.each(function (d, i) {
79
- select(this).attr('class', `${thisClass.itemClass} ${LegendHelper.getItemClasses(itemsDirection, position, i)}`);
80
- });
68
+ itemWrappers.classed(options.itemsOptions.wrapperClasses.join(" "), true);
81
69
  itemWrappers
82
70
  .append('span')
83
- .attr('class', this.markerClass);
71
+ .classed(options.itemsOptions.markerClass, true);
84
72
  LegendDomHelper.setItemsColors(itemWrappers, colorPalette);
85
73
  itemWrappers
86
74
  .append('span')
87
- .attr('class', LegendHelper.getLegendLabelClassByPosition(position))
75
+ .attr('class', options.itemsOptions.labelClass)
88
76
  .text(d => d);
89
- if (itemsDirection === 'row')
90
- LegendDomHelper.cropRowLabels(legendObject, itemWrappers);
77
+ if (options.shouldCropLabels)
78
+ LegendDomHelper.cropRowLabels(foreignObject, itemWrappers);
91
79
  return itemWrappers;
92
80
  }
93
81
  static getObject(block) {
@@ -1,6 +1,8 @@
1
1
  import { ChartNotation, MdtChartsDataRow, MdtChartsDataSource, Size } from "../../../config/config";
2
2
  import { LegendItemsDirection } from "../../../model/featuresModel/legendModel/legendCanvasModel";
3
3
  import { IntervalOptionsModel, LegendBlockModel, LegendPosition, Orient, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
4
+ import { LegendContentRenderingOptions } from "./legend";
5
+ import { LegendHelperService } from "./legendHelperService";
4
6
  export interface LegendCoordinate {
5
7
  x: number;
6
8
  y: number;
@@ -8,14 +10,11 @@ export interface LegendCoordinate {
8
10
  width: number;
9
11
  }
10
12
  export declare class LegendHelper {
13
+ static service: LegendHelperService;
11
14
  static getLegendItemsContent(options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel, data: MdtChartsDataSource): string[];
12
15
  static getMarksColor(options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel, dataRows?: MdtChartsDataRow[]): string[];
13
16
  static getMaxItemWidth(legendBlockWidth: string, marginsLeft: number[], itemsDirection: LegendItemsDirection): number;
14
- static getItemClasses(itemsDirection: LegendItemsDirection, position: LegendPosition, index: number): string;
15
- static getLegendItemClassByDirection(itemsDirection: LegendItemsDirection): string;
16
- static getLegendItemsMarginClass(legendPosition: LegendPosition): string;
17
- static getLegendLabelClassByPosition(position: LegendPosition): string;
18
- static getLegendItemsDirection(chartNotation: ChartNotation, legendPosition: LegendPosition): LegendItemsDirection;
19
17
  static getSumOfItemsWidths(itemsWidth: number[], marginsLeft: number[]): number;
20
18
  static getLegendCoordinateByPosition(legendPosition: Orient, legendBlockModel: LegendBlockModel, blockSize: Size): LegendCoordinate;
19
+ static getContentRenderingOptions(chartNotation: ChartNotation, legendPosition: LegendPosition): LegendContentRenderingOptions;
21
20
  }
@@ -1,5 +1,6 @@
1
1
  import { Helper } from '../../helpers/helper';
2
2
  import { Legend } from "./legend";
3
+ import { LegendHelperService } from "./legendHelperService";
3
4
  export class LegendHelper {
4
5
  static getLegendItemsContent(options, data) {
5
6
  if (options.type === '2d') {
@@ -40,29 +41,6 @@ export class LegendHelper {
40
41
  }
41
42
  return parseFloat(legendBlockWidth);
42
43
  }
43
- static getItemClasses(itemsDirection, position, index) {
44
- let cssClasses = this.getLegendItemClassByDirection(itemsDirection);
45
- if (itemsDirection === 'column' && index !== 0)
46
- cssClasses += ` ${this.getLegendItemsMarginClass(position)}`;
47
- return cssClasses;
48
- }
49
- static getLegendItemClassByDirection(itemsDirection) {
50
- return itemsDirection === 'column' ? 'legend-item-row' : 'legend-item-inline';
51
- }
52
- static getLegendItemsMarginClass(legendPosition) {
53
- return legendPosition === 'right' ? 'mt-15' : 'mt-10';
54
- }
55
- static getLegendLabelClassByPosition(position) {
56
- if (position === 'top' || position === 'bottom')
57
- return `${Legend.labelClass} ${Legend.labelClass + '-nowrap'}`;
58
- return Legend.labelClass;
59
- }
60
- static getLegendItemsDirection(chartNotation, legendPosition) {
61
- if (legendPosition === 'right' || legendPosition === 'left')
62
- return 'column';
63
- else
64
- return chartNotation === 'polar' ? 'column' : 'row';
65
- }
66
44
  static getSumOfItemsWidths(itemsWidth, marginsLeft) {
67
45
  let sumOfItemsWidth = Helper.getSumOfNumeric(itemsWidth);
68
46
  sumOfItemsWidth += Helper.getSumOfNumeric(marginsLeft);
@@ -96,4 +74,22 @@ export class LegendHelper {
96
74
  coordinate.y = blockSize.height - legendModel.size - legendModel.margin.bottom;
97
75
  return coordinate;
98
76
  }
77
+ static getContentRenderingOptions(chartNotation, legendPosition) {
78
+ const itemsDirection = this.service.getLegendItemsDirection(legendPosition);
79
+ return {
80
+ wrapperClasses: [
81
+ Legend.legendBlockClass,
82
+ this.service.getWrapperClassByItemsDirection(itemsDirection),
83
+ this.service.getWrapperJustifyContentClass(itemsDirection, legendPosition),
84
+ this.service.getWrapperClassByWrappingItems(legendPosition, chartNotation)
85
+ ],
86
+ shouldCropLabels: chartNotation === "2d",
87
+ itemsOptions: {
88
+ markerClass: Legend.markerClass,
89
+ labelClass: this.service.getLegendLabelClassByPosition(legendPosition, chartNotation, Legend.labelClass),
90
+ wrapperClasses: [Legend.itemClass, this.service.getItemClasses(itemsDirection)]
91
+ }
92
+ };
93
+ }
99
94
  }
95
+ LegendHelper.service = new LegendHelperService();
@@ -0,0 +1,12 @@
1
+ import { ChartNotation } from "../../../config/config";
2
+ import { LegendItemsDirection } from "../../../model/featuresModel/legendModel/legendCanvasModel";
3
+ import { LegendPosition } from "../../../model/model";
4
+ export declare class LegendHelperService {
5
+ getWrapperClassByItemsDirection(itemsDirection: LegendItemsDirection): "legend-block-column" | "legend-block-row";
6
+ getWrapperJustifyContentClass(itemsDirection: LegendItemsDirection, legendPosition: LegendPosition): "" | "legend-block-centered";
7
+ getWrapperClassByWrappingItems(legendPosition: LegendPosition, chartNotation: ChartNotation): "legend-wrapper-with-wrap" | "legend-wrapper-without-wrap";
8
+ getLegendLabelClassByPosition(legendPosition: LegendPosition, chartNotation: ChartNotation, initialLabelClass: string): string;
9
+ getItemClasses(itemsDirection: LegendItemsDirection): string;
10
+ getLegendItemsDirection(legendPosition: LegendPosition): LegendItemsDirection;
11
+ private doesLegendInTopBy2d;
12
+ }
@@ -0,0 +1,30 @@
1
+ export class LegendHelperService {
2
+ getWrapperClassByItemsDirection(itemsDirection) {
3
+ return itemsDirection === "column" ? "legend-block-column" : "legend-block-row";
4
+ }
5
+ getWrapperJustifyContentClass(itemsDirection, legendPosition) {
6
+ return itemsDirection === "column" && legendPosition === "right" ? "legend-block-centered" : "";
7
+ }
8
+ getWrapperClassByWrappingItems(legendPosition, chartNotation) {
9
+ if (this.doesLegendInTopBy2d(legendPosition, chartNotation)) {
10
+ return "legend-wrapper-without-wrap";
11
+ }
12
+ return "legend-wrapper-with-wrap";
13
+ }
14
+ getLegendLabelClassByPosition(legendPosition, chartNotation, initialLabelClass) {
15
+ if (this.doesLegendInTopBy2d(legendPosition, chartNotation))
16
+ return `${initialLabelClass} ${initialLabelClass + '-nowrap'}`;
17
+ return initialLabelClass;
18
+ }
19
+ getItemClasses(itemsDirection) {
20
+ return itemsDirection === 'column' ? 'legend-item-row' : 'legend-item-inline';
21
+ }
22
+ getLegendItemsDirection(legendPosition) {
23
+ if (legendPosition === 'right' || legendPosition === 'left')
24
+ return 'column';
25
+ return "row";
26
+ }
27
+ doesLegendInTopBy2d(legendPosition, chartNotation) {
28
+ return legendPosition === 'top' && chartNotation === "2d";
29
+ }
30
+ }
@@ -11,7 +11,7 @@ export class Donut {
11
11
  const arcGenerator = DonutHelper.getArcGenerator(outerRadius, innerRadius);
12
12
  const pieGenerator = DonutHelper.getPieGenerator(chart.data.valueField.name, settings.padAngle);
13
13
  const translateAttr = DonutHelper.getTranslate(margin, blockSize);
14
- Aggregator.render(block, data, chart.data.valueField, innerRadius, translateAttr, thickness, settings.aggregator);
14
+ Aggregator.render(block, chart.data.valueField, innerRadius, translateAttr, thickness, settings.aggregator);
15
15
  const donutBlock = block.getSvg()
16
16
  .append('g')
17
17
  .attr('class', this.donutBlockClass)
@@ -10,7 +10,6 @@ declare class PolarRecordOverflowAlertClass {
10
10
  update(block: Block, options: PolarRecordOverflowAlertOptions): void;
11
11
  private buildCoreOptions;
12
12
  private getPositionAttrs;
13
- private getLeftAttrForRightBlock;
14
13
  }
15
14
  export declare const PolarRecordOverflowAlert: PolarRecordOverflowAlertClass;
16
15
  export {};
@@ -1,6 +1,4 @@
1
- import { Legend } from "../../features/legend/legend";
2
1
  import { RecordOverflowAlertCore } from "../../features/recordOverflowAlert/recordOverflowAlertCore";
3
- import { DomHelper } from "../../helpers/domHelper";
4
2
  class PolarRecordOverflowAlertClass {
5
3
  constructor() {
6
4
  this.text = {
@@ -11,38 +9,32 @@ class PolarRecordOverflowAlertClass {
11
9
  };
12
10
  }
13
11
  render(block, options) {
14
- RecordOverflowAlertCore.render(block, this.buildCoreOptions(block, options));
12
+ RecordOverflowAlertCore.render(block, this.buildCoreOptions(options));
15
13
  }
16
14
  update(block, options) {
17
- RecordOverflowAlertCore.update(block, this.buildCoreOptions(block, options));
15
+ RecordOverflowAlertCore.update(block, this.buildCoreOptions(options));
18
16
  }
19
- buildCoreOptions(block, options) {
17
+ buildCoreOptions(options) {
20
18
  return {
21
19
  hidedRecordsAmount: options.hidedRecordsAmount,
22
20
  text: this.text,
23
- positionAttrs: this.getPositionAttrs(block, options)
21
+ positionAttrs: this.getPositionAttrs(options)
24
22
  };
25
23
  }
26
- getPositionAttrs(block, options) {
24
+ getPositionAttrs(options) {
27
25
  const position = options.legendPosition === 'off' ? 'bottom' : options.legendPosition;
28
26
  if (position === 'right') {
29
27
  return {
30
- bottom: '20px',
31
- left: this.getLeftAttrForRightBlock(block) + 'px'
28
+ bottom: '0',
29
+ right: '0'
32
30
  };
33
31
  }
34
32
  if (position === 'bottom') {
35
33
  return {
36
- bottom: '20px',
37
- left: '20px'
34
+ bottom: '0',
35
+ left: '0'
38
36
  };
39
37
  }
40
38
  }
41
- getLeftAttrForRightBlock(block) {
42
- const legendBlock = block.getSvg().select(`.${Legend.objectClass}`);
43
- if (legendBlock.empty())
44
- return 17;
45
- return DomHelper.getSelectionNumericAttr(legendBlock, 'x');
46
- }
47
39
  }
48
40
  export const PolarRecordOverflowAlert = new PolarRecordOverflowAlertClass();
@@ -39,7 +39,7 @@ export class PolarManager {
39
39
  Tooltip.render(block, model, data, model.otherComponents.tooltipBlock);
40
40
  block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options);
41
41
  });
42
- Aggregator.update(block, data[options.data.dataSource], options.charts[0].data.valueField, options.chartCanvas.aggregator);
42
+ Aggregator.update(block, options.charts[0].data.valueField, options.chartCanvas.aggregator);
43
43
  Legend.update(block, data, model);
44
44
  PolarRecordOverflowAlert.update(block, {
45
45
  hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
@@ -1,16 +1,16 @@
1
- import { TwoDimensionalChart, TwoDimensionalChartType } from "../../config/config";
1
+ import { MdtChartsTwoDimensionalChart, TwoDimensionalChartType } from "../../config/config";
2
2
  import { ChartStyleConfig } from "../../designer/designerConfig";
3
3
  import { ChartStyle } from "../model";
4
4
  export declare class TwoDimensionalChartStyleModel {
5
5
  private charts;
6
6
  private chartStyleConfig;
7
7
  private service;
8
- constructor(charts: TwoDimensionalChart[], chartStyleConfig: ChartStyleConfig);
9
- getChartStyle(chart: TwoDimensionalChart, chartIndex: number): ChartStyle;
8
+ constructor(charts: MdtChartsTwoDimensionalChart[], chartStyleConfig: ChartStyleConfig);
9
+ getChartStyle(chart: MdtChartsTwoDimensionalChart, chartIndex: number): ChartStyle;
10
10
  private getChartsValueFieldsAmounts;
11
11
  }
12
12
  export declare class TwoDimensionalChartStyleService {
13
- getChartColors(chart: TwoDimensionalChart, styleConfig: ChartStyleConfig, chartsFieldsAmounts: number[], chartIndex: number): string[];
13
+ getChartColors(chart: MdtChartsTwoDimensionalChart, styleConfig: ChartStyleConfig, chartsFieldsAmounts: number[], chartIndex: number): string[];
14
14
  getChartOpacity(chartsLength: number, chartType: TwoDimensionalChartType, chartsValueFieldAmount: number, isChartSegmented: boolean): number;
15
15
  private generateNewChartColors;
16
16
  private isMoreThanOneValueFieldOnCanvas;
@@ -2,6 +2,13 @@ import { MdtChartsConfig, MdtChartsDataSource } from "../../config/config";
2
2
  import { DesignerConfig } from "../../designer/designerConfig";
3
3
  import { LegendBlockModel } from "../model";
4
4
  import { ModelInstance } from "../modelInstance/modelInstance";
5
+ export interface DataLegendParams {
6
+ amount: number;
7
+ size: {
8
+ width: number;
9
+ height: number;
10
+ };
11
+ }
5
12
  export declare class DataManagerModel {
6
13
  private static service;
7
14
  static getPreparedData(data: MdtChartsDataSource, allowableKeys: string[], config: MdtChartsConfig): MdtChartsDataSource;
@@ -9,6 +16,7 @@ export declare class DataManagerModel {
9
16
  static getDataValuesByKeyField(data: MdtChartsDataSource, dataSourceName: string, keyFieldName: string): string[];
10
17
  private static initDataScopeFor2D;
11
18
  private static initDataScopeForPolar;
19
+ private static getLegendDataParams;
12
20
  private static getMaximumPossibleScope;
13
21
  private static limitAllowableKeys;
14
22
  /**