mdt-charts 1.12.2 → 1.12.6

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 (59) hide show
  1. package/lib/config/config.d.ts +19 -12
  2. package/lib/designer/designerConfig.d.ts +3 -5
  3. package/lib/engine/features/aggregator/aggregator.d.ts +9 -7
  4. package/lib/engine/features/aggregator/aggregator.js +51 -37
  5. package/lib/engine/features/gridLine/gidLineHelper.d.ts +2 -0
  6. package/lib/engine/features/gridLine/gidLineHelper.js +22 -0
  7. package/lib/engine/features/gridLine/gridLine.d.ts +5 -3
  8. package/lib/engine/features/gridLine/gridLine.js +16 -17
  9. package/lib/engine/features/scale/scale.d.ts +2 -0
  10. package/lib/engine/features/scale/scale.js +6 -3
  11. package/lib/engine/intervalNotation/intervalManager.js +1 -1
  12. package/lib/engine/polarNotation/donut/donut.js +1 -1
  13. package/lib/engine/polarNotation/polarManager.js +1 -1
  14. package/lib/engine/twoDimensionalNotation/area/areaHelper.js +2 -2
  15. package/lib/engine/twoDimensionalNotation/bar/bar.js +3 -3
  16. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +8 -8
  17. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +2 -2
  18. package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +4 -4
  19. package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
  20. package/lib/model/featuresModel/axisModel.d.ts +2 -1
  21. package/lib/model/featuresModel/axisModel.js +19 -5
  22. package/lib/model/featuresModel/legendModel/legendModel.js +3 -3
  23. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
  24. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +20 -0
  25. package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +31 -0
  26. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +19 -0
  27. package/lib/model/featuresModel/scaleModel/scaleModel.js +115 -0
  28. package/lib/model/featuresModel/scaleModel.d.ts +7 -6
  29. package/lib/model/featuresModel/scaleModel.js +19 -4
  30. package/lib/model/featuresModel/titleModel.js +4 -4
  31. package/lib/model/marginModel.d.ts +1 -3
  32. package/lib/model/marginModel.js +7 -29
  33. package/lib/model/model.d.ts +18 -6
  34. package/lib/model/modelBuilder.js +8 -9
  35. package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +5 -4
  36. package/lib/model/modelInstance/canvasModel/canvasModel.js +6 -2
  37. package/lib/model/modelInstance/canvasModel/marginModelService.d.ts +11 -0
  38. package/lib/model/modelInstance/canvasModel/marginModelService.js +26 -0
  39. package/lib/model/modelInstance/dataModel/dataModel.d.ts +14 -0
  40. package/lib/model/modelInstance/dataModel/dataModel.js +26 -0
  41. package/lib/model/modelInstance/dataModel/dataRepository.d.ts +12 -0
  42. package/lib/model/modelInstance/dataModel/dataRepository.js +20 -0
  43. package/lib/model/modelInstance/modelInstance.d.ts +3 -3
  44. package/lib/model/modelInstance/modelInstance.js +6 -4
  45. package/lib/model/notations/intervalModel.d.ts +2 -2
  46. package/lib/model/notations/intervalModel.js +1 -1
  47. package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +12 -0
  48. package/lib/model/notations/polar/donut/donutAggregatorService.js +25 -0
  49. package/lib/model/notations/polar/donut/donutModel.d.ts +10 -0
  50. package/lib/model/notations/polar/donut/donutModel.js +32 -0
  51. package/lib/model/notations/polar/donut/donutThicknessService.d.ts +9 -0
  52. package/lib/model/notations/polar/donut/donutThicknessService.js +30 -0
  53. package/lib/model/notations/polar/polarModel.d.ts +15 -0
  54. package/lib/model/notations/polar/polarModel.js +53 -0
  55. package/lib/model/notations/twoDimensionalModel.d.ts +6 -6
  56. package/lib/model/notations/twoDimensionalModel.js +9 -5
  57. package/lib/style/charts-main.css +6 -2
  58. package/lib/style/charts-main.less +6 -2
  59. package/package.json +1 -1
@@ -17,7 +17,7 @@ export interface MdtChartsDataSource {
17
17
  export declare type AxisLabelPosition = "straight" | "rotated";
18
18
  export interface MdtChartsConfig {
19
19
  canvas: ChartBlockCanvas;
20
- options: MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions | IntervalOptions;
20
+ options: MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions | MdtChartsIntervalOptions;
21
21
  }
22
22
  export interface ChartBlockCanvas {
23
23
  size: Size;
@@ -42,14 +42,14 @@ export interface MdtChartsTwoDimensionalOptions extends Options {
42
42
  type: '2d';
43
43
  axis: TwoDimensionalAxis;
44
44
  additionalElements: AdditionalElements;
45
- charts: TwoDimensionalChart[];
45
+ charts: MdtChartsTwoDimensionalChart[];
46
46
  orientation: ChartOrientation;
47
47
  }
48
48
  export interface MdtChartsPolarOptions extends Options {
49
49
  type: 'polar';
50
50
  chart: PolarChart;
51
51
  }
52
- export interface IntervalOptions extends Options {
52
+ export interface MdtChartsIntervalOptions extends Options {
53
53
  type: 'interval';
54
54
  axis: IntervalAxis;
55
55
  chart: IntervalChart;
@@ -68,10 +68,10 @@ export interface MdtChartsField {
68
68
  name: string;
69
69
  format: DataType;
70
70
  }
71
- export interface ValueField extends MdtChartsField {
71
+ export interface MdtChartsValueField extends MdtChartsField {
72
72
  title: string;
73
73
  }
74
- export interface TwoDimValueField extends ValueField {
74
+ export interface TwoDimValueField extends MdtChartsValueField {
75
75
  color?: string;
76
76
  }
77
77
  export interface TooltipOptions {
@@ -124,7 +124,7 @@ interface ChartSettings {
124
124
  interface Tooltip {
125
125
  show: boolean;
126
126
  }
127
- export interface TwoDimensionalChart extends ChartSettings {
127
+ export interface MdtChartsTwoDimensionalChart extends ChartSettings {
128
128
  type: TwoDimensionalChartType;
129
129
  data: TwoDimensionalChartData;
130
130
  embeddedLabels: EmbeddedLabelType;
@@ -134,7 +134,7 @@ export interface TwoDimensionalChart extends ChartSettings {
134
134
  export interface PolarChart extends ChartSettings {
135
135
  type: PolarChartType;
136
136
  data: PolarChartData;
137
- aggregator: MdtChartsPolarChartAggregator;
137
+ aggregator?: MdtChartsDonutAggregator;
138
138
  }
139
139
  export interface IntervalChart extends ChartSettings {
140
140
  type: IntervalChartType;
@@ -148,14 +148,21 @@ interface MarkersOptions {
148
148
  }
149
149
  export declare type MdtChartsColorField = string;
150
150
  export interface PolarChartData {
151
- valueField: ValueField;
151
+ valueField: MdtChartsValueField;
152
152
  colorField?: MdtChartsColorField;
153
153
  }
154
- export interface MdtChartsPolarChartAggregator {
155
- text: string;
154
+ export interface MdtChartsDonutAggregator {
155
+ content?: (model: MdtChartsAggregatorModel) => MdtChartsAggregatorContent;
156
+ }
157
+ export interface MdtChartsAggregatorModel {
158
+ data: MdtChartsDataRow[];
159
+ }
160
+ export interface MdtChartsAggregatorContent {
161
+ value: string | number;
162
+ title: string;
156
163
  }
157
164
  interface IntervalChartData {
158
- valueField1: ValueField;
159
- valueField2: ValueField;
165
+ valueField1: MdtChartsValueField;
166
+ valueField2: MdtChartsValueField;
160
167
  }
161
168
  export {};
@@ -4,7 +4,6 @@ export declare type DataTypeOptions = {
4
4
  };
5
5
  export declare type Formatter = (value: any, options?: any) => string;
6
6
  export declare type TooltipPosition = 'followCursor' | 'fixed';
7
- export declare type MdtChartsDonutThicknessUnit = "px" | "%";
8
7
  export interface DesignerConfig {
9
8
  canvas: Canvas;
10
9
  dataFormat: DataFormat;
@@ -50,10 +49,9 @@ export interface DonutOptionsCanvas {
50
49
  thickness: MdtChartsDonutThicknessOptions;
51
50
  }
52
51
  export interface MdtChartsDonutThicknessOptions {
53
- min: number;
54
- max: number;
55
- value: number;
56
- unit: MdtChartsDonutThicknessUnit;
52
+ min: number | string;
53
+ max: number | string;
54
+ value?: number | string;
57
55
  }
58
56
  interface DataFormat {
59
57
  formatters: Formatter;
@@ -1,23 +1,25 @@
1
- import { MdtChartsDataRow } from '../../../config/config';
2
1
  import { DataType } from '../../../designer/designerConfig';
3
- import { DonutChartAggreagorModel, Field } from "../../../model/model";
2
+ import { DonutAggregatorModel, Field } from "../../../model/model";
4
3
  import { Block } from "../../block/block";
5
4
  import { Translate } from "../../polarNotation/donut/donut";
6
5
  export interface AggregatorInfo {
7
6
  name: string;
8
- value: number;
7
+ value: number | string;
9
8
  format: DataType;
10
- margin: number;
9
+ marginInPercent: number;
11
10
  }
12
11
  export declare class Aggregator {
13
12
  static readonly aggregatorValueClass = "aggregator-value";
14
- private static readonly aggregatorNameClass;
13
+ private static readonly aggregatorTitleClass;
15
14
  private static readonly aggregatorObjectClass;
16
- static render(block: Block, data: MdtChartsDataRow[], valueField: Field, innerRadius: number, translate: Translate, fontSize: number, settings: DonutChartAggreagorModel): void;
17
- static update(block: Block, data: MdtChartsDataRow[], valueField: Field, settings: DonutChartAggreagorModel): void;
15
+ static render(block: Block, valueField: Field, innerRadius: number, translate: Translate, fontSize: number, settings: DonutAggregatorModel): void;
16
+ static update(block: Block, valueField: Field, settings: DonutAggregatorModel): void;
17
+ private static buildConfig;
18
18
  private static renderText;
19
+ private static formatValue;
19
20
  private static updateText;
20
21
  private static reCalculateAggregatorFontSize;
22
+ private static setTitleFontSize;
21
23
  private static renderAggregatorObject;
22
24
  private static renderWrapper;
23
25
  }
@@ -1,76 +1,90 @@
1
- import { sum } from 'd3-array';
2
1
  import { interpolateNumber } from 'd3-interpolate';
3
2
  import { Helper } from '../../helpers/helper';
4
3
  import { ValueFormatter } from '../../valueFormatter';
5
4
  export class Aggregator {
6
- static render(block, data, valueField, innerRadius, translate, fontSize, settings) {
7
- const aggregator = {
8
- name: settings.text,
9
- value: sum(data.map(d => d[valueField.name])),
10
- format: valueField.format,
11
- margin: settings.margin
12
- };
13
- this.renderText(block, innerRadius, aggregator, translate, fontSize);
5
+ static render(block, valueField, innerRadius, translate, fontSize, settings) {
6
+ const aggregator = this.buildConfig(valueField, settings);
7
+ this.renderText(block, innerRadius, aggregator, fontSize, translate);
8
+ }
9
+ static update(block, valueField, settings) {
10
+ const aggregator = this.buildConfig(valueField, settings);
11
+ this.updateText(block, aggregator, typeof aggregator.value === "string");
14
12
  }
15
- static update(block, data, valueField, settings) {
16
- const aggregator = {
17
- name: 'Сумма',
18
- value: sum(data.map(d => d[valueField.name])),
13
+ static buildConfig(valueField, settings) {
14
+ return {
15
+ name: settings.content.title,
16
+ value: settings.content.value,
19
17
  format: valueField.format,
20
- margin: settings.margin
18
+ marginInPercent: settings.margin
21
19
  };
22
- this.updateText(block, aggregator);
23
20
  }
24
- static renderText(block, innerRadius, aggregatorInfo, translate, fontSize) {
25
- if (innerRadius > 50) {
21
+ static renderText(block, innerRadius, aggregatorInfo, fontSize, translate) {
22
+ if (innerRadius > 30) {
26
23
  const aggregatorObject = this.renderAggregatorObject(block, innerRadius, translate);
27
24
  const wrapper = this.renderWrapper(aggregatorObject);
28
25
  wrapper
29
26
  .append('div')
30
27
  .attr('class', this.aggregatorValueClass)
28
+ .attr('title', this.formatValue(aggregatorInfo.format, aggregatorInfo.value))
31
29
  .style('text-align', 'center')
32
30
  .style('font-size', `${fontSize}px`)
33
- .text(ValueFormatter.formatField(aggregatorInfo.format, aggregatorInfo.value));
34
- wrapper
31
+ .text(this.formatValue(aggregatorInfo.format, aggregatorInfo.value));
32
+ const titleBlock = wrapper
35
33
  .append('div')
36
- .attr('class', this.aggregatorNameClass)
34
+ .attr('class', this.aggregatorTitleClass)
37
35
  .attr('title', aggregatorInfo.name)
38
36
  .style('text-align', 'center')
39
- .style('font-size', '18px')
40
37
  .text(aggregatorInfo.name);
41
- this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, aggregatorInfo.margin);
38
+ this.setTitleFontSize(titleBlock, innerRadius);
39
+ this.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, aggregatorInfo.marginInPercent);
42
40
  }
43
41
  }
44
- static updateText(block, newAggregator) {
42
+ static formatValue(format, value) {
43
+ if (typeof value === "string")
44
+ return value;
45
+ return ValueFormatter.formatField(format, value);
46
+ }
47
+ static updateText(block, newAggregator, withoutAnimation) {
45
48
  const aggregatorObject = block.getSvg()
46
49
  .select(`.${this.aggregatorObjectClass}`);
47
50
  const thisClass = this;
48
- block.getSvg()
49
- .select(`.${this.aggregatorValueClass}`)
51
+ const valueBlock = block.getSvg()
52
+ .select(`.${this.aggregatorValueClass}`);
53
+ if (withoutAnimation) {
54
+ valueBlock.text(this.formatValue(newAggregator.format, newAggregator.value));
55
+ return;
56
+ }
57
+ valueBlock
50
58
  .interrupt()
51
59
  .transition()
52
60
  .duration(block.transitionManager.durations.chartUpdate)
53
61
  .tween("text", function () {
62
+ const newValue = typeof newAggregator.value === "string" ? parseFloat(newAggregator.value) : newAggregator.value;
54
63
  const oldValue = Helper.parseFormattedToNumber(this.textContent, ',');
55
- const precision = Helper.calcDigitsAfterDot(newAggregator.value);
56
- const interpolateFunc = interpolateNumber(oldValue, newAggregator.value);
64
+ const precision = Helper.calcDigitsAfterDot(newValue);
65
+ const interpolateFunc = interpolateNumber(oldValue, newValue);
57
66
  return t => {
58
- this.textContent = ValueFormatter.formatField(newAggregator.format, (interpolateFunc(t)).toFixed(precision));
59
- thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.margin);
67
+ this.textContent = thisClass.formatValue(newAggregator.format, parseFloat((interpolateFunc(t)).toFixed(precision)));
68
+ thisClass.reCalculateAggregatorFontSize(aggregatorObject.node().getBoundingClientRect().width, block, newAggregator.marginInPercent);
60
69
  };
61
70
  });
62
71
  }
63
72
  static reCalculateAggregatorFontSize(wrapperSize, block, pad) {
64
- const aggreggatorValue = block.getSvg()
73
+ const aggregatorValue = block.getSvg()
65
74
  .select(`.${this.aggregatorValueClass}`);
66
- let fontSize = parseInt(aggreggatorValue.style('font-size'));
67
- while (aggreggatorValue.node().getBoundingClientRect().width > wrapperSize - pad * 2 && fontSize > 15) {
68
- aggreggatorValue.style('font-size', `${fontSize -= 2}px`);
69
- }
70
- while (aggreggatorValue.node().getBoundingClientRect().width < wrapperSize - pad * 2 && fontSize < 60) {
71
- aggreggatorValue.style('font-size', `${fontSize += 2}px`);
75
+ const sizeCoefficient = 0.25;
76
+ let fontSize = wrapperSize * sizeCoefficient;
77
+ aggregatorValue.style('font-size', `${fontSize}px`);
78
+ const margin = pad / 100 * wrapperSize;
79
+ while (aggregatorValue.node().getBoundingClientRect().width > wrapperSize - margin * 2 && fontSize > 12) {
80
+ aggregatorValue.style('font-size', `${fontSize -= 2}px`);
72
81
  }
73
82
  }
83
+ static setTitleFontSize(aggregatorTitle, innerRadius) {
84
+ const sizeCoefficient = 0.15;
85
+ aggregatorTitle.style('font-size', `${Math.round(innerRadius * sizeCoefficient)}px`);
86
+ aggregatorTitle.style('max-height', `${sizeCoefficient * 100}%`);
87
+ }
74
88
  static renderAggregatorObject(block, innerRadius, translate) {
75
89
  return block.getSvg()
76
90
  .append('foreignObject')
@@ -94,5 +108,5 @@ export class Aggregator {
94
108
  }
95
109
  }
96
110
  Aggregator.aggregatorValueClass = 'aggregator-value';
97
- Aggregator.aggregatorNameClass = 'aggregator-name';
111
+ Aggregator.aggregatorTitleClass = 'aggregator-name';
98
112
  Aggregator.aggregatorObjectClass = 'aggregator-object';
@@ -1,3 +1,4 @@
1
+ import { AxisScale } from "d3-axis";
1
2
  import { Size } from "../../../config/config";
2
3
  import { AxisModelOptions, BlockMargin } from "../../../model/model";
3
4
  export declare type GridLineType = 'key' | 'value';
@@ -10,4 +11,5 @@ export interface GridLineAttributes {
10
11
  export declare class GridLineHelper {
11
12
  static getGridLineLength(gridLineType: GridLineType, keyAxis: AxisModelOptions, valueAxis: AxisModelOptions, blockSize: Size, margin: BlockMargin): number;
12
13
  static getLineAttributes(axis: AxisModelOptions, lineLength: number): GridLineAttributes;
14
+ static getKeyLineAttributes(axis: AxisModelOptions, scaleValue: AxisScale<any>): GridLineAttributes;
13
15
  }
@@ -1,3 +1,4 @@
1
+ import { max, min } from "d3-array";
1
2
  export class GridLineHelper {
2
3
  static getGridLineLength(gridLineType, keyAxis, valueAxis, blockSize, margin) {
3
4
  let axis;
@@ -27,4 +28,25 @@ export class GridLineHelper {
27
28
  attributes.y2 = lineLength;
28
29
  return attributes;
29
30
  }
31
+ static getKeyLineAttributes(axis, scaleValue) {
32
+ const attributes = {
33
+ x1: 0,
34
+ y1: 0,
35
+ x2: 0,
36
+ y2: 0
37
+ };
38
+ const scaledStart = scaleValue(scaleValue.domain()[0]);
39
+ const scaledEnd = scaleValue(scaleValue.domain()[1]);
40
+ const minCoord = min([scaledStart, scaledEnd]) - scaleValue(0);
41
+ const maxCoord = max([scaledStart, scaledEnd]) - scaleValue(0);
42
+ if (axis.orient === 'left' || axis.orient === 'right') {
43
+ attributes.x1 = minCoord;
44
+ attributes.x2 = maxCoord;
45
+ }
46
+ else {
47
+ attributes.y1 = minCoord;
48
+ attributes.y2 = maxCoord;
49
+ }
50
+ return attributes;
51
+ }
30
52
  }
@@ -1,11 +1,13 @@
1
1
  import { Size } from "../../../config/config";
2
- import { BlockMargin, GridLineFlag, IAxisModel, ScaleKeyModel } from "../../../model/model";
2
+ import { BlockMargin, GridLineFlag, IAxisModel } from "../../../model/model";
3
3
  import { Block } from "../../block/block";
4
+ import { Scales } from "../scale/scale";
4
5
  export declare class GridLine {
5
6
  private static readonly gridLineClass;
6
- static render(block: Block, gridLineFlag: GridLineFlag, axes: IAxisModel, blockSize: Size, margin: BlockMargin, scaleKey: ScaleKeyModel): void;
7
- static update(block: Block, gridLineFlag: GridLineFlag, axes: IAxisModel, blockSize: Size, margin: BlockMargin, scaleKey: ScaleKeyModel): void;
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;
8
9
  private static renderLine;
9
10
  private static clear;
10
11
  private static removeGridLinesOnAxes;
12
+ private static rmGridLineOnTick;
11
13
  }
@@ -1,24 +1,20 @@
1
1
  import { GridLineHelper } from "./gidLineHelper";
2
2
  export class GridLine {
3
- static render(block, gridLineFlag, axes, blockSize, margin, scaleKey) {
3
+ static render(block, gridLineFlag, axes, blockSize, margin, scales) {
4
4
  if (gridLineFlag.value) {
5
5
  const lineLength = GridLineHelper.getGridLineLength('value', axes.key, axes.value, blockSize, margin);
6
6
  const lineAttributes = GridLineHelper.getLineAttributes(axes.value, lineLength);
7
7
  this.renderLine(block, axes.value, lineAttributes);
8
8
  }
9
9
  if (gridLineFlag.key) {
10
- const lineLength = GridLineHelper.getGridLineLength('key', axes.key, axes.value, blockSize, margin);
11
- const lineAttributes = GridLineHelper.getLineAttributes(axes.key, lineLength);
10
+ const lineAttributes = GridLineHelper.getKeyLineAttributes(axes.key, scales.value);
12
11
  this.renderLine(block, axes.key, lineAttributes);
13
12
  }
14
- if (scaleKey.type === 'point' && (gridLineFlag.key || gridLineFlag.value))
15
- this.removeGridLinesOnAxes(block, axes.key, axes.value, false);
16
- else if (gridLineFlag.key || gridLineFlag.value)
17
- this.removeGridLinesOnAxes(block, axes.key, axes.value, true);
13
+ this.removeGridLinesOnAxes(block, axes.key, axes.value, true);
18
14
  }
19
- static update(block, gridLineFlag, axes, blockSize, margin, scaleKey) {
15
+ static update(block, gridLineFlag, axes, blockSize, margin, scales) {
20
16
  this.clear(block, axes.key.cssClass, axes.value.cssClass);
21
- this.render(block, gridLineFlag, axes, blockSize, margin, scaleKey);
17
+ this.render(block, gridLineFlag, axes, blockSize, margin, scales);
22
18
  }
23
19
  static renderLine(block, axis, lineAttributes) {
24
20
  block
@@ -51,17 +47,20 @@ export class GridLine {
51
47
  tickOnValueAxisSelector = ':last-of-type';
52
48
  if (keyAxis.orient === 'bottom' || keyAxis.orient === 'right')
53
49
  tickOnKeyAxisSelector = ':last-of-type';
54
- block.getSvg()
50
+ const tickOnKey = block.getSvg()
55
51
  .select(`.${valueAxis.cssClass}`)
56
- .select(`g.tick${tickOnKeyAxisSelector}`)
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
57
62
  .select(`.${this.gridLineClass}`)
58
63
  .remove();
59
- if (!excludeKey)
60
- block.getSvg()
61
- .select(`.${keyAxis.cssClass}`)
62
- .select(`g.tick${tickOnValueAxisSelector}`)
63
- .select(`.${this.gridLineClass}`)
64
- .remove();
65
64
  }
66
65
  }
67
66
  GridLine.gridLineClass = 'grid-line';
@@ -1,3 +1,4 @@
1
+ import { ScaleLinear, ScaleTime } from 'd3-scale';
1
2
  import { AxisScale } from 'd3-axis';
2
3
  import { BarChartSettings, ScaleKeyModel, ScaleValueModel } from '../../../model/model';
3
4
  export interface Scales {
@@ -6,6 +7,7 @@ export interface Scales {
6
7
  }
7
8
  export declare class Scale {
8
9
  static getScales(scaleKey: ScaleKeyModel, scaleValue: ScaleValueModel, bandSettings: BarChartSettings): Scales;
10
+ static getScaleValue(scaleValue: ScaleValueModel): ScaleLinear<number, number, never> | ScaleTime<number, number, never>;
9
11
  static getScaleBandWidth(scale: AxisScale<any>): number;
10
12
  static getScaleStep(scale: AxisScale<any>): number;
11
13
  static getScaledValue(scale: AxisScale<any>, value: any): number;
@@ -9,11 +9,14 @@ export class Scale {
9
9
  scales.key = this.getScaleBand(scaleKey.domain, scaleKey.range, bandSettings, scaleKey.elementsAmount);
10
10
  else if (scaleKey.type === 'point')
11
11
  scales.key = this.getScalePoint(scaleKey.domain, scaleKey.range);
12
+ scales.value = this.getScaleValue(scaleValue);
13
+ return scales;
14
+ }
15
+ static getScaleValue(scaleValue) {
12
16
  if (scaleValue.type === 'linear')
13
- scales.value = this.getScaleLinear(scaleValue.domain, scaleValue.range);
17
+ return this.getScaleLinear(scaleValue.domain, scaleValue.range);
14
18
  else if (scaleValue.type === 'datetime')
15
- scales.value = this.getScaleTime(scaleValue.domain, scaleValue.range);
16
- return scales;
19
+ return this.getScaleTime(scaleValue.domain, scaleValue.range);
17
20
  }
18
21
  static getScaleBandWidth(scale) {
19
22
  if (scale.bandwidth && scale.bandwidth() !== 0) {
@@ -11,7 +11,7 @@ export class IntervalManager {
11
11
  block.renderSvg(model.blockCanvas.size);
12
12
  const scales = Scale.getScales(options.scale.key, options.scale.value, options.chartSettings.bar);
13
13
  Axis.render(block, scales, options.scale, options.axis, model.blockCanvas.size);
14
- GridLine.render(block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, options.scale.key);
14
+ GridLine.render(block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
15
15
  this.renderCharts(block, options.charts, scales, data, options.data, model.chartBlock.margin, options.axis.key.orient, options.chartSettings);
16
16
  Title.render(block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
17
17
  Legend.render(block, data, options, model);
@@ -11,7 +11,7 @@ export class Donut {
11
11
  const arcGenerator = DonutHelper.getArcGenerator(outerRadius, innerRadius);
12
12
  const pieGenerator = DonutHelper.getPieGenerator(chart.data.valueField.name, settings.padAngle);
13
13
  const translateAttr = DonutHelper.getTranslate(margin, blockSize);
14
- Aggregator.render(block, data, chart.data.valueField, innerRadius, translateAttr, thickness, settings.aggregator);
14
+ Aggregator.render(block, chart.data.valueField, innerRadius, translateAttr, thickness, settings.aggregator);
15
15
  const donutBlock = block.getSvg()
16
16
  .append('g')
17
17
  .attr('class', this.donutBlockClass)
@@ -39,7 +39,7 @@ export class PolarManager {
39
39
  Tooltip.render(block, model, data, model.otherComponents.tooltipBlock);
40
40
  block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options);
41
41
  });
42
- Aggregator.update(block, data[options.data.dataSource], options.charts[0].data.valueField, options.chartCanvas.aggregator);
42
+ Aggregator.update(block, options.charts[0].data.valueField, options.chartCanvas.aggregator);
43
43
  Legend.update(block, data, model);
44
44
  PolarRecordOverflowAlert.update(block, {
45
45
  hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
@@ -5,11 +5,11 @@ export class AreaHelper {
5
5
  if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top')
6
6
  return area()
7
7
  .x(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.left)
8
- .y0(d => this.getZeroCoordinate(keyAxisOrient, margin, blockSize))
8
+ .y0(d => scales.value(0) + margin.top)
9
9
  .y1(d => scales.value(d[valueFieldName]) + margin.top);
10
10
  if (keyAxisOrient === 'left' || keyAxisOrient === 'right')
11
11
  return area()
12
- .x0(d => this.getZeroCoordinate(keyAxisOrient, margin, blockSize))
12
+ .x0(d => scales.value(0) + margin.left)
13
13
  .x1(d => scales.value(d[valueFieldName]) + margin.left)
14
14
  .y(d => Scale.getScaledValue(scales.key, d[keyFieldName]) + margin.top);
15
15
  }
@@ -171,15 +171,15 @@ export class Bar {
171
171
  resolve('');
172
172
  return;
173
173
  }
174
- let barsHander = bars;
174
+ let barsHandler = bars;
175
175
  if (transitionDuration > 0) {
176
- barsHander = barsHander
176
+ barsHandler = barsHandler
177
177
  .interrupt()
178
178
  .transition()
179
179
  .duration(transitionDuration)
180
180
  .on('end', () => resolve(''));
181
181
  }
182
- barsHander.attr('x', d => barAttrs.x(d))
182
+ barsHandler.attr('x', d => barAttrs.x(d))
183
183
  .attr('y', d => barAttrs.y(d))
184
184
  .attr('height', d => barAttrs.height(d))
185
185
  .attr('width', d => barAttrs.width(d));
@@ -66,20 +66,20 @@ export class BarHelper {
66
66
  }
67
67
  static setGroupedBarAttrsByValue(attrs, keyAxisOrient, margin, scaleValue, valueFieldName, blockSize) {
68
68
  if (keyAxisOrient === 'top') {
69
- attrs.y = d => margin.top;
70
- attrs.height = d => Helper.getValueOrZero(scaleValue(d[valueFieldName]));
69
+ attrs.y = d => scaleValue(Math.min(d[valueFieldName], 0)) + margin.top;
70
+ attrs.height = d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
71
71
  }
72
72
  if (keyAxisOrient === 'bottom') {
73
- attrs.y = d => scaleValue(d[valueFieldName]) + margin.top;
74
- attrs.height = d => Helper.getValueOrZero(blockSize.height - margin.top - margin.bottom - scaleValue(d[valueFieldName]));
73
+ attrs.y = d => scaleValue(Math.max(d[valueFieldName], 0)) + margin.top;
74
+ attrs.height = d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
75
75
  }
76
76
  if (keyAxisOrient === 'left') {
77
- attrs.x = d => margin.left + 1;
78
- attrs.width = d => Helper.getValueOrZero(scaleValue(d[valueFieldName]));
77
+ attrs.x = d => scaleValue(Math.min(d[valueFieldName], 0)) + margin.left;
78
+ attrs.width = d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
79
79
  }
80
80
  if (keyAxisOrient === 'right') {
81
- attrs.x = d => scaleValue(d[valueFieldName]) + margin.left;
82
- attrs.width = d => Helper.getValueOrZero(blockSize.width - margin.left - margin.right - scaleValue(d[valueFieldName]));
81
+ attrs.x = d => scaleValue(Math.max(d[valueFieldName], 0)) + margin.left;
82
+ attrs.width = d => Math.abs(scaleValue(d[valueFieldName]) - scaleValue(0));
83
83
  }
84
84
  }
85
85
  static setSegmentedBarAttrsByValue(attrs, keyAxisOrient, scaleValue, margin, blockSize) {
@@ -20,7 +20,7 @@ export class TwoDimensionalManager {
20
20
  engine.block.scales = scales;
21
21
  engine.block.renderSvg(model.blockCanvas.size);
22
22
  Axis.render(engine.block, scales, options.scale, options.axis, model.blockCanvas.size);
23
- GridLine.render(engine.block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, options.scale.key);
23
+ GridLine.render(engine.block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
24
24
  this.renderCharts(engine.block, options.charts, scales, engine.data, options.data, model.chartBlock.margin, options.axis.key.orient, options.chartSettings.bar, model.blockCanvas.size);
25
25
  engine.block.filterEventManager.registerEventFor2D(scales.key, model.chartBlock.margin, model.blockCanvas.size, options);
26
26
  engine.block.filterEventManager.event2DUpdate(options);
@@ -49,7 +49,7 @@ export class TwoDimensionalManager {
49
49
  const keyDomainEquality = Helper.checkDomainsEquality(block.scales.key.domain(), scales.key.domain());
50
50
  block.scales = scales;
51
51
  Axis.update(block, scales, options.scale, options.axis, model.blockCanvas.size, keyDomainEquality);
52
- GridLine.update(block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, options.scale.key);
52
+ GridLine.update(block, options.additionalElements.gridLine.flag, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
53
53
  const promises = this.updateCharts(block, options.charts, scales, data, model.options.data, model.chartBlock.margin, options.axis.key.orient, model.blockCanvas.size, options.chartSettings.bar);
54
54
  Promise.all(promises)
55
55
  .then(() => {
@@ -1,16 +1,16 @@
1
- import { TwoDimensionalChart, TwoDimensionalChartType } from "../../config/config";
1
+ import { MdtChartsTwoDimensionalChart, TwoDimensionalChartType } from "../../config/config";
2
2
  import { ChartStyleConfig } from "../../designer/designerConfig";
3
3
  import { ChartStyle } from "../model";
4
4
  export declare class TwoDimensionalChartStyleModel {
5
5
  private charts;
6
6
  private chartStyleConfig;
7
7
  private service;
8
- constructor(charts: TwoDimensionalChart[], chartStyleConfig: ChartStyleConfig);
9
- getChartStyle(chart: TwoDimensionalChart, chartIndex: number): ChartStyle;
8
+ constructor(charts: MdtChartsTwoDimensionalChart[], chartStyleConfig: ChartStyleConfig);
9
+ getChartStyle(chart: MdtChartsTwoDimensionalChart, chartIndex: number): ChartStyle;
10
10
  private getChartsValueFieldsAmounts;
11
11
  }
12
12
  export declare class TwoDimensionalChartStyleService {
13
- getChartColors(chart: TwoDimensionalChart, styleConfig: ChartStyleConfig, chartsFieldsAmounts: number[], chartIndex: number): string[];
13
+ getChartColors(chart: MdtChartsTwoDimensionalChart, styleConfig: ChartStyleConfig, chartsFieldsAmounts: number[], chartIndex: number): string[];
14
14
  getChartOpacity(chartsLength: number, chartType: TwoDimensionalChartType, chartsValueFieldAmount: number, isChartSegmented: boolean): number;
15
15
  private generateNewChartColors;
16
16
  private isMoreThanOneValueFieldOnCanvas;
@@ -2,7 +2,7 @@ import { AxisModel } from "../featuresModel/axisModel";
2
2
  import { LegendCanvasModel } from "../featuresModel/legendModel/legendCanvasModel";
3
3
  import { LegendPolarMarginCalculator } from "../featuresModel/legendModel/polarMarginCalculator";
4
4
  import { ModelHelper } from "../modelHelper";
5
- import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polarModel";
5
+ import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polar/polarModel";
6
6
  import { DataManagerModelService } from "./dataManagerModelService";
7
7
  export class DataManagerModel {
8
8
  static getPreparedData(data, allowableKeys, config) {
@@ -9,7 +9,7 @@ export interface LabelSize {
9
9
  }
10
10
  export declare class AxisModel {
11
11
  private static service;
12
- static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings): AxisModelOptions;
12
+ static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings, getZeroCoordinate?: () => number): AxisModelOptions;
13
13
  static getValueAxis(orient: ChartOrientation, axisConfig: NumberAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel): AxisModelOptions;
14
14
  static getAxisLength(chartOrientation: ChartOrientation, canvasModel: CanvasModel): number;
15
15
  static getAxisOrient(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition): Orient;
@@ -17,4 +17,5 @@ export declare class AxisModel {
17
17
  static getAxisTranslateY(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, canvasModel: CanvasModel): number;
18
18
  static getKeyAxisLabelPosition(canvasModel: CanvasModel, scopedDataLength: number, axisConfig?: DiscreteAxisOptions): AxisLabelPosition;
19
19
  static getLabelSize(labelMaxWidth: number, labelTexts: any[]): LabelSize;
20
+ private static getKeyAxisTranslateModel;
20
21
  }
@@ -4,16 +4,14 @@ import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
4
4
  import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
5
5
  import { AxisModelService } from "./axisModelService";
6
6
  export class AxisModel {
7
- static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings) {
7
+ static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings, getZeroCoordinate) {
8
8
  const { charts, orientation, data: dataOptions } = options;
9
9
  const axisConfig = options.axis.key;
10
+ const translate = this.getKeyAxisTranslateModel(orientation, axisConfig.position, canvasModel, getZeroCoordinate);
10
11
  return {
11
12
  type: 'key',
12
13
  orient: AxisModel.getAxisOrient(AxisType.Key, orientation, axisConfig.position),
13
- translate: {
14
- translateX: AxisModel.getAxisTranslateX(AxisType.Key, orientation, axisConfig.position, canvasModel),
15
- translateY: AxisModel.getAxisTranslateY(AxisType.Key, orientation, axisConfig.position, canvasModel)
16
- },
14
+ translate,
17
15
  cssClass: 'key-axis',
18
16
  ticks: axisConfig.ticks,
19
17
  labels: {
@@ -109,5 +107,21 @@ export class AxisModel {
109
107
  textBlock.remove();
110
108
  return labelSize;
111
109
  }
110
+ static getKeyAxisTranslateModel(chartOrientation, axisPosition, canvasModel, getZeroCoordinate) {
111
+ let translateY;
112
+ let translateX;
113
+ if (chartOrientation === "vertical") {
114
+ translateY = getZeroCoordinate() + canvasModel.getMarginSide("top");
115
+ translateX = AxisModel.getAxisTranslateX(AxisType.Key, chartOrientation, axisPosition, canvasModel);
116
+ }
117
+ else {
118
+ translateX = getZeroCoordinate() + canvasModel.getMarginSide("left");
119
+ translateY = AxisModel.getAxisTranslateY(AxisType.Key, chartOrientation, axisPosition, canvasModel);
120
+ }
121
+ return {
122
+ translateX,
123
+ translateY
124
+ };
125
+ }
112
126
  }
113
127
  AxisModel.service = new AxisModelService();