mdt-charts 1.10.3 → 1.12.1

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 (78) hide show
  1. package/lib/config/config.d.ts +18 -5
  2. package/lib/designer/designerConfig.d.ts +8 -2
  3. package/lib/engine/features/aggregator/aggregator.d.ts +4 -3
  4. package/lib/engine/features/aggregator/aggregator.js +14 -11
  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/features/recordOverflowAlert/recordOverflowAlertCore.d.ts +28 -0
  12. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +50 -0
  13. package/lib/engine/features/title/title.js +2 -0
  14. package/lib/engine/features/tolltip/tooltip.js +1 -1
  15. package/lib/engine/filterManager/filterEventManager.d.ts +3 -3
  16. package/lib/engine/filterManager/filterEventManager.js +4 -4
  17. package/lib/engine/intervalNotation/intervalManager.js +2 -5
  18. package/lib/engine/polarNotation/donut/DonutHelper.d.ts +2 -0
  19. package/lib/engine/polarNotation/donut/DonutHelper.js +20 -3
  20. package/lib/engine/polarNotation/donut/donut.js +1 -1
  21. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +15 -0
  22. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +40 -0
  23. package/lib/engine/polarNotation/polarManager.js +16 -12
  24. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.d.ts +15 -0
  25. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +32 -0
  26. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +13 -7
  27. package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +19 -0
  28. package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.js +61 -0
  29. package/lib/model/chartStyleModel/chartStyleModel.d.ts +9 -0
  30. package/lib/model/chartStyleModel/chartStyleModel.js +27 -0
  31. package/lib/model/{dataManagerModel.d.ts → dataManagerModel/dataManagerModel.d.ts} +18 -6
  32. package/lib/model/{dataManagerModel.js → dataManagerModel/dataManagerModel.js} +52 -44
  33. package/lib/model/dataManagerModel/dataManagerModelService.d.ts +5 -0
  34. package/lib/model/dataManagerModel/dataManagerModelService.js +28 -0
  35. package/lib/model/featuresModel/axisModel.d.ts +10 -8
  36. package/lib/model/featuresModel/axisModel.js +28 -26
  37. package/lib/model/featuresModel/axisModelService.d.ts +4 -0
  38. package/lib/model/featuresModel/axisModelService.js +11 -0
  39. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +4 -2
  40. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +42 -29
  41. package/lib/model/featuresModel/legendModel/legendModel.d.ts +4 -6
  42. package/lib/model/featuresModel/legendModel/legendModel.js +18 -21
  43. package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +11 -0
  44. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +42 -0
  45. package/lib/model/featuresModel/otherComponents.d.ts +9 -2
  46. package/lib/model/featuresModel/otherComponents.js +6 -4
  47. package/lib/model/featuresModel/scaleModel.d.ts +7 -6
  48. package/lib/model/featuresModel/scaleModel.js +9 -9
  49. package/lib/model/featuresModel/titleModel.d.ts +1 -1
  50. package/lib/model/featuresModel/titleModel.js +8 -6
  51. package/lib/model/marginModel.d.ts +7 -6
  52. package/lib/model/marginModel.js +44 -38
  53. package/lib/model/model.d.ts +25 -20
  54. package/lib/model/modelBuilder.js +27 -38
  55. package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +24 -0
  56. package/lib/model/modelInstance/canvasModel/canvasModel.js +44 -0
  57. package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +7 -0
  58. package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +13 -0
  59. package/lib/model/modelInstance/canvasModel/titleCanvas.d.ts +9 -0
  60. package/lib/model/modelInstance/canvasModel/titleCanvas.js +11 -0
  61. package/lib/model/modelInstance/dataModel.d.ts +11 -0
  62. package/lib/model/modelInstance/dataModel.js +23 -0
  63. package/lib/model/modelInstance/modelInstance.d.ts +10 -0
  64. package/lib/model/modelInstance/modelInstance.js +17 -0
  65. package/lib/model/notations/intervalModel.d.ts +2 -1
  66. package/lib/model/notations/intervalModel.js +17 -15
  67. package/lib/model/notations/polarModel.d.ts +11 -3
  68. package/lib/model/notations/polarModel.js +40 -8
  69. package/lib/model/notations/twoDimensionalModel.d.ts +7 -5
  70. package/lib/model/notations/twoDimensionalModel.js +19 -12
  71. package/lib/style/charts-main.css +27 -7
  72. package/lib/style/charts-main.less +27 -7
  73. package/package.json +3 -2
  74. package/tsconfig.production.json +23 -0
  75. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
  76. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
  77. package/lib/model/chartStyleModel.d.ts +0 -16
  78. package/lib/model/chartStyleModel.js +0 -67
@@ -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: PolarOptions | TwoDimensionalOptions | IntervalOptions;
20
+ options: MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions | IntervalOptions;
20
21
  }
21
22
  export interface ChartBlockCanvas {
22
23
  size: Size;
@@ -33,18 +34,18 @@ export interface NewSize {
33
34
  interface Options {
34
35
  legend: Legend;
35
36
  data: DataOptions;
36
- title: string;
37
+ title?: string;
37
38
  selectable: boolean;
38
39
  tooltip?: TooltipOptions;
39
40
  }
40
- export interface TwoDimensionalOptions extends Options {
41
+ export interface MdtChartsTwoDimensionalOptions extends Options {
41
42
  type: '2d';
42
43
  axis: TwoDimensionalAxis;
43
44
  additionalElements: AdditionalElements;
44
45
  charts: TwoDimensionalChart[];
45
46
  orientation: ChartOrientation;
46
47
  }
47
- export interface PolarOptions extends Options {
48
+ export interface MdtChartsPolarOptions extends Options {
48
49
  type: 'polar';
49
50
  chart: PolarChart;
50
51
  }
@@ -61,6 +62,7 @@ export interface Legend {
61
62
  export interface DataOptions {
62
63
  dataSource: string;
63
64
  keyField: MdtChartsField;
65
+ maxRecordsAmount?: number;
64
66
  }
65
67
  export interface MdtChartsField {
66
68
  name: string;
@@ -69,6 +71,9 @@ export interface MdtChartsField {
69
71
  export interface ValueField extends MdtChartsField {
70
72
  title: string;
71
73
  }
74
+ export interface TwoDimValueField extends ValueField {
75
+ color?: string;
76
+ }
72
77
  export interface TooltipOptions {
73
78
  html: TooltipHtml;
74
79
  }
@@ -102,6 +107,10 @@ export interface NumberDomain {
102
107
  end: number;
103
108
  }
104
109
  export interface DiscreteAxisOptions extends AxisOptions {
110
+ labels?: MdtChartsDiscreteAxisLabel;
111
+ }
112
+ export interface MdtChartsDiscreteAxisLabel {
113
+ position?: AxisLabelPosition;
105
114
  }
106
115
  export interface IntervalAxis {
107
116
  key: DiscreteAxisOptions;
@@ -125,13 +134,14 @@ export interface TwoDimensionalChart extends ChartSettings {
125
134
  export interface PolarChart extends ChartSettings {
126
135
  type: PolarChartType;
127
136
  data: PolarChartData;
137
+ aggregator: MdtChartsPolarChartAggregator;
128
138
  }
129
139
  export interface IntervalChart extends ChartSettings {
130
140
  type: IntervalChartType;
131
141
  data: IntervalChartData;
132
142
  }
133
143
  export interface TwoDimensionalChartData {
134
- valueFields: ValueField[];
144
+ valueFields: TwoDimValueField[];
135
145
  }
136
146
  interface MarkersOptions {
137
147
  show: boolean;
@@ -141,6 +151,9 @@ export interface PolarChartData {
141
151
  valueField: ValueField;
142
152
  colorField?: MdtChartsColorField;
143
153
  }
154
+ export interface MdtChartsPolarChartAggregator {
155
+ text: string;
156
+ }
144
157
  interface IntervalChartData {
145
158
  valueField1: ValueField;
146
159
  valueField2: ValueField;
@@ -4,6 +4,7 @@ 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" | "%";
7
8
  export interface DesignerConfig {
8
9
  canvas: Canvas;
9
10
  dataFormat: DataFormat;
@@ -45,9 +46,14 @@ export interface BarOptionsCanvas {
45
46
  }
46
47
  export interface DonutOptionsCanvas {
47
48
  padAngle: number;
48
- minThickness: number;
49
- maxThickness: number;
50
49
  aggregatorPad: number;
50
+ thickness: MdtChartsDonutThicknessOptions;
51
+ }
52
+ export interface MdtChartsDonutThicknessOptions {
53
+ min: number;
54
+ max: number;
55
+ value: number;
56
+ unit: MdtChartsDonutThicknessUnit;
51
57
  }
52
58
  interface DataFormat {
53
59
  formatters: Formatter;
@@ -1,19 +1,20 @@
1
1
  import { MdtChartsDataRow } from '../../../config/config';
2
2
  import { DataType } from '../../../designer/designerConfig';
3
- import { Field } from "../../../model/model";
3
+ import { DonutChartAggreagorModel, Field } from "../../../model/model";
4
4
  import { Block } from "../../block/block";
5
5
  import { Translate } from "../../polarNotation/donut/donut";
6
6
  export interface AggregatorInfo {
7
7
  name: string;
8
8
  value: number;
9
9
  format: DataType;
10
+ margin: number;
10
11
  }
11
12
  export declare class Aggregator {
12
13
  static readonly aggregatorValueClass = "aggregator-value";
13
14
  private static readonly aggregatorNameClass;
14
15
  private static readonly aggregatorObjectClass;
15
- static render(block: Block, data: MdtChartsDataRow[], valueField: Field, innerRadius: number, translate: Translate, fontSize: number, pad: number): void;
16
- static update(block: Block, data: MdtChartsDataRow[], valueField: Field, pad: number): void;
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;
17
18
  private static renderText;
18
19
  private static updateText;
19
20
  private static reCalculateAggregatorFontSize;
@@ -3,23 +3,25 @@ import { interpolateNumber } from 'd3-interpolate';
3
3
  import { Helper } from '../../helpers/helper';
4
4
  import { ValueFormatter } from '../../valueFormatter';
5
5
  export class Aggregator {
6
- static render(block, data, valueField, innerRadius, translate, fontSize, pad) {
6
+ static render(block, data, valueField, innerRadius, translate, fontSize, settings) {
7
7
  const aggregator = {
8
- name: 'Сумма',
8
+ name: settings.text,
9
9
  value: sum(data.map(d => d[valueField.name])),
10
- format: valueField.format
10
+ format: valueField.format,
11
+ margin: settings.margin
11
12
  };
12
- this.renderText(block, innerRadius, aggregator, translate, fontSize, pad);
13
+ this.renderText(block, innerRadius, aggregator, translate, fontSize);
13
14
  }
14
- static update(block, data, valueField, pad) {
15
+ static update(block, data, valueField, settings) {
15
16
  const aggregator = {
16
17
  name: 'Сумма',
17
18
  value: sum(data.map(d => d[valueField.name])),
18
- format: valueField.format
19
+ format: valueField.format,
20
+ margin: settings.margin
19
21
  };
20
- this.updateText(block, aggregator, pad);
22
+ this.updateText(block, aggregator);
21
23
  }
22
- static renderText(block, innerRadius, aggregatorInfo, translate, fontSize, pad) {
24
+ static renderText(block, innerRadius, aggregatorInfo, translate, fontSize) {
23
25
  if (innerRadius > 50) {
24
26
  const aggregatorObject = this.renderAggregatorObject(block, innerRadius, translate);
25
27
  const wrapper = this.renderWrapper(aggregatorObject);
@@ -32,13 +34,14 @@ export class Aggregator {
32
34
  wrapper
33
35
  .append('div')
34
36
  .attr('class', this.aggregatorNameClass)
37
+ .attr('title', aggregatorInfo.name)
35
38
  .style('text-align', 'center')
36
39
  .style('font-size', '18px')
37
40
  .text(aggregatorInfo.name);
38
- this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, pad);
41
+ this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, aggregatorInfo.margin);
39
42
  }
40
43
  }
41
- static updateText(block, newAggregator, pad) {
44
+ static updateText(block, newAggregator) {
42
45
  const aggregatorObject = block.getSvg()
43
46
  .select(`.${this.aggregatorObjectClass}`);
44
47
  const thisClass = this;
@@ -53,7 +56,7 @@ export class Aggregator {
53
56
  const interpolateFunc = interpolateNumber(oldValue, newAggregator.value);
54
57
  return t => {
55
58
  this.textContent = ValueFormatter.formatField(newAggregator.format, (interpolateFunc(t)).toFixed(precision));
56
- thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, pad);
59
+ thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.margin);
57
60
  };
58
61
  });
59
62
  }
@@ -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
+ }
@@ -0,0 +1,28 @@
1
+ import { Block } from "../../block/block";
2
+ export interface RecordOverflowAlertOptions {
3
+ hidedRecordsAmount: number;
4
+ text: RecordOverflowAlertText;
5
+ positionAttrs: AlertBlockPositionAttrs;
6
+ }
7
+ export interface RecordOverflowAlertText {
8
+ one: string;
9
+ twoToFour: string;
10
+ tenToTwenty: string;
11
+ other: string;
12
+ }
13
+ export interface AlertBlockPositionAttrs {
14
+ top?: string;
15
+ bottom?: string;
16
+ right?: string;
17
+ left?: string;
18
+ }
19
+ declare class RecordOverflowAlertCoreClass {
20
+ private readonly blockClass;
21
+ render(block: Block, options: RecordOverflowAlertOptions): void;
22
+ update(block: Block, options: RecordOverflowAlertOptions): void;
23
+ private getAlertText;
24
+ private getWordTextEndingByAmount;
25
+ private setAlertPosition;
26
+ }
27
+ export declare const RecordOverflowAlertCore: RecordOverflowAlertCoreClass;
28
+ export {};
@@ -0,0 +1,50 @@
1
+ class RecordOverflowAlertCoreClass {
2
+ constructor() {
3
+ this.blockClass = 'record-overflow-alert';
4
+ }
5
+ render(block, options) {
6
+ const alertBlock = block.getWrapper()
7
+ .append('div')
8
+ .attr('class', this.blockClass)
9
+ .text(this.getAlertText(options));
10
+ this.setAlertPosition(alertBlock, options.positionAttrs);
11
+ }
12
+ update(block, options) {
13
+ let alertBlock = block.getWrapper()
14
+ .select(`div.${this.blockClass}`);
15
+ if (alertBlock.empty()) {
16
+ if (options.hidedRecordsAmount === 0)
17
+ return;
18
+ else
19
+ this.render(block, options);
20
+ }
21
+ else {
22
+ if (options.hidedRecordsAmount === 0)
23
+ alertBlock.remove();
24
+ else
25
+ alertBlock.text(this.getAlertText(options));
26
+ }
27
+ }
28
+ getAlertText(options) {
29
+ return `+ ${options.hidedRecordsAmount} ${this.getWordTextEndingByAmount(options.hidedRecordsAmount, options.text)}`;
30
+ }
31
+ getWordTextEndingByAmount(hidedRecordsAmount, text) {
32
+ const lastDigit = hidedRecordsAmount % 10;
33
+ if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
34
+ return text.tenToTwenty;
35
+ if (lastDigit === 1)
36
+ return text.one;
37
+ if (lastDigit >= 2 && lastDigit <= 4)
38
+ return text.twoToFour;
39
+ return text.other;
40
+ }
41
+ setAlertPosition(alertBlock, attrs) {
42
+ alertBlock
43
+ .style('position', 'absolute')
44
+ .style('left', attrs.left)
45
+ .style('right', attrs.right)
46
+ .style('top', attrs.top)
47
+ .style('bottom', attrs.bottom);
48
+ }
49
+ }
50
+ export const RecordOverflowAlertCore = new RecordOverflowAlertCoreClass();
@@ -1,6 +1,8 @@
1
1
  import { DomHelper } from '../../helpers/domHelper';
2
2
  export class Title {
3
3
  static render(block, text, titleBlockModel, blockSize) {
4
+ if (!text)
5
+ return;
4
6
  const titleBlock = block.getSvg()
5
7
  .append('text')
6
8
  .attr('class', 'chart-title');
@@ -19,7 +19,7 @@ export class Tooltip {
19
19
  this.renderTooltipFor2DCharts(block, data, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
20
20
  }
21
21
  else if (model.options.type === 'polar') {
22
- this.renderTooltipForPolar(block, model.options, data, model.blockCanvas.size, model.chartBlock.margin, DonutHelper.getThickness(model.chartSettings.donut, model.blockCanvas.size, model.chartBlock.margin), model.otherComponents.tooltipBlock);
22
+ this.renderTooltipForPolar(block, model.options, data, model.blockCanvas.size, model.chartBlock.margin, DonutHelper.getThickness(model.options.chartCanvas, model.blockCanvas.size, model.chartBlock.margin), model.otherComponents.tooltipBlock);
23
23
  }
24
24
  else if (model.options.type === 'interval') {
25
25
  this.renderTooltipForIntervalCharts(block, data, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
@@ -1,6 +1,6 @@
1
1
  import { AxisScale } from "d3-axis";
2
2
  import { MdtChartsDataRow, Size } from "../../config/config";
3
- import { BlockMargin, TwoDimensionalOptionsModel, PolarOptionsModel, DonutChartSettings } from "../../model/model";
3
+ import { BlockMargin, TwoDimensionalOptionsModel, PolarOptionsModel } from "../../model/model";
4
4
  import { Block } from "../block/block";
5
5
  export declare type FilterCallback = (rows: MdtChartsDataRow[]) => void;
6
6
  export interface SelectDetails {
@@ -19,12 +19,12 @@ export declare class FilterEventManager {
19
19
  updateData(newDataset: MdtChartsDataRow[]): void;
20
20
  isSelected(keyValue: string): boolean;
21
21
  clearKeysFor2D(options: TwoDimensionalOptionsModel): void;
22
- clearKeysForPolar(margin: BlockMargin, blockSize: Size, options: PolarOptionsModel, donutSettings: DonutChartSettings): void;
22
+ clearKeysForPolar(margin: BlockMargin, blockSize: Size, options: PolarOptionsModel): void;
23
23
  private setKey;
24
24
  private addId;
25
25
  private removeId;
26
26
  private processKey;
27
- setListenerPolar(margin: BlockMargin, blockSize: Size, options: PolarOptionsModel, donutSettings: DonutChartSettings): void;
27
+ setListenerPolar(margin: BlockMargin, blockSize: Size, options: PolarOptionsModel): void;
28
28
  event2DUpdate(options: TwoDimensionalOptionsModel): void;
29
29
  registerEventFor2D(scaleKey: AxisScale<any>, margin: BlockMargin, blockSize: Size, options: TwoDimensionalOptionsModel): void;
30
30
  private registerEventToDonut;
@@ -29,11 +29,11 @@ export class FilterEventManager {
29
29
  this.callback([]);
30
30
  SelectHighlighter.clear2D(this.block, options);
31
31
  }
32
- clearKeysForPolar(margin, blockSize, options, donutSettings) {
32
+ clearKeysForPolar(margin, blockSize, options) {
33
33
  this.selectedKeys = [];
34
34
  if (this.callback)
35
35
  this.callback([]);
36
- SelectHighlighter.clearPolar(margin, blockSize, this.block, options, Donut.getAllArcGroups(this.block), donutSettings);
36
+ SelectHighlighter.clearPolar(margin, blockSize, this.block, options, Donut.getAllArcGroups(this.block), options.chartCanvas);
37
37
  }
38
38
  setKey(key) {
39
39
  this.selectedKeys = [key];
@@ -66,9 +66,9 @@ export class FilterEventManager {
66
66
  }
67
67
  }
68
68
  }
69
- setListenerPolar(margin, blockSize, options, donutSettings) {
69
+ setListenerPolar(margin, blockSize, options) {
70
70
  if (this.filterable) {
71
- this.registerEventToDonut(margin, blockSize, options, donutSettings);
71
+ this.registerEventToDonut(margin, blockSize, options, options.chartCanvas);
72
72
  const selectedElems = Donut.getAllArcGroups(this.block).filter(d => this.selectedKeys.findIndex(sid => sid === d.data[options.data.keyField.name]) !== -1);
73
73
  this.selectedKeys = [];
74
74
  selectedElems.dispatch('click', { bubbles: false, cancelable: true, detail: { multySelect: true } });
@@ -1,7 +1,6 @@
1
1
  import { Axis } from "../features/axis/axis";
2
2
  import { GridLine } from "../features/gridLine/gridLine";
3
3
  import { Legend } from "../features/legend/legend";
4
- import { RecordOverflowAlert } from "../features/recordOverflowAlert/recordOverflowAlert";
5
4
  import { Scale } from "../features/scale/scale";
6
5
  import { Title } from "../features/title/title";
7
6
  import { Tooltip } from "../features/tolltip/tooltip";
@@ -10,15 +9,13 @@ export class IntervalManager {
10
9
  static render(block, model, data) {
11
10
  const options = model.options;
12
11
  block.renderSvg(model.blockCanvas.size);
13
- const scales = Scale.getScales(options.scale.key, options.scale.value, model.chartSettings.bar);
12
+ const scales = Scale.getScales(options.scale.key, options.scale.value, options.chartSettings.bar);
14
13
  Axis.render(block, scales, options.scale, options.axis, model.blockCanvas.size);
15
14
  GridLine.render(block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, options.scale.key);
16
- this.renderCharts(block, options.charts, scales, data, options.data, model.chartBlock.margin, options.axis.key.orient, model.chartSettings);
15
+ this.renderCharts(block, options.charts, scales, data, options.data, model.chartBlock.margin, options.axis.key.orient, options.chartSettings);
17
16
  Title.render(block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
18
17
  Legend.render(block, data, options, model);
19
18
  Tooltip.render(block, model, data, model.otherComponents.tooltipBlock, scales);
20
- if (model.dataSettings.scope.hidedRecordsAmount !== 0)
21
- RecordOverflowAlert.render(block, model.dataSettings.scope.hidedRecordsAmount, 'top', options.orient);
22
19
  }
23
20
  static renderCharts(block, charts, scales, data, dataOptions, margin, keyAxisOrient, chartSettings) {
24
21
  block.renderChartsBlock();
@@ -12,4 +12,6 @@ export declare class DonutHelper {
12
12
  static getArcGenerator(outerRadius: number, innerRadius: number): Arc<any, PieArcDatum<MdtChartsDataRow>>;
13
13
  static getPieGenerator(valueField: string, padAngle: number): Pie<any, MdtChartsDataRow>;
14
14
  static mergeDataWithZeros(firstDataset: MdtChartsDataRow[], secondDataset: MdtChartsDataRow[], keyField: string, colorField: MdtChartsColorField): MdtChartsDataRow[];
15
+ private static getThicknessByUnit;
16
+ private static getChartBlockSize;
15
17
  }
@@ -1,10 +1,15 @@
1
1
  import { merge } from "d3-array";
2
2
  import { arc, pie } from "d3-shape";
3
+ const MIN_CHART_BLOCK_SIZE_FOR_MAX_THICKNESS = 400;
3
4
  export class DonutHelper {
4
5
  static getThickness(donutSettings, blockSize, margin) {
5
- if (Math.min(blockSize.width - margin.left - margin.right, blockSize.height - margin.bottom - margin.top) > 400)
6
- return donutSettings.maxThickness;
7
- return donutSettings.minThickness;
6
+ const thicknessOpts = donutSettings.thickness;
7
+ const chartBlockSize = this.getChartBlockSize(blockSize, margin);
8
+ if (thicknessOpts.value)
9
+ return this.getThicknessByUnit(chartBlockSize, thicknessOpts.value, thicknessOpts.unit);
10
+ if (Math.min(chartBlockSize.width, chartBlockSize.height) > MIN_CHART_BLOCK_SIZE_FOR_MAX_THICKNESS)
11
+ return this.getThicknessByUnit(chartBlockSize, thicknessOpts.max, thicknessOpts.unit);
12
+ return this.getThicknessByUnit(chartBlockSize, thicknessOpts.min, thicknessOpts.unit);
8
13
  }
9
14
  static getArcCentroid(blockSize, margin, dataItem, donutThickness) {
10
15
  const arc = this.getArcGeneratorObject(blockSize, margin, donutThickness);
@@ -57,4 +62,16 @@ export class DonutHelper {
57
62
  const sortedMerge = merge([secondDataset, onlyNew]);
58
63
  return sortedMerge;
59
64
  }
65
+ static getThicknessByUnit(chartBlockSize, valueInPx, unit) {
66
+ if (unit === "px")
67
+ return valueInPx;
68
+ const minSideSize = Math.min(chartBlockSize.width, chartBlockSize.height);
69
+ return minSideSize / 2 * (valueInPx / 100);
70
+ }
71
+ static getChartBlockSize(blockSize, margin) {
72
+ return {
73
+ height: blockSize.height - margin.top - margin.bottom,
74
+ width: blockSize.width - margin.left - margin.right
75
+ };
76
+ }
60
77
  }