mdt-charts 1.22.0 → 1.23.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 (37) hide show
  1. package/lib/config/config.d.ts +34 -4
  2. package/lib/engine/features/axis/axis.js +2 -0
  3. package/lib/engine/features/gridLine/gridLine.d.ts +3 -5
  4. package/lib/engine/features/gridLine/gridLine.js +15 -32
  5. package/lib/engine/features/legend/legend.d.ts +3 -0
  6. package/lib/engine/features/legend/legend.js +3 -0
  7. package/lib/engine/features/legend/legendHelper.d.ts +1 -0
  8. package/lib/engine/features/legend/legendHelper.js +11 -2
  9. package/lib/engine/features/legend/legendHelperService.d.ts +0 -1
  10. package/lib/engine/features/legend/legendHelperService.js +0 -3
  11. package/lib/engine/features/legend/legendMarkerCreator.js +7 -4
  12. package/lib/engine/features/valueLabels/valueLabels.d.ts +0 -1
  13. package/lib/engine/features/valueLabels/valueLabels.js +9 -14
  14. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.d.ts +7 -2
  15. package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +25 -1
  16. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +1 -0
  17. package/lib/engine/twoDimensionalNotation/bar/bar.js +8 -3
  18. package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +7 -2
  19. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +13 -1
  20. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +4 -0
  21. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +2 -2
  22. package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
  23. package/lib/model/featuresModel/axisModel.js +11 -4
  24. package/lib/model/featuresModel/legendModel/legendModel.js +2 -2
  25. package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +2 -2
  26. package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +3 -1
  27. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +6 -0
  28. package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +13 -0
  29. package/lib/model/model.d.ts +52 -4
  30. package/lib/model/notations/polar/polarModel.js +10 -2
  31. package/lib/model/notations/twoDimensional/styles.d.ts +4 -1
  32. package/lib/model/notations/twoDimensional/styles.js +59 -3
  33. package/lib/model/notations/twoDimensionalModel.d.ts +1 -0
  34. package/lib/model/notations/twoDimensionalModel.js +38 -9
  35. package/lib/style/charts-main.css +10 -8
  36. package/lib/style/charts-main.less +10 -8
  37. package/package.json +1 -1
@@ -9,6 +9,7 @@ export declare type PolarChartType = 'donut';
9
9
  export declare type IntervalChartType = 'gantt';
10
10
  export declare type EmbeddedLabelType = 'none' | 'key' | 'value';
11
11
  export declare type ValueLabelsCollisionMode = "none" | "hide";
12
+ export declare type TwoDimLegendPosition = "top" | "bottom";
12
13
  export declare type MdtChartsDataRow = {
13
14
  [field: string]: any;
14
15
  };
@@ -44,7 +45,7 @@ interface BasicOptions {
44
45
  }
45
46
  interface GraphicNotationOptions extends BasicOptions {
46
47
  data: DataOptions;
47
- legend: Legend;
48
+ legend: MdtChartsTwoDimLegend;
48
49
  title?: Title;
49
50
  selectable: boolean;
50
51
  }
@@ -54,7 +55,7 @@ export interface MdtChartsTwoDimensionalOptions extends GraphicNotationOptions {
54
55
  additionalElements: AdditionalElements;
55
56
  charts: MdtChartsTwoDimensionalChart[];
56
57
  orientation: ChartOrientation;
57
- valueLabels?: TwoDimensionalValueLabels;
58
+ valueLabels?: MdtChartsTwoDimensionalValueLabels;
58
59
  }
59
60
  export interface MdtChartsPolarOptions extends GraphicNotationOptions {
60
61
  type: 'polar';
@@ -70,6 +71,9 @@ export interface MdtChartsIntervalOptions extends GraphicNotationOptions {
70
71
  export interface Legend {
71
72
  show: boolean;
72
73
  }
74
+ export interface MdtChartsTwoDimLegend extends Legend {
75
+ position?: TwoDimLegendPosition;
76
+ }
73
77
  export interface TitleFunctionParams {
74
78
  data: MdtChartsDataRow[];
75
79
  }
@@ -125,11 +129,18 @@ export interface AdditionalElements {
125
129
  }
126
130
  interface GridLineOptions {
127
131
  flag: GridLineFlag;
132
+ styles?: GridLineStyles;
128
133
  }
129
134
  interface GridLineFlag {
130
135
  key: boolean;
131
136
  value: boolean;
132
137
  }
138
+ interface GridLineStyles {
139
+ dash?: GridLineStylesDash;
140
+ }
141
+ interface GridLineStylesDash {
142
+ on?: boolean;
143
+ }
133
144
  export interface TwoDimensionalAxis {
134
145
  key: DiscreteAxisOptions;
135
146
  value: NumberAxisOptions;
@@ -140,10 +151,15 @@ export interface AxisOptions {
140
151
  visibility: boolean;
141
152
  position: AxisPosition;
142
153
  ticks: AxisTicks;
154
+ line?: AxisLineOptions;
143
155
  }
144
156
  interface AxisTicks {
145
157
  flag: boolean;
146
158
  }
159
+ interface AxisLineOptions {
160
+ /** @default true */
161
+ visible?: boolean;
162
+ }
147
163
  export interface NumberAxisOptions extends AxisOptions {
148
164
  domain: AxisNumberDomain;
149
165
  labels?: NumberAxisLabel;
@@ -174,10 +190,13 @@ export interface MdtChartsShowAxisLabelRule {
174
190
  spaceForOneLabel?: number;
175
191
  showTickFn?: ShowTickFn;
176
192
  }
177
- export interface TwoDimensionalValueLabels {
193
+ export interface MdtChartsTwoDimensionalValueLabels {
178
194
  collision: ValueLabelsCollision;
179
195
  }
180
196
  export interface ValueLabelsCollision {
197
+ otherValueLabels: OtherValueLabels;
198
+ }
199
+ export interface OtherValueLabels {
181
200
  mode: ValueLabelsCollisionMode;
182
201
  }
183
202
  export interface IntervalAxis {
@@ -193,6 +212,10 @@ interface MdtChartsLineLikeChart {
193
212
  }
194
213
  export interface MdtChartsLineLikeChartStyles {
195
214
  dash?: MdtChartsLineLikeChartDashedStyles;
215
+ /**
216
+ * @default 2
217
+ */
218
+ width?: number;
196
219
  }
197
220
  export interface MdtChartsLineLikeChartDashedStyles {
198
221
  on: boolean;
@@ -213,8 +236,15 @@ interface MdtChartsBarLikeChart {
213
236
  barStyles?: MdtChartsBarLikeChartStyles;
214
237
  embeddedLabels: EmbeddedLabelType;
215
238
  }
216
- interface MdtChartsBarLikeChartStyles {
239
+ export interface MdtChartsBarLikeChartStyles {
217
240
  hatch?: MdtChartsBarLikeChartHatchedStyles;
241
+ borderRadius?: MdtChartsBarLikeChartBorderRadius;
242
+ }
243
+ interface MdtChartsBarLikeChartBorderRadius {
244
+ /**
245
+ * @default 2
246
+ */
247
+ value?: number;
218
248
  }
219
249
  interface MdtChartsBarLikeChartHatchedStyles {
220
250
  on: boolean;
@@ -44,6 +44,8 @@ export class Axis {
44
44
  .append('g')
45
45
  .attr('class', `${this.axesClass} ${axisOptions.cssClass} data-label`);
46
46
  AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate);
47
+ if (!axisOptions.line.visible)
48
+ axisElement.select('.domain').style('display', 'none');
47
49
  if (!axisOptions.labels.visible) {
48
50
  AxisLabelHelper.hideLabels(axisElement);
49
51
  return;
@@ -1,13 +1,11 @@
1
1
  import { Size } from "../../../config/config";
2
- import { BlockMargin, GridLineFlag, IAxisModel } from "../../../model/model";
2
+ import { BlockMargin, GridLineOptions, IAxisModel } from "../../../model/model";
3
3
  import { Block } from "../../block/block";
4
4
  import { Scales } from "../scale/scale";
5
5
  export declare class GridLine {
6
6
  private static readonly gridLineClass;
7
- static render(block: Block, gridLineFlag: GridLineFlag, axes: IAxisModel, blockSize: Size, margin: BlockMargin, scales: Scales): void;
8
- static update(block: Block, gridLineFlag: GridLineFlag, axes: IAxisModel, blockSize: Size, margin: BlockMargin, scales: Scales): void;
7
+ static render(block: Block, options: GridLineOptions, axes: IAxisModel, blockSize: Size, margin: BlockMargin, scales: Scales): void;
8
+ static update(block: Block, options: GridLineOptions, axes: IAxisModel, blockSize: Size, margin: BlockMargin, scales: Scales): void;
9
9
  private static renderLine;
10
10
  private static clear;
11
- private static removeGridLinesOnAxes;
12
- private static rmGridLineOnTick;
13
11
  }
@@ -1,23 +1,25 @@
1
1
  import { GridLineHelper } from "./gidLineHelper";
2
2
  export class GridLine {
3
- static render(block, gridLineFlag, axes, blockSize, margin, scales) {
4
- if (gridLineFlag.value) {
3
+ static render(block, options, axes, blockSize, margin, scales) {
4
+ if (options.flag.value) {
5
5
  const lineLength = GridLineHelper.getGridLineLength('value', axes.key, axes.value, blockSize, margin);
6
6
  const lineAttributes = GridLineHelper.getLineAttributes(axes.value, lineLength);
7
- this.renderLine(block, axes.value, lineAttributes);
7
+ this.renderLine(block, axes.value, lineAttributes, options)
8
+ .style('display', (d, i, group) => {
9
+ return d === 0 ? 'none' : 'block';
10
+ });
8
11
  }
9
- if (gridLineFlag.key) {
12
+ if (options.flag.key) {
10
13
  const lineAttributes = GridLineHelper.getKeyLineAttributes(axes.key, scales.value);
11
- this.renderLine(block, axes.key, lineAttributes);
14
+ this.renderLine(block, axes.key, lineAttributes, options);
12
15
  }
13
- this.removeGridLinesOnAxes(block, axes.key, axes.value, true);
14
16
  }
15
- static update(block, gridLineFlag, axes, blockSize, margin, scales) {
17
+ static update(block, options, axes, blockSize, margin, scales) {
16
18
  this.clear(block, axes.key.cssClass, axes.value.cssClass);
17
- this.render(block, gridLineFlag, axes, blockSize, margin, scales);
19
+ this.render(block, options, axes, blockSize, margin, scales);
18
20
  }
19
- static renderLine(block, axis, lineAttributes) {
20
- block
21
+ static renderLine(block, axis, lineAttributes, options) {
22
+ const gridLine = block
21
23
  .getSvg()
22
24
  .selectAll(`.${axis.cssClass}`)
23
25
  .selectAll('g.tick')
@@ -27,6 +29,9 @@ export class GridLine {
27
29
  .attr('y1', lineAttributes.y1)
28
30
  .attr('x2', lineAttributes.x2)
29
31
  .attr('y2', lineAttributes.y2);
32
+ if (options.styles.dash.on)
33
+ gridLine.style('stroke-dasharray', 3);
34
+ return gridLine;
30
35
  }
31
36
  static clear(block, keyAxisClass, valueAxisClass) {
32
37
  block.getSvg()
@@ -40,27 +45,5 @@ export class GridLine {
40
45
  .selectAll(`.${this.gridLineClass}`)
41
46
  .remove();
42
47
  }
43
- static removeGridLinesOnAxes(block, keyAxis, valueAxis, excludeKey) {
44
- let tickOnKeyAxisSelector = '';
45
- let tickOnValueAxisSelector = '';
46
- if (valueAxis.orient === 'right' || valueAxis.orient === 'bottom')
47
- tickOnValueAxisSelector = ':last-of-type';
48
- if (keyAxis.orient === 'bottom' || keyAxis.orient === 'right')
49
- tickOnKeyAxisSelector = ':last-of-type';
50
- const tickOnKey = block.getSvg()
51
- .select(`.${valueAxis.cssClass}`)
52
- .select(`g.tick${tickOnKeyAxisSelector}`);
53
- const tickOnValue = block.getSvg()
54
- .select(`.${keyAxis.cssClass}`)
55
- .select(`g.tick${tickOnValueAxisSelector}`);
56
- // this.rmGridLineOnTick(tickOnKey);
57
- // if (!excludeKey)
58
- // this.rmGridLineOnTick(tickOnValue);
59
- }
60
- static rmGridLineOnTick(tick) {
61
- tick
62
- .select(`.${this.gridLineClass}`)
63
- .remove();
64
- }
65
48
  }
66
49
  GridLine.gridLineClass = 'grid-line';
@@ -18,6 +18,9 @@ export declare class Legend {
18
18
  static get(): Legend;
19
19
  static readonly objectClass = "legend-object";
20
20
  static readonly labelClass = "legend-label";
21
+ static readonly label2DClass = "legend-2d-label";
22
+ static readonly labelPolarClass = "legend-polar-label";
23
+ static readonly labelIntervalClass = "legend-interval-label";
21
24
  static readonly itemClass = "legend-item";
22
25
  static readonly markerClass = "legend-marker";
23
26
  static readonly markerCircle = "legend-circle";
@@ -110,6 +110,9 @@ export class Legend {
110
110
  }
111
111
  Legend.objectClass = 'legend-object';
112
112
  Legend.labelClass = 'legend-label';
113
+ Legend.label2DClass = 'legend-2d-label';
114
+ Legend.labelPolarClass = 'legend-polar-label';
115
+ Legend.labelIntervalClass = 'legend-interval-label';
113
116
  Legend.itemClass = 'legend-item';
114
117
  Legend.markerClass = 'legend-marker';
115
118
  Legend.markerCircle = 'legend-circle';
@@ -20,4 +20,5 @@ export declare class LegendHelper {
20
20
  static getSumOfItemsWidths(itemsWidth: number[], marginsLeft: number[]): number;
21
21
  static getLegendCoordinateByPosition(legendPosition: Orient, legendBlockModel: LegendBlockModel, blockSize: Size): LegendCoordinate;
22
22
  static getContentRenderingOptions(chartNotation: ChartNotation, legendPosition: LegendPosition, legendBlockModel: LegendBlockModel): LegendContentRenderingOptions;
23
+ private static getLegendClassByChartNotation;
23
24
  }
@@ -70,21 +70,30 @@ export class LegendHelper {
70
70
  }
71
71
  static getContentRenderingOptions(chartNotation, legendPosition, legendBlockModel) {
72
72
  const itemsDirection = this.service.getLegendItemsDirection(legendPosition);
73
+ const legendLabelClass = this.getLegendClassByChartNotation(chartNotation);
73
74
  return {
74
75
  wrapperClasses: [
75
76
  Legend.legendBlockClass,
77
+ chartNotation === "2d" ? "legend-block-centered" : "",
76
78
  this.service.getWrapperClassByItemsDirection(itemsDirection),
77
- this.service.getWrapperJustifyContentClass(itemsDirection, legendPosition),
78
79
  this.service.getWrapperClassByWrappingItems(legendPosition, chartNotation)
79
80
  ],
80
81
  shouldCropLabels: chartNotation === "2d",
81
82
  blockModel: legendBlockModel,
82
83
  itemsOptions: {
83
84
  markerClass: Legend.markerClass,
84
- labelClass: this.service.getLegendLabelClassByPosition(legendPosition, chartNotation, Legend.labelClass),
85
+ labelClass: this.service.getLegendLabelClassByPosition(legendPosition, chartNotation, legendLabelClass),
85
86
  wrapperClasses: [Legend.itemClass, this.service.getItemClasses(itemsDirection)]
86
87
  }
87
88
  };
88
89
  }
90
+ static getLegendClassByChartNotation(chartNotation) {
91
+ const legendClasses = {
92
+ '2d': Legend.label2DClass,
93
+ 'polar': Legend.labelPolarClass,
94
+ 'interval': Legend.labelIntervalClass
95
+ };
96
+ return `${Legend.labelClass} ${legendClasses[chartNotation]}`;
97
+ }
89
98
  }
90
99
  LegendHelper.service = new LegendHelperService();
@@ -3,7 +3,6 @@ import { LegendItemsDirection } from "../../../model/featuresModel/legendModel/l
3
3
  import { LegendPosition } from "../../../model/model";
4
4
  export declare class LegendHelperService {
5
5
  getWrapperClassByItemsDirection(itemsDirection: LegendItemsDirection): "legend-block-column" | "legend-block-row";
6
- getWrapperJustifyContentClass(itemsDirection: LegendItemsDirection, legendPosition: LegendPosition): "" | "legend-block-centered";
7
6
  getWrapperClassByWrappingItems(legendPosition: LegendPosition, chartNotation: ChartNotation): "legend-wrapper-with-wrap" | "legend-wrapper-without-wrap";
8
7
  getLegendLabelClassByPosition(legendPosition: LegendPosition, chartNotation: ChartNotation, initialLabelClass: string): string;
9
8
  getItemClasses(itemsDirection: LegendItemsDirection): string;
@@ -2,9 +2,6 @@ export class LegendHelperService {
2
2
  getWrapperClassByItemsDirection(itemsDirection) {
3
3
  return itemsDirection === "column" ? "legend-block-column" : "legend-block-row";
4
4
  }
5
- getWrapperJustifyContentClass(itemsDirection, legendPosition) {
6
- return itemsDirection === "column" && legendPosition === "right" ? "legend-block-centered" : "";
7
- }
8
5
  getWrapperClassByWrappingItems(legendPosition, chartNotation) {
9
6
  if (this.doesLegendInTopBy2d(legendPosition, chartNotation)) {
10
7
  return "legend-wrapper-without-wrap";
@@ -1,6 +1,7 @@
1
1
  import { Legend } from "./legend";
2
2
  import { HatchPatternDef } from "../../block/defs/hatchPattern";
3
3
  import { applyLineDash } from "../../twoDimensionalNotation/line/lineHelper";
4
+ import { getClipPathValue } from "../../../engine/twoDimensionalNotation/bar/barHelper";
4
5
  export class LegendMarkerCreator {
5
6
  create(selection, options) {
6
7
  const creator = getMarkerCreator(options);
@@ -51,7 +52,8 @@ class BarMarkerCreator extends SvgMarkerCreator {
51
52
  .attr('y', 0)
52
53
  .attr('height', this.options.width)
53
54
  .attr('width', this.options.width)
54
- .style('fill', color);
55
+ .style('fill', color)
56
+ .style('clip-path', getClipPathValue(this.options.borderRadius));
55
57
  if (this.options.hatch.on) {
56
58
  bars.style('mask', HatchPatternDef.getMaskValue());
57
59
  }
@@ -67,16 +69,17 @@ class LineMarkerCreator extends SvgMarkerCreator {
67
69
  this.options = options;
68
70
  }
69
71
  renderMarker(selection, color) {
70
- const svg = this.renderSvg(selection).style("width", this.options.width);
72
+ const svg = this.renderSvg(selection).style("width", this.options.length);
71
73
  const line = svg
72
74
  .append('line')
73
75
  .style('stroke', 'red')
74
76
  .classed("line", true)
75
77
  .attr('x1', 0)
76
- .attr('x2', this.options.width)
78
+ .attr('x2', this.options.length)
77
79
  .attr('y1', 5)
78
80
  .attr('y2', 5)
79
- .style('stroke', color);
81
+ .style('stroke', color)
82
+ .style('stroke-width', this.options.strokeWidth);
80
83
  if (this.options.dashedStyles.on) {
81
84
  applyLineDash(line, this.options.dashedStyles.dashSize, this.options.dashedStyles.gapSize);
82
85
  }
@@ -39,7 +39,6 @@ export declare class CanvasValueLabels {
39
39
  render(scales: ScalesWithSecondary, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData): void;
40
40
  update(scales: ScalesWithSecondary, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData): void;
41
41
  private toggleOldValueLabelsVisibility;
42
- private hideValueLabelsCollision;
43
42
  private getAllValueLabels;
44
43
  private getChartScales;
45
44
  }
@@ -84,6 +84,7 @@ export class CanvasValueLabels {
84
84
  this.chartsValueLabels = [];
85
85
  }
86
86
  render(scales, charts, data, dataOptions) {
87
+ const valueLabelsSettings = this.options.canvas.valueLabels;
87
88
  const chartsWithLabels = charts.filter(chart => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
88
89
  if (chartsWithLabels.length === 0)
89
90
  return;
@@ -93,25 +94,24 @@ export class CanvasValueLabels {
93
94
  this.chartsValueLabels.push(chartValueLabels);
94
95
  chartValueLabels.render(chartScales, data[dataOptions.dataSource]);
95
96
  });
96
- if (this.options.canvas.valueLabels.collision.mode === 'hide') {
97
- this.hideValueLabelsCollision();
98
- }
97
+ const valueLabels = this.getAllValueLabels();
98
+ ValueLabelsCollision.resolveValueLabelsCollisions(valueLabels, valueLabelsSettings);
99
99
  }
100
100
  update(scales, charts, data, dataOptions) {
101
+ const valueLabelsSettings = this.options.canvas.valueLabels;
101
102
  const chartsWithLabels = charts.filter(chart => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
102
103
  if (chartsWithLabels.length === 0)
103
104
  return;
104
- if (this.options.canvas.valueLabels.collision.mode === 'hide')
105
+ if (this.options.canvas.valueLabels.collision.otherValueLables.mode === 'hide')
105
106
  this.toggleOldValueLabelsVisibility();
106
107
  const chartsUpdatePromises = chartsWithLabels.map((chart, index) => {
107
108
  const chartScales = this.getChartScales(scales, chart);
108
109
  return this.chartsValueLabels[index].update(chartScales, data[dataOptions.dataSource]);
109
110
  });
110
- if (this.options.canvas.valueLabels.collision.mode === 'hide') {
111
- Promise.all(chartsUpdatePromises).then(() => {
112
- this.hideValueLabelsCollision();
113
- });
114
- }
111
+ Promise.all(chartsUpdatePromises).then(() => {
112
+ const newValueLabels = this.getAllValueLabels();
113
+ ValueLabelsCollision.resolveValueLabelsCollisions(newValueLabels, valueLabelsSettings);
114
+ });
115
115
  }
116
116
  toggleOldValueLabelsVisibility() {
117
117
  const oldValueLabels = this.getAllValueLabels();
@@ -120,11 +120,6 @@ export class CanvasValueLabels {
120
120
  select(this).style('display', 'block');
121
121
  });
122
122
  }
123
- hideValueLabelsCollision() {
124
- const newValueLabels = this.getAllValueLabels();
125
- const valueLabelElementsRectInfo = ValueLabelsCollision.getValueLabelElementsRectInfo(newValueLabels);
126
- ValueLabelsCollision.toggleValueLabelElementsVisibility(valueLabelElementsRectInfo);
127
- }
128
123
  getAllValueLabels() {
129
124
  const block = this.options.elementAccessors.getBlock().svg.getChartBlock();
130
125
  return block
@@ -1,4 +1,6 @@
1
1
  import { Selection } from "d3-selection";
2
+ import { TwoDimensionalValueLabels } from "../../../model/model";
3
+ import { MdtChartsDataRow } from "../../../config/config";
2
4
  export declare type ValueLabelOnCanvasIndex = number;
3
5
  export interface BoundingRect {
4
6
  x: number;
@@ -18,6 +20,9 @@ export interface LabelVisibility {
18
20
  isVisible: boolean;
19
21
  }
20
22
  export declare class ValueLabelsCollision {
21
- static getValueLabelElementsRectInfo(valueLabels: Selection<SVGTextElement, unknown, SVGGElement, unknown>): ValueLabelElement[];
22
- static toggleValueLabelElementsVisibility(elements: ValueLabelElement[]): void;
23
+ static resolveValueLabelsCollisions(newValueLabels: Selection<SVGTextElement, MdtChartsDataRow, SVGGElement, unknown>, valueLabelsSettings: TwoDimensionalValueLabels): void;
24
+ private static getValueLabelElementsRectInfo;
25
+ private static shiftValueLabelsCollision;
26
+ private static toggleValueLabelElementsVisibility;
27
+ private static changeLabelElementCoordinateX;
23
28
  }
@@ -1,10 +1,18 @@
1
1
  import { select } from "d3-selection";
2
2
  import { ValueLabelsCollisionHelper } from "../../../engine/features/valueLabelsCollision/valueLabelsCollisionHelper";
3
3
  export class ValueLabelsCollision {
4
+ static resolveValueLabelsCollisions(newValueLabels, valueLabelsSettings) {
5
+ const valueLabelElementsRectInfo = this.getValueLabelElementsRectInfo(newValueLabels);
6
+ this.shiftValueLabelsCollision(valueLabelElementsRectInfo, valueLabelsSettings.collision.chartBlock);
7
+ if (valueLabelsSettings.collision.otherValueLables.mode === 'hide')
8
+ this.toggleValueLabelElementsVisibility(valueLabelElementsRectInfo);
9
+ }
4
10
  static getValueLabelElementsRectInfo(valueLabels) {
5
11
  let ValueLabelElementsReactInfo = [];
6
12
  valueLabels.each(function (_, index) {
7
- const { x, y, height, width } = this.getBoundingClientRect();
13
+ const { height, width } = this.getBBox();
14
+ const x = +this.getAttribute("x");
15
+ const y = +this.getAttribute("y");
8
16
  ValueLabelElementsReactInfo.push({
9
17
  index,
10
18
  svgElement: this,
@@ -13,6 +21,18 @@ export class ValueLabelsCollision {
13
21
  });
14
22
  return ValueLabelElementsReactInfo;
15
23
  }
24
+ static shiftValueLabelsCollision(valueLabelElementsRectInfo, chartBlock) {
25
+ valueLabelElementsRectInfo.forEach(element => {
26
+ if (chartBlock.left.mode === 'shift' && chartBlock.left.hasCollision(element.boundingClientRect)) {
27
+ chartBlock.left.shiftCoordinate(element.boundingClientRect);
28
+ this.changeLabelElementCoordinateX(element);
29
+ }
30
+ if (chartBlock.right.mode === 'shift' && chartBlock.right.hasCollision(element.boundingClientRect)) {
31
+ chartBlock.right.shiftCoordinate(element.boundingClientRect);
32
+ this.changeLabelElementCoordinateX(element);
33
+ }
34
+ });
35
+ }
16
36
  static toggleValueLabelElementsVisibility(elements) {
17
37
  const labelsVisibility = ValueLabelsCollisionHelper.calculateValueLabelsVisibility(elements);
18
38
  labelsVisibility.forEach(label => {
@@ -21,4 +41,8 @@ export class ValueLabelsCollision {
21
41
  select(labelInfo.svgElement).style('display', 'none');
22
42
  });
23
43
  }
44
+ static changeLabelElementCoordinateX(element) {
45
+ select(element.svgElement)
46
+ .attr('x', element.boundingClientRect.x);
47
+ }
24
48
  }
@@ -19,6 +19,7 @@ export declare class Bar {
19
19
  private readonly barItemClass;
20
20
  private readonly barSegmentGroupClass;
21
21
  private createBarPipeline;
22
+ private createSegmentGroupBarsPipeline;
22
23
  constructor();
23
24
  render(block: Block, scales: Scales, data: MdtChartsDataRow[], keyField: Field, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barSettings: BarChartSettings, barsAmounts: number[], isSegmented: boolean, firstBarIndex: number): void;
24
25
  update(block: Block, newData: MdtChartsDataRow[], scales: Scales, margin: BlockMargin, keyAxisOrient: Orient, chart: TwoDimensionalChartModel, blockSize: Size, barsAmounts: number[], keyField: Field, firstBarIndex: number, barSettings: BarChartSettings, isSegmented: boolean): Promise<any>[];
@@ -12,7 +12,8 @@ export class Bar {
12
12
  this.barItemClass = Bar.barItemClass;
13
13
  this.barSegmentGroupClass = 'bar-segment-group';
14
14
  this.createBarPipeline = new Pipeline();
15
- onBarChartInit(this.createBarPipeline);
15
+ this.createSegmentGroupBarsPipeline = new Pipeline();
16
+ onBarChartInit(this.createBarPipeline, this.createSegmentGroupBarsPipeline);
16
17
  }
17
18
  static get() {
18
19
  return new Bar();
@@ -88,7 +89,9 @@ export class Bar {
88
89
  DomHelper.setCssClasses(bars, chart.cssClasses); // Для обозначения принадлежности бара к конкретному чарту
89
90
  const thisClass = this;
90
91
  groups.each(function (d, i) {
91
- DomHelper.setCssClasses(select(this).selectAll(`rect${Helper.getCssClassesLine(chart.cssClasses)}`), Helper.getCssClassesWithElementIndex(chart.cssClasses, i)); // Для обозначения принадлежности бара к конкретной части стака
92
+ const barsInGroup = select(this).selectAll(`rect${Helper.getCssClassesLine(chart.cssClasses)}`);
93
+ DomHelper.setCssClasses(barsInGroup, Helper.getCssClassesWithElementIndex(chart.cssClasses, i)); // Для обозначения принадлежности бара к конкретной части стака
94
+ thisClass.createSegmentGroupBarsPipeline.execute(barsInGroup, { segmentIndex: i, chart });
92
95
  thisClass.setSegmentColor(select(this).selectAll(Helper.getCssClassesLine(chart.cssClasses)), chart.style.elementColors, i);
93
96
  });
94
97
  }
@@ -174,7 +177,9 @@ export class Bar {
174
177
  DomHelper.setCssClasses(newBars, chart.cssClasses);
175
178
  const thisClass = this;
176
179
  groups.each(function (d, i) {
177
- DomHelper.setCssClasses(select(this).selectAll(`rect${Helper.getCssClassesLine(chart.cssClasses)}`), Helper.getCssClassesWithElementIndex(chart.cssClasses, i)); // Для обозначения принадлежности бара к конкретной части стака
180
+ const barsInGroup = select(this).selectAll(`rect${Helper.getCssClassesLine(chart.cssClasses)}`);
181
+ DomHelper.setCssClasses(barsInGroup, Helper.getCssClassesWithElementIndex(chart.cssClasses, i)); // Для обозначения принадлежности бара к конкретной части стака
182
+ thisClass.createSegmentGroupBarsPipeline.execute(barsInGroup, { segmentIndex: i, chart });
178
183
  thisClass.setSegmentColor(select(this).selectAll(Helper.getCssClassesLine(chart.cssClasses)), chart.style.elementColors, i);
179
184
  });
180
185
  return [prom];
@@ -1,5 +1,5 @@
1
1
  import { AxisScale } from "d3-axis";
2
- import { BarChartSettings, BlockMargin, Orient, TwoDimensionalChartModel } from "../../../model/model";
2
+ import { BarBorderRadius, BarChartSettings, BlockMargin, Orient, TwoDimensionalChartModel } from "../../../model/model";
3
3
  import { Scales } from "../../features/scale/scale";
4
4
  import { MdtChartsDataRow } from "../../../config/config";
5
5
  import { Pipeline } from "../../helpers/pipeline/Pipeline";
@@ -10,6 +10,10 @@ export interface BarAttrsHelper {
10
10
  width: (dataRow: MdtChartsDataRow) => number;
11
11
  height: (dataRow: MdtChartsDataRow) => number;
12
12
  }
13
+ export interface GroupBarsSegment {
14
+ segmentIndex: number;
15
+ chart: TwoDimensionalChartModel;
16
+ }
13
17
  interface BandLikeChartSettingsStore {
14
18
  getBandItemSize(): number;
15
19
  getBandItemPad(bandItemIndex: number): number;
@@ -50,5 +54,6 @@ export declare class BarHelper {
50
54
  static setGroupedBandStartCoordinateAttr(attrs: BarAttrsHelper, keyAxisOrient: Orient, scaleValue: AxisScale<any>, margin: BlockMargin, valueFieldName: string): void;
51
55
  private static setSegmentedBarAttrsByValue;
52
56
  }
53
- export declare function onBarChartInit(createBarPipeline: Pipeline<Selection<SVGRectElement, any, BaseType, any>, TwoDimensionalChartModel>): void;
57
+ export declare function onBarChartInit(createBarPipeline: Pipeline<Selection<SVGRectElement, any, BaseType, any>, TwoDimensionalChartModel>, createSegmentGroupBarsPipeline: Pipeline<Selection<SVGRectElement, any, BaseType, any>, GroupBarsSegment>): void;
58
+ export declare function getClipPathValue({ topLeft, topRight, bottomLeft, bottomRight }: BarBorderRadius): string;
54
59
  export {};
@@ -135,8 +135,20 @@ export class BarHelper {
135
135
  }
136
136
  }
137
137
  }
138
- export function onBarChartInit(createBarPipeline) {
138
+ export function onBarChartInit(createBarPipeline, createSegmentGroupBarsPipeline) {
139
139
  createBarPipeline.push(hatchBar);
140
+ createBarPipeline.push(roundGroupedBars);
141
+ createSegmentGroupBarsPipeline.push(roundSegmentedBars);
142
+ }
143
+ function roundSegmentedBars(bars, segment) {
144
+ const radiusValues = segment.chart.barViewOptions.borderRadius.segmented.handle(segment.segmentIndex);
145
+ return bars.style('clip-path', getClipPathValue(radiusValues));
146
+ }
147
+ function roundGroupedBars(bars, chart) {
148
+ return bars.style('clip-path', getClipPathValue(chart.barViewOptions.borderRadius.grouped));
149
+ }
150
+ export function getClipPathValue({ topLeft, topRight, bottomLeft, bottomRight }) {
151
+ return `inset(0px round ${topLeft}px ${topRight}px ${bottomRight}px ${bottomLeft}px)`;
140
152
  }
141
153
  function hatchBar(bars, chart) {
142
154
  if (chart.barViewOptions.hatch.on)
@@ -45,6 +45,10 @@ export function onLineChartInit(creatingPipeline) {
45
45
  }
46
46
  return path;
47
47
  });
48
+ creatingPipeline.push(setStrokeWidth);
49
+ }
50
+ function setStrokeWidth(path, chart) {
51
+ return path.style('stroke-width', chart.lineLikeViewOptions.strokeWidth);
48
52
  }
49
53
  export function applyLineDash(lineSelection, dashSize, gapSize) {
50
54
  return lineSelection.style('stroke-dasharray', `${dashSize} ${gapSize}`);
@@ -23,7 +23,7 @@ export class TwoDimensionalManager {
23
23
  engine.block.scales = scales;
24
24
  engine.block.svg.render(model.blockCanvas.size);
25
25
  Axis.render(engine.block, scales, options.scale, options.axis, model.blockCanvas.size);
26
- GridLine.render(engine.block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
26
+ GridLine.render(engine.block, options.additionalElements.gridLine, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
27
27
  this.dotChart = new CanvasDotChart({
28
28
  elementAccessors: {
29
29
  getBlock: () => engine.block,
@@ -85,7 +85,7 @@ export class TwoDimensionalManager {
85
85
  const keyDomainEquality = Helper.checkDomainsEquality(block.scales.key.domain(), scales.key.domain());
86
86
  block.scales = scales;
87
87
  Axis.update(block, scales, options.scale, options.axis, model.blockCanvas.size, keyDomainEquality);
88
- GridLine.update(block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
88
+ GridLine.update(block, options.additionalElements.gridLine, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
89
89
  const promises = this.updateCharts(block, options.charts, scales, data, model.options.data, model.chartBlock.margin, options.axis.key.orient, model.blockCanvas.size, options.chartSettings);
90
90
  Promise.all(promises)
91
91
  .then(() => {
@@ -72,7 +72,7 @@ export class DataManagerModel {
72
72
  wrapperSize: { marginRightPx: styledElementValues.legend.inlineDynamicItemWrapperMarginRightPx }
73
73
  }));
74
74
  if (position === 'right') {
75
- return LegendCanvasModel.findElementsAmountByLegendSize(legendItemContentOptions, position, this.polarMarginCalculator.getMaxLegendWidth(legendCanvas, canvasModel.getBlockSize().width), canvasModel.getChartBlockHeight() - legendBlock.coordinate.bottom.margin.bottom);
75
+ return LegendCanvasModel.findElementsAmountByLegendSize(legendItemContentOptions, position, this.polarMarginCalculator.getMaxLegendWidth(legendCanvas, canvasModel.getBlockSize().width), canvasModel.getChartBlockHeight() - legendBlock.coordinate.right.margin.bottom);
76
76
  }
77
77
  else {
78
78
  return LegendCanvasModel.findElementsAmountByLegendSize(legendItemContentOptions, position, canvasModel.getChartBlockWidth() - legendBlock.coordinate.bottom.margin.left - legendBlock.coordinate.bottom.margin.right, canvasModel.getChartBlockHeight() - legendBlock.coordinate.bottom.margin.bottom - legendBlock.coordinate.bottom.margin.top - MIN_DONUT_BLOCK_SIZE);
@@ -5,9 +5,10 @@ import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
5
5
  import { AxisModelService, AxisModelTickCalculator, showAllTicks } from "./axisModelService";
6
6
  export const MINIMAL_VERTICAL_STEP_SIZE = 60;
7
7
  export const MINIMAL_HORIZONTAL_STEP_SIZE = 100;
8
+ const DEFAULT_AXIS_LINE_VISIBLE = true;
8
9
  export class AxisModel {
9
10
  static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings, getZeroCoordinate) {
10
- var _a;
11
+ var _a, _b, _c;
11
12
  const { charts, orientation, data: dataOptions } = options;
12
13
  const axisConfig = options.axis.key;
13
14
  const translate = this.getKeyAxisTranslateModel(orientation, axisConfig.position, canvasModel, getZeroCoordinate);
@@ -26,7 +27,10 @@ export class AxisModel {
26
27
  showTick: tickCalculator.createFunctionCalculator(this.getAxisLength(orientation, canvasModel)),
27
28
  linearTickStep: MINIMAL_HORIZONTAL_STEP_SIZE
28
29
  },
29
- visibility: axisConfig.visibility
30
+ visibility: axisConfig.visibility,
31
+ line: {
32
+ visible: (_c = (_b = axisConfig.line) === null || _b === void 0 ? void 0 : _b.visible) !== null && _c !== void 0 ? _c : DEFAULT_AXIS_LINE_VISIBLE
33
+ }
30
34
  };
31
35
  }
32
36
  static getMainValueAxis(orient, position, axisConfig, labelConfig, canvasModel) {
@@ -36,7 +40,7 @@ export class AxisModel {
36
40
  return this.getValueAxis(orient, mainAxisPosition === "start" ? "end" : "start", 'value-secondary-axis', axisConfig, labelConfig, canvasModel);
37
41
  }
38
42
  static getValueAxis(orient, position, cssClass, axisConfig, labelConfig, canvasModel) {
39
- var _a, _b;
43
+ var _a, _b, _c, _d;
40
44
  return {
41
45
  type: 'value',
42
46
  orient: AxisModel.getAxisOrient(AxisType.Value, orient, position),
@@ -54,7 +58,10 @@ export class AxisModel {
54
58
  showTick: showAllTicks,
55
59
  linearTickStep: (_b = (_a = axisConfig.labels) === null || _a === void 0 ? void 0 : _a.stepSize) !== null && _b !== void 0 ? _b : (orient === "horizontal" ? MINIMAL_HORIZONTAL_STEP_SIZE : MINIMAL_VERTICAL_STEP_SIZE)
56
60
  },
57
- visibility: axisConfig.visibility
61
+ visibility: axisConfig.visibility,
62
+ line: {
63
+ visible: (_d = (_c = axisConfig.line) === null || _c === void 0 ? void 0 : _c.visible) !== null && _d !== void 0 ? _d : DEFAULT_AXIS_LINE_VISIBLE
64
+ }
58
65
  };
59
66
  }
60
67
  static getAxisLength(chartOrientation, canvasModel) {
@@ -11,7 +11,7 @@ export class LegendModel {
11
11
  },
12
12
  bottom: {
13
13
  size: 0,
14
- margin: { top: 10, bottom: 20, left: 0, right: 0 },
14
+ margin: { top: 2, bottom: 0, left: 0, right: 0 },
15
15
  pad: 0
16
16
  },
17
17
  right: {
@@ -21,7 +21,7 @@ export class LegendModel {
21
21
  },
22
22
  top: {
23
23
  size: 0,
24
- margin: { top: 5, bottom: 10, left: 0, right: 0 },
24
+ margin: { top: 0, bottom: 10, left: 0, right: 0 },
25
25
  pad: canvasModel.titleCanvas.getAllNeededSpace()
26
26
  }
27
27
  },
@@ -1,10 +1,10 @@
1
- import { Legend } from "../../../config/config";
1
+ import { MdtChartsTwoDimLegend } from "../../../config/config";
2
2
  import { LegendBlockModel } from "../../model";
3
3
  import { TwoDimConfigReader } from "../../modelInstance/configReader";
4
4
  import { ModelInstance } from "../../modelInstance/modelInstance";
5
5
  export declare class TwoDimLegendModel {
6
6
  private configReader;
7
7
  constructor(configReader: TwoDimConfigReader);
8
- recalcMarginWith2DLegend(modelInstance: ModelInstance, legendBlockModel: LegendBlockModel, legendOptions: Legend): void;
8
+ recalcMarginWith2DLegend(modelInstance: ModelInstance, legendBlockModel: LegendBlockModel, legendOptions: MdtChartsTwoDimLegend): void;
9
9
  private getLegendModel;
10
10
  }
@@ -24,7 +24,9 @@ export class TwoDimLegendModel {
24
24
  }
25
25
  }
26
26
  getLegendModel(legendOptions) {
27
- const position = legendOptions.show ? "top" : "off";
27
+ var _a;
28
+ const position = legendOptions.show
29
+ ? (_a = legendOptions.position) !== null && _a !== void 0 ? _a : "top" : "off";
28
30
  return {
29
31
  position
30
32
  };
@@ -1,4 +1,6 @@
1
1
  import { BlockMargin, Orient, ValueLabelAnchor, ValueLabelDominantBaseline } from "../../model";
2
+ import { BoundingRect } from "../../../engine/features/valueLabelsCollision/valueLabelsCollision";
3
+ import { Size } from "../../../config/config";
2
4
  interface ValueLabelAlignment {
3
5
  dominantBaseline: ValueLabelDominantBaseline;
4
6
  textAnchor: ValueLabelAnchor;
@@ -6,4 +8,8 @@ interface ValueLabelAlignment {
6
8
  export declare function getValueLabelY(scaledValue: number, keyAxisOrient: Orient, margin: BlockMargin): number;
7
9
  export declare function getValueLabelX(scaledValue: number, keyAxisOrient: Orient, margin: BlockMargin): number;
8
10
  export declare function calculateValueLabelAlignment(keyAxisOrient: Orient): ValueLabelAlignment;
11
+ export declare function hasCollisionLeftSide(labelClientRect: BoundingRect, margin: BlockMargin): boolean;
12
+ export declare function hasCollisionRightSide(labelClientRect: BoundingRect, blockSize: Size, margin: BlockMargin): boolean;
13
+ export declare function shiftCoordinateXLeft(labelClientRect: BoundingRect): void;
14
+ export declare function shiftCoordinateXRight(labelClientRect: BoundingRect): void;
9
15
  export {};
@@ -1,4 +1,5 @@
1
1
  const OFFSET_SIZE_PX = 10;
2
+ const BORDER_OFFSET_SIZE_PX = 2;
2
3
  export function getValueLabelY(scaledValue, keyAxisOrient, margin) {
3
4
  switch (keyAxisOrient) {
4
5
  case 'bottom':
@@ -31,3 +32,15 @@ export function calculateValueLabelAlignment(keyAxisOrient) {
31
32
  return { dominantBaseline: "middle", textAnchor: "end" };
32
33
  }
33
34
  }
35
+ export function hasCollisionLeftSide(labelClientRect, margin) {
36
+ return labelClientRect.x - labelClientRect.width / 2 <= margin.left;
37
+ }
38
+ export function hasCollisionRightSide(labelClientRect, blockSize, margin) {
39
+ return labelClientRect.x + labelClientRect.width / 2 >= blockSize.width - margin.right;
40
+ }
41
+ export function shiftCoordinateXLeft(labelClientRect) {
42
+ labelClientRect.x -= labelClientRect.width / 2 + BORDER_OFFSET_SIZE_PX;
43
+ }
44
+ export function shiftCoordinateXRight(labelClientRect) {
45
+ labelClientRect.x += +labelClientRect.width / 2 + BORDER_OFFSET_SIZE_PX;
46
+ }
@@ -1,5 +1,6 @@
1
- import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition, ShowTickFn, MdtChartsDataRow, TwoDimensionalValueGroup, ValueLabelsCollision } from "../config/config";
1
+ import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition, ShowTickFn, MdtChartsDataRow, TwoDimensionalValueGroup, ValueLabelsCollisionMode } from "../config/config";
2
2
  import { DataType, DonutOptionsCanvas, Formatter, StaticLegendBlockCanvas, TooltipSettings, Transitions } from "../designer/designerConfig";
3
+ import { BoundingRect } from "../engine/features/valueLabelsCollision/valueLabelsCollision";
3
4
  declare type AxisType = "key" | "value";
4
5
  export declare type Orient = "top" | "bottom" | "left" | "right";
5
6
  export declare type ScaleKeyType = "band" | "point";
@@ -134,6 +135,10 @@ export interface AxisModelOptions {
134
135
  cssClass: string;
135
136
  ticks: AxisTicksModel;
136
137
  labels: AxisLabelModel;
138
+ line: AxisLineModel;
139
+ }
140
+ export interface AxisLineModel {
141
+ visible: boolean;
137
142
  }
138
143
  export interface TranslateModel {
139
144
  translateX: number;
@@ -155,11 +160,18 @@ export interface AdditionalElementsOptions {
155
160
  }
156
161
  export interface GridLineOptions {
157
162
  flag: GridLineFlag;
163
+ styles: GridLineStyles;
158
164
  }
159
165
  export interface GridLineFlag {
160
166
  key: boolean;
161
167
  value: boolean;
162
168
  }
169
+ interface GridLineStyles {
170
+ dash: GridLineStylesDash;
171
+ }
172
+ interface GridLineStylesDash {
173
+ on: boolean;
174
+ }
163
175
  export interface TwoDimChartElementsSettings {
164
176
  bar: BarChartSettings;
165
177
  lineLike: LineLikeChartSettings;
@@ -194,9 +206,41 @@ interface LineLikeChartCurveOptions {
194
206
  interface BarLikeChartHatchOptions {
195
207
  on: boolean;
196
208
  }
209
+ export interface BarLikeChartBorderRadius {
210
+ grouped: BarBorderRadius;
211
+ segmented: SegmentedBarBorderRadius;
212
+ }
213
+ export interface BarBorderRadius {
214
+ topLeft: number;
215
+ topRight: number;
216
+ bottomLeft: number;
217
+ bottomRight: number;
218
+ }
219
+ interface SegmentedBarBorderRadius {
220
+ handle: (segmentIndex: number) => BarBorderRadius;
221
+ }
197
222
  export interface TwoDimensionalValueLabels {
198
223
  collision: ValueLabelsCollision;
199
224
  }
225
+ export interface ValueLabelsCollision {
226
+ otherValueLables: OtherValueLables;
227
+ chartBlock: ValueLabelsChartBlock;
228
+ }
229
+ export interface OtherValueLables {
230
+ mode: ValueLabelsCollisionMode;
231
+ }
232
+ export interface ValueLabelsChartBlock {
233
+ left: {
234
+ mode: "none" | "shift";
235
+ hasCollision: (labelClientRect: BoundingRect) => boolean;
236
+ shiftCoordinate: (labelClientRect: BoundingRect) => void;
237
+ };
238
+ right: {
239
+ mode: "none" | "shift";
240
+ hasCollision: (labelClientRect: BoundingRect) => boolean;
241
+ shiftCoordinate: (labelClientRect: BoundingRect) => void;
242
+ };
243
+ }
200
244
  export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad" | "thickness"> {
201
245
  aggregator: DonutAggregatorModel;
202
246
  thickness: DonutThicknessOptions;
@@ -234,11 +278,13 @@ export interface ChartLegendModel {
234
278
  lineViewOptions: TwoDimensionalChartLegendLineModel;
235
279
  }
236
280
  export declare type LegendMarkerShape = "default" | "bar" | "line";
237
- export interface TwoDimensionalChartLegendBarModel extends TwoDimensionalBarLikeChartViewModel {
281
+ export interface TwoDimensionalChartLegendBarModel {
282
+ hatch: BarLikeChartHatchOptions;
283
+ borderRadius: BarBorderRadius;
238
284
  width: number;
239
285
  }
240
286
  export interface TwoDimensionalChartLegendLineModel extends Omit<TwoDimensionalLineLikeChartViewModel, 'renderForKey'> {
241
- width: number;
287
+ length: number;
242
288
  }
243
289
  interface TwoDimensionalLineLikeChartModel {
244
290
  lineLikeViewOptions: TwoDimensionalLineLikeChartViewModel;
@@ -246,14 +292,16 @@ interface TwoDimensionalLineLikeChartModel {
246
292
  }
247
293
  interface TwoDimensionalLineLikeChartViewModel {
248
294
  dashedStyles: LineLikeChartDashOptions;
295
+ strokeWidth: number;
249
296
  renderForKey: LineLikeChartRenderFn;
250
297
  }
251
298
  export declare type LineLikeChartRenderFn = (dataRow: MdtChartsDataRow, valueFieldName: string) => boolean;
252
299
  interface TwoDimensionalBarLikeChartModel {
253
300
  barViewOptions: TwoDimensionalBarLikeChartViewModel;
254
301
  }
255
- interface TwoDimensionalBarLikeChartViewModel {
302
+ export interface TwoDimensionalBarLikeChartViewModel {
256
303
  hatch: BarLikeChartHatchOptions;
304
+ borderRadius: BarLikeChartBorderRadius;
257
305
  }
258
306
  interface TwoDimensionalAreaChartModel {
259
307
  areaViewOptions: AreaChartViewOptions;
@@ -52,8 +52,16 @@ export class PolarModel {
52
52
  style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig),
53
53
  legend: {
54
54
  markerShape: "default",
55
- barViewOptions: { hatch: { on: false }, width: 0 },
56
- lineViewOptions: { dashedStyles: { on: false, dashSize: 0, gapSize: 0 }, width: 0 }
55
+ barViewOptions: {
56
+ hatch: { on: false },
57
+ borderRadius: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 },
58
+ width: 0
59
+ },
60
+ lineViewOptions: {
61
+ dashedStyles: { on: false, dashSize: 0, gapSize: 0 },
62
+ strokeWidth: 0,
63
+ length: 0
64
+ }
57
65
  }
58
66
  });
59
67
  return chartsModel;
@@ -1,8 +1,11 @@
1
- import { AreaChartViewOptions, ChartLegendModel, ChartStyle, GradientId, LineLikeChartDashOptions, LineLikeChartShapeOptions } from "../../model";
1
+ import { AreaChartViewOptions, BarBorderRadius, ChartLegendModel, ChartStyle, GradientId, LineLikeChartDashOptions, LineLikeChartShapeOptions, Orient, TwoDimensionalBarLikeChartViewModel } from "../../model";
2
2
  import { ChartOrientation, MdtChartsLineLikeChartDashedStyles, MdtChartsTwoDimensionalChart, TwoDimensionalChartType } from "../../../config/config";
3
3
  import { MdtChartsLineLikeChartShape } from "../../../designer/designerConfig";
4
+ export declare const LINE_CHART_DEFAULT_WIDTH = 2;
4
5
  export declare function parseShape(chartOrientation: ChartOrientation, configOptions?: MdtChartsLineLikeChartShape): LineLikeChartShapeOptions;
5
6
  export declare function parseDashStyles(configOptions?: MdtChartsLineLikeChartDashedStyles): LineLikeChartDashOptions;
7
+ export declare function getBarViewOptions(chart: MdtChartsTwoDimensionalChart, keyAxisOrient: Orient): TwoDimensionalBarLikeChartViewModel;
8
+ export declare function getSegmentedRadiusValues(segmentsLength: number, segmentIndex: number, keyAxisOrient: Orient, defaultRadius: number): BarBorderRadius;
6
9
  export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart): ChartLegendModel;
7
10
  export declare function getWidthOfLegendMarkerByType(chartType: TwoDimensionalChartType): number;
8
11
  export declare function getAreaViewOptions(chart: MdtChartsTwoDimensionalChart, chartIndex: number, style: ChartStyle): AreaChartViewOptions;
@@ -1,5 +1,7 @@
1
1
  import { LineCurveType } from "../../model";
2
2
  import { styledElementValues } from "../../modelBuilder";
3
+ const BAR_CHART_BORDER_RADIUS_DEFAULT = 2;
4
+ export const LINE_CHART_DEFAULT_WIDTH = 2;
3
5
  export function parseShape(chartOrientation, configOptions) {
4
6
  var _a;
5
7
  const curveType = (_a = configOptions === null || configOptions === void 0 ? void 0 : configOptions.curve) === null || _a === void 0 ? void 0 : _a.type;
@@ -27,8 +29,54 @@ export function parseDashStyles(configOptions) {
27
29
  gapSize: (_c = configOptions === null || configOptions === void 0 ? void 0 : configOptions.gapSize) !== null && _c !== void 0 ? _c : DEFAULT_GAP_SIZE_PX
28
30
  };
29
31
  }
32
+ export function getBarViewOptions(chart, keyAxisOrient) {
33
+ var _a, _b, _c, _d, _e, _f;
34
+ const hatch = { on: (_c = (_b = (_a = chart.barStyles) === null || _a === void 0 ? void 0 : _a.hatch) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false };
35
+ const defaultRadius = (_f = (_e = (_d = chart.barStyles) === null || _d === void 0 ? void 0 : _d.borderRadius) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : BAR_CHART_BORDER_RADIUS_DEFAULT;
36
+ const borderRadius = {
37
+ grouped: getRadiusValues(defaultRadius),
38
+ segmented: {
39
+ handle: (valueIndex) => getSegmentedRadiusValues(chart.data.valueFields.length, valueIndex, keyAxisOrient, defaultRadius),
40
+ }
41
+ };
42
+ return { hatch, borderRadius };
43
+ }
44
+ function getRadiusValues(defaultRadius) {
45
+ return {
46
+ topLeft: defaultRadius,
47
+ topRight: defaultRadius,
48
+ bottomLeft: defaultRadius,
49
+ bottomRight: defaultRadius
50
+ };
51
+ }
52
+ export function getSegmentedRadiusValues(segmentsLength, segmentIndex, keyAxisOrient, defaultRadius) {
53
+ const radiusConfigs = {
54
+ first: {
55
+ top: { topLeft: defaultRadius, topRight: defaultRadius, bottomLeft: 0, bottomRight: 0 },
56
+ bottom: { topLeft: 0, topRight: 0, bottomLeft: defaultRadius, bottomRight: defaultRadius },
57
+ left: { topLeft: defaultRadius, topRight: 0, bottomLeft: defaultRadius, bottomRight: 0 },
58
+ right: { topLeft: 0, topRight: defaultRadius, bottomLeft: 0, bottomRight: defaultRadius },
59
+ },
60
+ last: {
61
+ top: { topLeft: 0, topRight: 0, bottomLeft: defaultRadius, bottomRight: defaultRadius },
62
+ bottom: { topLeft: defaultRadius, topRight: defaultRadius, bottomLeft: 0, bottomRight: 0 },
63
+ left: { topLeft: 0, topRight: defaultRadius, bottomLeft: 0, bottomRight: defaultRadius },
64
+ right: { topLeft: defaultRadius, topRight: 0, bottomLeft: defaultRadius, bottomRight: 0 },
65
+ },
66
+ middle: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 },
67
+ default: getRadiusValues(defaultRadius)
68
+ };
69
+ if (segmentsLength === 1)
70
+ return radiusConfigs.default;
71
+ else if (segmentIndex === 0)
72
+ return radiusConfigs.first[keyAxisOrient];
73
+ else if (segmentIndex === segmentsLength - 1)
74
+ return radiusConfigs.last[keyAxisOrient];
75
+ else
76
+ return radiusConfigs.middle;
77
+ }
30
78
  export function getLegendMarkerOptions(chart) {
31
- var _a, _b, _c, _d;
79
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
32
80
  const shapeByType = {
33
81
  area: "default",
34
82
  bar: "bar",
@@ -37,8 +85,16 @@ export function getLegendMarkerOptions(chart) {
37
85
  };
38
86
  return {
39
87
  markerShape: shapeByType[chart.type],
40
- barViewOptions: { hatch: { on: (_c = (_b = (_a = chart.barStyles) === null || _a === void 0 ? void 0 : _a.hatch) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false }, width: getWidthOfLegendMarkerByType("bar") },
41
- lineViewOptions: { dashedStyles: parseDashStyles((_d = chart.lineStyles) === null || _d === void 0 ? void 0 : _d.dash), width: getWidthOfLegendMarkerByType("line") }
88
+ barViewOptions: {
89
+ hatch: { on: (_c = (_b = (_a = chart.barStyles) === null || _a === void 0 ? void 0 : _a.hatch) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false },
90
+ borderRadius: getRadiusValues((_f = (_e = (_d = chart.barStyles) === null || _d === void 0 ? void 0 : _d.borderRadius) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : BAR_CHART_BORDER_RADIUS_DEFAULT),
91
+ width: getWidthOfLegendMarkerByType("bar")
92
+ },
93
+ lineViewOptions: {
94
+ dashedStyles: parseDashStyles((_g = chart.lineStyles) === null || _g === void 0 ? void 0 : _g.dash),
95
+ strokeWidth: (_j = (_h = chart.lineStyles) === null || _h === void 0 ? void 0 : _h.width) !== null && _j !== void 0 ? _j : LINE_CHART_DEFAULT_WIDTH,
96
+ length: getWidthOfLegendMarkerByType("line")
97
+ }
42
98
  };
43
99
  }
44
100
  export function getWidthOfLegendMarkerByType(chartType) {
@@ -18,4 +18,5 @@ export declare class TwoDimensionalModel {
18
18
  private static getEmbeddedLabelType;
19
19
  private static getAdditionalElements;
20
20
  private static getChartsByTypes;
21
+ private static getValueLabels;
21
22
  }
@@ -3,13 +3,12 @@ import { TwoDimensionalChartStyleModel } from "../chartStyleModel/twoDimensional
3
3
  import { AxisModel } from "../featuresModel/axisModel";
4
4
  import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
5
5
  import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
6
- import { getAreaViewOptions, getLegendMarkerOptions, parseDashStyles, parseShape } from "./twoDimensional/styles";
6
+ import { getAreaViewOptions, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
7
7
  import { getResolvedTitle } from "../../model/featuresModel/titleModel";
8
- import { calculateValueLabelAlignment, getValueLabelX, getValueLabelY } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
8
+ import { calculateValueLabelAlignment, getValueLabelX, getValueLabelY, hasCollisionLeftSide, hasCollisionRightSide, shiftCoordinateXLeft, shiftCoordinateXRight } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
9
9
  import { TwoDimensionalModelHelper } from "../helpers/twoDimensionalModelHelper";
10
10
  export class TwoDimensionalModel {
11
11
  static getOptions(configReader, designerConfig, modelInstance) {
12
- var _a;
13
12
  const options = configReader.options;
14
13
  const canvasModel = modelInstance.canvasModel;
15
14
  const scaleModel = new ScaleModel();
@@ -37,7 +36,7 @@ export class TwoDimensionalModel {
37
36
  additionalElements: this.getAdditionalElements(options),
38
37
  tooltip: options.tooltip,
39
38
  chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation),
40
- valueLabels: (_a = options.valueLabels) !== null && _a !== void 0 ? _a : { collision: { mode: "none" } },
39
+ valueLabels: this.getValueLabels(options.valueLabels, canvasModel),
41
40
  defs: {
42
41
  gradients: TwoDimensionalModelHelper.getGradientDefs(charts, keyAxis.orient, options.orientation)
43
42
  }
@@ -70,7 +69,7 @@ export class TwoDimensionalModel {
70
69
  this.sortCharts(charts);
71
70
  const chartsModel = [];
72
71
  charts.forEach((chart, index) => {
73
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
72
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
74
73
  const style = styleModel.getChartStyle(chart, index);
75
74
  chartsModel.push({
76
75
  type: chart.type,
@@ -96,13 +95,14 @@ export class TwoDimensionalModel {
96
95
  },
97
96
  lineLikeViewOptions: {
98
97
  dashedStyles: parseDashStyles((_k = chart.lineStyles) === null || _k === void 0 ? void 0 : _k.dash),
98
+ strokeWidth: (_m = (_l = chart.lineStyles) === null || _l === void 0 ? void 0 : _l.width) !== null && _m !== void 0 ? _m : LINE_CHART_DEFAULT_WIDTH,
99
99
  renderForKey: (dataRow, valueFieldName) => dataRow[valueFieldName] !== null && dataRow[valueFieldName] !== undefined
100
100
  },
101
- barViewOptions: { hatch: { on: (_o = (_m = (_l = chart.barStyles) === null || _l === void 0 ? void 0 : _l.hatch) === null || _m === void 0 ? void 0 : _m.on) !== null && _o !== void 0 ? _o : false } },
101
+ barViewOptions: getBarViewOptions(chart, keyAxisOrient),
102
102
  legend: getLegendMarkerOptions(chart),
103
103
  index,
104
104
  valueLabels: {
105
- show: (_q = (_p = chart.valueLabels) === null || _p === void 0 ? void 0 : _p.on) !== null && _q !== void 0 ? _q : false,
105
+ show: (_p = (_o = chart.valueLabels) === null || _o === void 0 ? void 0 : _o.on) !== null && _p !== void 0 ? _p : false,
106
106
  handleX: (scaledValue) => getValueLabelX(scaledValue, keyAxisOrient, canvasModel.getMargin()),
107
107
  handleY: (scaledValue) => getValueLabelY(scaledValue, keyAxisOrient, canvasModel.getMargin()),
108
108
  textAnchor: calculateValueLabelAlignment(keyAxisOrient).textAnchor,
@@ -115,7 +115,7 @@ export class TwoDimensionalModel {
115
115
  type: "line",
116
116
  handleEndCoordinate: (v) => v + 2,
117
117
  handleStartCoordinate: (v) => v - 2,
118
- width: (_t = (_s = (_r = chart.dotLikeStyles) === null || _r === void 0 ? void 0 : _r.shape) === null || _s === void 0 ? void 0 : _s.width) !== null && _t !== void 0 ? _t : 2
118
+ width: (_s = (_r = (_q = chart.dotLikeStyles) === null || _q === void 0 ? void 0 : _q.shape) === null || _r === void 0 ? void 0 : _r.width) !== null && _s !== void 0 ? _s : 2
119
119
  }
120
120
  }
121
121
  });
@@ -136,11 +136,40 @@ export class TwoDimensionalModel {
136
136
  return 'none';
137
137
  }
138
138
  static getAdditionalElements(options) {
139
+ var _a, _b;
140
+ const { flag, styles } = options.additionalElements.gridLine;
139
141
  return {
140
- gridLine: options.additionalElements.gridLine
142
+ gridLine: {
143
+ flag,
144
+ styles: {
145
+ dash: { on: (_b = (_a = styles === null || styles === void 0 ? void 0 : styles.dash) === null || _a === void 0 ? void 0 : _a.on) !== null && _b !== void 0 ? _b : false }
146
+ }
147
+ }
141
148
  };
142
149
  }
143
150
  static getChartsByTypes(charts, types) {
144
151
  return charts.filter(chart => types.includes(chart.type));
145
152
  }
153
+ static getValueLabels(valueLabels, canvasModel) {
154
+ var _a;
155
+ return {
156
+ collision: {
157
+ otherValueLables: (_a = valueLabels === null || valueLabels === void 0 ? void 0 : valueLabels.collision.otherValueLabels) !== null && _a !== void 0 ? _a : {
158
+ mode: 'none'
159
+ },
160
+ chartBlock: {
161
+ left: {
162
+ mode: 'shift',
163
+ hasCollision: (labelClientRect) => hasCollisionLeftSide(labelClientRect, canvasModel.getMargin()),
164
+ shiftCoordinate: (labelClientRect) => shiftCoordinateXRight(labelClientRect),
165
+ },
166
+ right: {
167
+ mode: 'shift',
168
+ hasCollision: (labelClientRect) => hasCollisionRightSide(labelClientRect, canvasModel.getBlockSize(), canvasModel.getMargin()),
169
+ shiftCoordinate: (labelClientRect) => shiftCoordinateXLeft(labelClientRect),
170
+ }
171
+ }
172
+ },
173
+ };
174
+ }
146
175
  }
@@ -11,7 +11,6 @@
11
11
  }
12
12
  .line {
13
13
  fill: none;
14
- stroke-width: 4;
15
14
  }
16
15
 
17
16
  .area-border-line {
@@ -55,15 +54,16 @@
55
54
  display: flex;
56
55
  height: 100%;
57
56
  }
57
+ .legend-block-centered {
58
+ justify-content: center;
59
+ }
58
60
  .legend-block-column {
59
61
  flex-direction: column;
60
62
  }
61
63
  .legend-block-row {
62
64
  flex-direction: row;
63
65
  flex-wrap: wrap;
64
- }
65
- .legend-block-centered {
66
- justify-content: center;
66
+ align-items: flex-end;
67
67
  }
68
68
  .legend-item {
69
69
  cursor: default;
@@ -103,6 +103,9 @@
103
103
  overflow: hidden;
104
104
  line-height: normal;
105
105
  }
106
+ .legend-2d-label {
107
+ font-weight: 500;
108
+ }
106
109
  .legend-label-nowrap {
107
110
  white-space: nowrap;
108
111
  text-overflow: ellipsis;
@@ -203,10 +206,10 @@
203
206
 
204
207
  /*========================================================================= Additional */
205
208
  .mdt-charts-axis .domain {
206
- stroke: #D2D2D2;
209
+ stroke: rgba(231, 229, 228, 0.8);
207
210
  }
208
211
  .mdt-charts-axis .tick line:first-of-type {
209
- stroke: #D2D2D2;
212
+ stroke: rgba(231, 229, 228, 0.8);
210
213
  }
211
214
 
212
215
  /* Aggregator */
@@ -229,8 +232,7 @@
229
232
 
230
233
  /* Grid */
231
234
  .grid-line {
232
- stroke: #D2D2D2;
233
- stroke-dasharray: 3;
235
+ stroke: rgba(231, 229, 228, 0.8);
234
236
  }
235
237
 
236
238
  /* Record overflow */
@@ -11,7 +11,6 @@
11
11
  }
12
12
  .line {
13
13
  fill: none;
14
- stroke-width: 4;
15
14
  }
16
15
 
17
16
  .area-border-line {
@@ -55,15 +54,16 @@
55
54
  display: flex;
56
55
  height: 100%;
57
56
  }
57
+ .legend-block-centered {
58
+ justify-content: center;
59
+ }
58
60
  .legend-block-column {
59
61
  flex-direction: column;
60
62
  }
61
63
  .legend-block-row {
62
64
  flex-direction: row;
63
65
  flex-wrap: wrap;
64
- }
65
- .legend-block-centered {
66
- justify-content: center;
66
+ align-items: flex-end;
67
67
  }
68
68
  .legend-item {
69
69
  cursor: default;
@@ -103,6 +103,9 @@
103
103
  overflow: hidden;
104
104
  line-height: normal;
105
105
  }
106
+ .legend-2d-label {
107
+ font-weight: 500;
108
+ }
106
109
  .legend-label-nowrap {
107
110
  white-space: nowrap;
108
111
  text-overflow: ellipsis;
@@ -203,10 +206,10 @@
203
206
 
204
207
  /*========================================================================= Additional */
205
208
  .mdt-charts-axis .domain {
206
- stroke: #D2D2D2;
209
+ stroke: rgba(231, 229, 228, 0.8);
207
210
  }
208
211
  .mdt-charts-axis .tick line:first-of-type {
209
- stroke: #D2D2D2;
212
+ stroke: rgba(231, 229, 228, 0.8);
210
213
  }
211
214
 
212
215
  /* Aggregator */
@@ -229,8 +232,7 @@
229
232
 
230
233
  /* Grid */
231
234
  .grid-line {
232
- stroke: #D2D2D2;
233
- stroke-dasharray: 3;
235
+ stroke: rgba(231, 229, 228, 0.8);
234
236
  }
235
237
 
236
238
  /* Record overflow */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdt-charts",
3
- "version": "1.22.0",
3
+ "version": "1.23.1",
4
4
  "description": "",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {