mdt-charts 1.13.2 → 1.14.0

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 (82) hide show
  1. package/README.md +1 -189
  2. package/lib/config/config.d.ts +28 -6
  3. package/lib/designer/designerConfig.d.ts +20 -2
  4. package/lib/engine/block/blockSvg.d.ts +3 -1
  5. package/lib/engine/block/blockSvg.js +8 -3
  6. package/lib/engine/block/defs.d.ts +7 -0
  7. package/lib/engine/block/defs.js +18 -0
  8. package/lib/engine/cardsNotation/card/cardService.js +2 -2
  9. package/lib/engine/elementHighlighter/elementHighlighter.js +2 -1
  10. package/lib/engine/features/axis/axis.js +6 -3
  11. package/lib/engine/features/axis/axisHelper.d.ts +2 -2
  12. package/lib/engine/features/axis/axisHelper.js +6 -11
  13. package/lib/engine/features/axis/axisLabelDomHelper.js +9 -11
  14. package/lib/engine/features/legend/legend.d.ts +17 -12
  15. package/lib/engine/features/legend/legend.js +38 -22
  16. package/lib/engine/features/legend/legendDomHelper.d.ts +8 -4
  17. package/lib/engine/features/legend/legendDomHelper.js +20 -8
  18. package/lib/engine/features/legend/legendEventsManager.d.ts +2 -2
  19. package/lib/engine/features/legend/legendEventsManager.js +5 -5
  20. package/lib/engine/features/legend/legendHelper.d.ts +6 -3
  21. package/lib/engine/features/legend/legendHelper.js +5 -7
  22. package/lib/engine/features/legend/legendMarkerCreator.d.ts +21 -0
  23. package/lib/engine/features/legend/legendMarkerCreator.js +88 -0
  24. package/lib/engine/features/legend/legendWidthCalculator.d.ts +16 -0
  25. package/lib/engine/features/legend/legendWidthCalculator.js +119 -0
  26. package/lib/engine/features/tolltip/tooltip.js +2 -5
  27. package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +4 -4
  28. package/lib/engine/features/tolltip/tooltipDomHelper.js +13 -26
  29. package/lib/engine/helpers/domHelper.js +1 -1
  30. package/lib/engine/helpers/pipeline/Pipeline.d.ts +9 -0
  31. package/lib/engine/helpers/pipeline/Pipeline.js +37 -0
  32. package/lib/engine/intervalNotation/intervalManager.js +0 -2
  33. package/lib/engine/polarNotation/polarManager.js +3 -3
  34. package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +16 -13
  35. package/lib/engine/twoDimensionalNotation/bar/bar.js +30 -18
  36. package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +3 -0
  37. package/lib/engine/twoDimensionalNotation/bar/barHelper.js +9 -0
  38. package/lib/engine/twoDimensionalNotation/line/line.d.ts +22 -11
  39. package/lib/engine/twoDimensionalNotation/line/line.js +33 -17
  40. package/lib/engine/twoDimensionalNotation/line/lineGenerator.d.ts +15 -0
  41. package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +27 -0
  42. package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +18 -4
  43. package/lib/engine/twoDimensionalNotation/line/lineHelper.js +26 -16
  44. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +13 -12
  45. package/lib/model/featuresModel/axisModel.d.ts +2 -1
  46. package/lib/model/featuresModel/axisModel.js +11 -1
  47. package/lib/model/featuresModel/legendModel/legendModel.d.ts +2 -1
  48. package/lib/model/featuresModel/legendModel/legendModel.js +5 -1
  49. package/lib/model/featuresModel/otherComponents.d.ts +2 -1
  50. package/lib/model/featuresModel/otherComponents.js +1 -1
  51. package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +2 -1
  52. package/lib/model/featuresModel/scaleModel/scaleModel.js +4 -2
  53. package/lib/model/margin/marginModel.d.ts +6 -3
  54. package/lib/model/margin/marginModel.js +12 -8
  55. package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +6 -3
  56. package/lib/model/margin/twoDim/twoDimMarginModel.js +30 -29
  57. package/lib/model/model.d.ts +56 -4
  58. package/lib/model/model.js +7 -1
  59. package/lib/model/modelBuilder.js +11 -6
  60. package/lib/model/modelInstance/configReader.d.ts +19 -0
  61. package/lib/model/modelInstance/configReader.js +35 -0
  62. package/lib/model/modelInstance/dataModel/dataModel.d.ts +2 -2
  63. package/lib/model/modelInstance/dataModel/dataModel.js +0 -1
  64. package/lib/model/modelInstance/dataModel/dataRepository.d.ts +6 -2
  65. package/lib/model/modelInstance/dataModel/dataRepository.js +15 -2
  66. package/lib/model/modelInstance/modelInstance.d.ts +2 -1
  67. package/lib/model/modelInstance/modelInstance.js +6 -4
  68. package/lib/model/notations/cards/cardsChangeService.js +2 -2
  69. package/lib/model/notations/cards/cardsModelService.js +1 -1
  70. package/lib/model/notations/intervalModel.js +4 -3
  71. package/lib/model/notations/polar/polarModel.js +6 -1
  72. package/lib/model/notations/twoDimensional/styles.d.ts +6 -0
  73. package/lib/model/notations/twoDimensional/styles.js +41 -0
  74. package/lib/model/notations/twoDimensionalModel.d.ts +5 -5
  75. package/lib/model/notations/twoDimensionalModel.js +13 -8
  76. package/lib/style/charts-main.css +3 -0
  77. package/lib/style/charts-main.less +3 -0
  78. package/package.json +5 -5
  79. package/lib/engine/contentManager.d.ts +0 -9
  80. package/lib/engine/contentManager.js +0 -29
  81. package/lib/model/modelInstance/canvasModel/marginModelService.d.ts +0 -11
  82. package/lib/model/modelInstance/canvasModel/marginModelService.js +0 -26
package/README.md CHANGED
@@ -1,190 +1,2 @@
1
1
  # Charts
2
- **Demo**: https://vishulaknow.github.io/charts-demo/
3
- ## Установка
4
- ```
5
- npm install mdt-charts
6
- ```
7
- ## Импорт
8
- ```js
9
- import { Chart } from "mdt-charts"
10
- ```
11
- ## Импорт TypeScript интерфейсов
12
- ```ts
13
- import { Config, DesignerConfig } from "mdt-charts"
14
- ```
15
-
16
- ## Использование
17
-
18
- Для создания графика минимально требуется конфигуратор, конфигуратор дизайнера и данные.
19
-
20
- ```ts
21
- const chart = new Chart(config, designerConfig, data);
22
- ```
23
-
24
- ### Конфигуратор
25
-
26
- Пример настроек для построения простого барчарта:
27
-
28
- ```json
29
- {
30
- "canvas": {
31
- "class": "svg-chart outline",
32
- "size": {
33
- "width": 800,
34
- "height": 400
35
- }
36
- },
37
- "options": {
38
- "title": "Количество автомобилей",
39
- "type": "2d",
40
- "isSegmented": false,
41
- "axis": {
42
- "key": {
43
- "position": "end",
44
- "ticks": {
45
- "flag": false
46
- },
47
- "visibility": true
48
- },
49
- "value": {
50
- "domain": {
51
- "start": -1,
52
- "end": -1
53
- },
54
- "position": "start",
55
- "ticks": {
56
- "flag": false
57
- },
58
- "visibility": true
59
- }
60
- },
61
- "additionalElements": {
62
- "gridLine": {
63
- "flag": {
64
- "value": true,
65
- "key": true
66
- }
67
- }
68
- },
69
- "legend": {
70
- "show": true
71
- },
72
- "orientation": "vertical",
73
- "data": {
74
- "dataSource": "dataSet",
75
- "keyField": {
76
- "name": "brand",
77
- "format": "string"
78
- }
79
- },
80
- "selectable": true,
81
- "charts": [
82
- {
83
- "title": "Рост стоимости",
84
- "type": "bar",
85
- "data": {
86
- "valueFields": [
87
- {
88
- "name": "price",
89
- "format": "money",
90
- "title": "Заголовок"
91
- }
92
- ]
93
- },
94
- "tooltip": {
95
- "show": true
96
- },
97
- "markers": {
98
- "show": true
99
- },
100
- "embeddedLabels": "key"
101
- }
102
- ]
103
- }
104
- }
105
- ```
106
-
107
- ### Конфигуратор дизайнера
108
-
109
- Пример рекомендованных значений для конфигуратора дизайнера:
110
-
111
- ```ts
112
- const designerConfig: DesignerConfig = {
113
- canvas: {
114
- axisLabel: {
115
- maxSize: {
116
- main: 60
117
- }
118
- },
119
- chartBlockMargin: {
120
- top: 30,
121
- bottom: 20,
122
- left: 20,
123
- right: 20
124
- },
125
- legendBlock: {
126
- maxWidth: 200
127
- },
128
- chartOptions: {
129
- bar: {
130
- minBarWidth: 3,
131
- maxBarWidth: 30,
132
- groupMinDistance: 16,
133
- barDistance: 8,
134
- groupMaxDistance: 35
135
- },
136
- donut: {
137
- padAngle: 0,
138
- minThickness: 40,
139
- maxThickness: 60,
140
- aggregatorPad: 30
141
- }
142
- }
143
- },
144
- chartStyle: {
145
- baseColors: ['#209de3', '#ff3131', '#ffba00', '#20b078']
146
- },
147
- elementsOptions: {
148
- tooltip: {
149
- position: 'followCursor'
150
- }
151
- },
152
- dataFormat: {
153
- formatters: (value: any, options: { type?: string; title?: string; empty?: string; } = {}) => {
154
- var type = typeof value;
155
- if ((value === undefined || value === null || value === "") && type != "boolean" && options.type != "boolean")
156
- return value;
157
- if (type == "boolean" || options.type == "boolean") {
158
- return value.toString();
159
- }
160
- if (value instanceof Date) {
161
- return value.getFullYear() + '-' + (value.getMonth() + 1) + '-' + value.getDate() + ' ' + value.getHours() + ':' + value.getMinutes()
162
- }
163
- if (options.type === "markdown") {
164
- return value.toString();
165
- }
166
- if ((options.type === "money" || options.type === "number")) {
167
- return Intl.NumberFormat('ru-Ru', { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(value);
168
- }
169
- return value;
170
- }
171
- }
172
- }
173
- ```
174
-
175
- ## Для разработчиков
176
-
177
- Для загрузки всех зависимостей использйте скрипт:
178
-
179
- ```
180
- npm install
181
- ```
182
-
183
-
184
- Для сборки плейграунда необходимо запустить скрипт:
185
-
186
- ```
187
- npm run dev
188
- ```
189
-
190
- Полученные файлы будут расположены в папке dist.
2
+ **Demo**: https://vishulaknow.github.io/charts-demo/
@@ -123,11 +123,16 @@ interface AxisTicks {
123
123
  }
124
124
  export interface NumberAxisOptions extends AxisOptions {
125
125
  domain: NumberDomain;
126
+ labels?: NumberAxisLabel;
126
127
  }
127
128
  export interface NumberDomain {
128
129
  start: number;
129
130
  end: number;
130
131
  }
132
+ export interface NumberAxisLabel {
133
+ format: (v: number) => string;
134
+ }
135
+ export declare type AxisLabelFormatter = (v: number) => string;
131
136
  export interface DiscreteAxisOptions extends AxisOptions {
132
137
  labels?: MdtChartsDiscreteAxisLabel;
133
138
  }
@@ -140,10 +145,7 @@ export interface IntervalAxis {
140
145
  }
141
146
  interface DateAxisOptions extends AxisOptions {
142
147
  }
143
- export interface MdtChartsCardValue {
144
- field: string;
145
- dataType?: DataType;
146
- }
148
+ export declare type MdtChartsCardValue = MdtChartsField;
147
149
  export interface MdtChartsCardsChange {
148
150
  value: MdtChartsCardValue;
149
151
  color?: MdtChartsColorRangeItem[];
@@ -163,12 +165,32 @@ interface ChartSettings {
163
165
  interface Tooltip {
164
166
  show: boolean;
165
167
  }
166
- export interface MdtChartsTwoDimensionalChart extends ChartSettings {
168
+ interface MdtChartsLineLikeChart {
169
+ markers: MarkersOptions;
170
+ lineStyles?: MdtChartsLineLikeChartStyles;
171
+ }
172
+ export interface MdtChartsLineLikeChartStyles {
173
+ dash?: MdtChartsLineLikeChartDashedStyles;
174
+ }
175
+ export interface MdtChartsLineLikeChartDashedStyles {
176
+ on: boolean;
177
+ dashSize?: number;
178
+ gapSize?: number;
179
+ }
180
+ interface MdtChartsBarLikeChart {
181
+ barStyles?: MdtChartsBarLikeChartStyles;
182
+ }
183
+ interface MdtChartsBarLikeChartStyles {
184
+ hatch?: MdtChartsBarLikeChartHatchedStyles;
185
+ }
186
+ interface MdtChartsBarLikeChartHatchedStyles {
187
+ on: boolean;
188
+ }
189
+ export interface MdtChartsTwoDimensionalChart extends ChartSettings, MdtChartsLineLikeChart, MdtChartsBarLikeChart {
167
190
  type: TwoDimensionalChartType;
168
191
  data: TwoDimensionalChartData;
169
192
  embeddedLabels: EmbeddedLabelType;
170
193
  isSegmented: boolean;
171
- markers: MarkersOptions;
172
194
  }
173
195
  export interface PolarChart extends ChartSettings {
174
196
  type: PolarChartType;
@@ -2,7 +2,11 @@ export declare type DataType = string;
2
2
  export declare type DataTypeOptions = {
3
3
  [option: string]: any;
4
4
  };
5
- export declare type Formatter = (value: any, options?: any) => string;
5
+ export declare type Formatter = (value: any, options?: {
6
+ type?: string;
7
+ title?: string;
8
+ empty?: string;
9
+ }) => string;
6
10
  export declare type TooltipPosition = 'followCursor' | 'fixed';
7
11
  export interface DesignerConfig {
8
12
  canvas: Canvas;
@@ -31,10 +35,15 @@ interface BlockMargin {
31
35
  }
32
36
  export interface LegendBlockCanvas {
33
37
  maxWidth: number | string;
38
+ static?: StaticLegendBlockCanvas;
34
39
  }
35
- interface ChartOptionsCanvas {
40
+ export interface StaticLegendBlockCanvas {
41
+ maxLinesAmount: number;
42
+ }
43
+ export interface ChartOptionsCanvas {
36
44
  bar: BarOptionsCanvas;
37
45
  donut: DonutOptionsCanvas;
46
+ line?: LineOptionsCanvas;
38
47
  }
39
48
  export interface BarOptionsCanvas {
40
49
  minBarWidth: number;
@@ -53,6 +62,15 @@ export interface MdtChartsDonutThicknessOptions {
53
62
  max: number | string;
54
63
  value?: number | string;
55
64
  }
65
+ interface LineOptionsCanvas {
66
+ shape?: MdtChartsLineLikeChartShape;
67
+ }
68
+ export declare type MdtChartsLineLikeChartCurveType = "monotone" | "none";
69
+ export interface MdtChartsLineLikeChartShape {
70
+ curve?: {
71
+ type?: MdtChartsLineLikeChartCurveType;
72
+ };
73
+ }
56
74
  interface DataFormat {
57
75
  formatters: Formatter;
58
76
  }
@@ -9,6 +9,7 @@ export declare class BlockSvg {
9
9
  private parentBlockId;
10
10
  private parent;
11
11
  private svgCssClasses;
12
+ private hatchPatternDef;
12
13
  private readonly chartBlockClass;
13
14
  private readonly chartGroupClass;
14
15
  constructor(options: BlockSvgOptions);
@@ -21,6 +22,7 @@ export declare class BlockSvg {
21
22
  getClipPathId(): string;
22
23
  renderChartClipPath(margin: BlockMargin, blockSize: Size): void;
23
24
  updateChartClipPath(margin: BlockMargin, blockSize: Size): void;
24
- private renderDefs;
25
+ renderBarHatchPattern(): void;
26
+ private ensureDefsRendered;
25
27
  }
26
28
  export {};
@@ -1,7 +1,9 @@
1
1
  import { NamesHelper } from "../helpers/namesHelper";
2
2
  import { BlockHelper } from "./blockHelper";
3
+ import { HatchPatternDef } from "./defs";
3
4
  export class BlockSvg {
4
5
  constructor(options) {
6
+ this.hatchPatternDef = new HatchPatternDef();
5
7
  this.chartBlockClass = 'chart-block';
6
8
  this.chartGroupClass = 'chart-group';
7
9
  this.svgCssClasses = options.svgCssClasses;
@@ -41,7 +43,7 @@ export class BlockSvg {
41
43
  }
42
44
  renderChartClipPath(margin, blockSize) {
43
45
  const attributes = BlockHelper.getClipPathAttributes(blockSize, margin);
44
- this.renderDefs()
46
+ this.ensureDefsRendered()
45
47
  .append('clipPath')
46
48
  .attr('id', this.getClipPathId())
47
49
  .append('rect')
@@ -52,7 +54,7 @@ export class BlockSvg {
52
54
  }
53
55
  updateChartClipPath(margin, blockSize) {
54
56
  const attributes = BlockHelper.getClipPathAttributes(blockSize, margin);
55
- this.renderDefs()
57
+ this.ensureDefsRendered()
56
58
  .select('clipPath')
57
59
  .select('rect')
58
60
  .attr('x', attributes.x)
@@ -60,7 +62,10 @@ export class BlockSvg {
60
62
  .attr('width', attributes.width)
61
63
  .attr('height', attributes.height);
62
64
  }
63
- renderDefs() {
65
+ renderBarHatchPattern() {
66
+ this.hatchPatternDef.appendToDefsBlock(this.ensureDefsRendered());
67
+ }
68
+ ensureDefsRendered() {
64
69
  let defs = this.getBlock().select('defs');
65
70
  if (defs.empty())
66
71
  defs = this.getBlock().append('defs');
@@ -0,0 +1,7 @@
1
+ import { Selection } from "d3-selection";
2
+ export declare class HatchPatternDef {
3
+ static getMaskValue(): string;
4
+ private static readonly hatchMaskUrl;
5
+ private readonly hatchPattern;
6
+ appendToDefsBlock(defsSelection: Selection<SVGDefsElement, unknown, HTMLElement, unknown>): void;
7
+ }
@@ -0,0 +1,18 @@
1
+ export class HatchPatternDef {
2
+ constructor() {
3
+ this.hatchPattern = `
4
+ <pattern id="hatch-pattern" width="4" height="4" patternUnits="userSpaceOnUse"patternTransform="rotate(45)">
5
+ <rect width="2" height="4" transform="translate(0,0)" fill="white"></rect>
6
+ </pattern>
7
+ <mask id="${HatchPatternDef.hatchMaskUrl}">
8
+ <rect x="0" y="0" width="100%" height="100%" fill="url(#hatch-pattern)" />
9
+ </mask>`;
10
+ }
11
+ static getMaskValue() {
12
+ return `url(#${this.hatchMaskUrl})`;
13
+ }
14
+ appendToDefsBlock(defsSelection) {
15
+ defsSelection.append("g").html(this.hatchPattern);
16
+ }
17
+ }
18
+ HatchPatternDef.hatchMaskUrl = "hatch-mask";
@@ -5,8 +5,8 @@ export class CardServiceClass {
5
5
  return this.getValueContentFromRow(valueOptions, dataRow);
6
6
  }
7
7
  getValueContentFromRow(valueOptions, dataRow) {
8
- const value = dataRow[valueOptions.field];
9
- return ValueFormatter.formatField(valueOptions.dataType, value);
8
+ const value = dataRow[valueOptions.name];
9
+ return ValueFormatter.formatField(valueOptions.format, value);
10
10
  }
11
11
  }
12
12
  export const CardService = new CardServiceClass();
@@ -7,6 +7,7 @@ import { Donut } from '../polarNotation/donut/donut';
7
7
  import { MarkDot } from '../features/markDots/markDot';
8
8
  import { Helper } from '../helpers/helper';
9
9
  import * as chroma from 'chroma-js';
10
+ import { NamesHelper } from '../helpers/namesHelper';
10
11
  export class ElementHighlighter {
11
12
  static toggleActivityStyle(elementSelection, isActive) {
12
13
  elementSelection.classed(this.inactiveElemClass, !isActive);
@@ -195,4 +196,4 @@ export class ElementHighlighter {
195
196
  });
196
197
  }
197
198
  }
198
- ElementHighlighter.inactiveElemClass = 'charts-opacity-inactive';
199
+ ElementHighlighter.inactiveElemClass = NamesHelper.getClassName("opacity-inactive");
@@ -29,7 +29,7 @@ export class Axis {
29
29
  .select(`g.${axisCssClass}`);
30
30
  }
31
31
  static renderAxis(block, scale, scaleOptions, axisOptions, blockSize) {
32
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scale, scaleOptions);
32
+ const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scale);
33
33
  if (axisOptions.type === 'value' && (scaleOptions.type === 'linear' || scaleOptions.type === 'datetime'))
34
34
  AxisHelper.setLabelsSettings(axisGenerator, scale.range(), scaleOptions);
35
35
  const axisElement = block.getSvg()
@@ -50,11 +50,14 @@ export class Axis {
50
50
  AxisLabelHelper.alignLabelsInKeyAxis(axisOptions, axisElement);
51
51
  AxisLabelsEventManager.setHoverEvents(block, axisElement);
52
52
  }
53
+ if (axisOptions.type === "value") {
54
+ AxisLabelHelper.cropLabels(block, scale, scaleOptions, axisOptions, blockSize);
55
+ }
53
56
  if (axisOptions.labels.defaultTooltip)
54
57
  AxisLabelHelper.setTitles(axisElement);
55
58
  }
56
59
  static updateValueAxis(block, scaleValue, scaleOptions, axisOptions) {
57
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleValue, scaleOptions);
60
+ const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleValue);
58
61
  AxisHelper.setLabelsSettings(axisGenerator, scaleValue.range(), scaleOptions);
59
62
  const axisElement = block.getSvg().select(`g.${axisOptions.cssClass}`);
60
63
  AxisDomHelper.updateAxisElement(axisGenerator, axisElement, axisOptions.translate, block.transitionManager.durations.chartUpdate)
@@ -64,7 +67,7 @@ export class Axis {
64
67
  });
65
68
  }
66
69
  static updateKeyAxis(block, scaleKey, scaleOptions, axisOptions, blockSize, domainNotUpdated) {
67
- const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleKey, scaleOptions);
70
+ const axisGenerator = AxisHelper.getBaseAxisGenerator(axisOptions, scaleKey);
68
71
  if (axisOptions.labels.position === 'rotated') { // Задание координат для перевернутых лейблов (если до этого они не были перевернуты)
69
72
  if (axisOptions.orient === 'bottom')
70
73
  axisGenerator.tickPadding(-4);
@@ -1,9 +1,9 @@
1
1
  import { AxisScale, Axis as IAxis } from 'd3-axis';
2
- import { AxisModelOptions, Orient, ScaleKeyModel, ScaleValueModel } from "../../../model/model";
2
+ import { AxisModelOptions, Orient, ScaleValueModel } from "../../../model/model";
3
3
  export declare class AxisHelper {
4
4
  static getAxisByOrient(orient: Orient, scale: AxisScale<any>): IAxis<any>;
5
5
  static setLabelsSettings(axisGenerator: IAxis<any>, range: number[], scaleOptions: ScaleValueModel): void;
6
- static getBaseAxisGenerator(axisOptions: AxisModelOptions, scale: AxisScale<any>, scaleOptions: ScaleKeyModel | ScaleValueModel): IAxis<any>;
6
+ static getBaseAxisGenerator(axisOptions: AxisModelOptions, scale: AxisScale<any>): IAxis<any>;
7
7
  private static removeTicks;
8
8
  private static setNumTickFormat;
9
9
  }
@@ -2,7 +2,7 @@ import { axisTop, axisBottom, axisLeft, axisRight } from 'd3-axis';
2
2
  import { max, min } from 'd3-array';
3
3
  import { format } from 'd3-format';
4
4
  import { AxisLabelHelper } from './axisLabelDomHelper';
5
- const MINIMAL_STEP_SIZE = 40;
5
+ const MINIMAL_STEP_SIZE = 60;
6
6
  export class AxisHelper {
7
7
  static getAxisByOrient(orient, scale) {
8
8
  if (orient === 'top')
@@ -28,26 +28,21 @@ export class AxisHelper {
28
28
  }
29
29
  }
30
30
  if (scaleOptions.type === 'linear') {
31
- axisGenerator.scale().ticks(ticksAmount).forEach((value) => {
32
- if (format('~s')(value).indexOf('.') !== -1) {
33
- this.setNumTickFormat(axisGenerator, '.2s');
34
- }
35
- });
31
+ this.setNumTickFormat(axisGenerator, scaleOptions.formatter);
36
32
  }
37
33
  }
38
- static getBaseAxisGenerator(axisOptions, scale, scaleOptions) {
34
+ static getBaseAxisGenerator(axisOptions, scale) {
39
35
  const axisGenerator = AxisHelper.getAxisByOrient(axisOptions.orient, scale);
40
36
  if (!axisOptions.ticks.flag)
41
37
  this.removeTicks(axisGenerator);
42
38
  AxisLabelHelper.setAxisLabelPaddingByOrient(axisGenerator, axisOptions);
43
- if (scaleOptions.type === 'linear')
44
- this.setNumTickFormat(axisGenerator);
45
39
  return axisGenerator;
46
40
  }
47
41
  static removeTicks(axis) {
48
42
  axis.tickSize(0);
49
43
  }
50
- static setNumTickFormat(axis, formatName = '~s') {
51
- axis.tickFormat(format(formatName));
44
+ static setNumTickFormat(axis, formatter) {
45
+ const defaultFormatter = format('~s');
46
+ axis.tickFormat(formatter !== null && formatter !== void 0 ? formatter : defaultFormatter);
52
47
  }
53
48
  }
@@ -38,17 +38,15 @@ export class AxisLabelHelper {
38
38
  }
39
39
  }
40
40
  static cropLabels(block, scale, scaleOptions, axisOptions, blockSize) {
41
- if (scaleOptions.type === 'point' || scaleOptions.type === 'band') {
42
- const axisTextBlocks = block.getSvg().select(`.${axisOptions.cssClass}`).selectAll('text');
43
- let maxLabelSize;
44
- if ((axisOptions.orient === 'left' || axisOptions.orient === 'right') || (axisOptions.type === 'key' && axisOptions.labels.position === 'rotated'))
45
- maxLabelSize = axisOptions.labels.maxSize;
46
- else
47
- maxLabelSize = scale.step() - 4;
48
- DomHelper.cropSvgLabels(axisTextBlocks, maxLabelSize);
49
- if (scaleOptions.type === 'point' && axisOptions.labels.position === 'straight' && (axisOptions.orient === 'top' || axisOptions.orient === 'bottom')) {
50
- this.cropAndAlignExtremeLabels(block, maxLabelSize, axisOptions, blockSize);
51
- }
41
+ const axisTextBlocks = block.getSvg().select(`.${axisOptions.cssClass}`).selectAll('text');
42
+ let maxLabelSize;
43
+ if ((axisOptions.orient === 'left' || axisOptions.orient === 'right') || (axisOptions.type === 'key' && axisOptions.labels.position === 'rotated'))
44
+ maxLabelSize = axisOptions.labels.maxSize;
45
+ else
46
+ maxLabelSize = scale.step() - 4;
47
+ DomHelper.cropSvgLabels(axisTextBlocks, maxLabelSize);
48
+ if (scaleOptions.type === 'point' && axisOptions.labels.position === 'straight' && (axisOptions.orient === 'top' || axisOptions.orient === 'bottom')) {
49
+ this.cropAndAlignExtremeLabels(block, maxLabelSize, axisOptions, blockSize);
52
50
  }
53
51
  }
54
52
  static hideLabels(axisElement) {
@@ -1,11 +1,13 @@
1
1
  import { BaseType, Selection } from "d3-selection";
2
2
  import { MdtChartsDataSource } from "../../../config/config";
3
- import { IntervalOptionsModel, Model, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
3
+ import { IntervalOptionsModel, LegendBlockModel, Model, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
4
4
  import { Block } from "../../block/block";
5
5
  import { SelectionCondition } from "../../helpers/domHelper";
6
+ import { ChartLegendEngineModel } from "./legendHelper";
6
7
  export interface LegendContentRenderingOptions {
7
8
  wrapperClasses: string[];
8
9
  shouldCropLabels: boolean;
10
+ blockModel: LegendBlockModel;
9
11
  itemsOptions: {
10
12
  wrapperClasses: string[];
11
13
  markerClass: string;
@@ -13,19 +15,22 @@ export interface LegendContentRenderingOptions {
13
15
  };
14
16
  }
15
17
  export declare class Legend {
18
+ static get(): Legend;
16
19
  static readonly objectClass = "legend-object";
17
20
  static readonly labelClass = "legend-label";
18
21
  static readonly itemClass = "legend-item";
19
- static readonly markerClass = "legend-circle";
22
+ static readonly markerClass = "legend-marker";
23
+ static readonly markerCircle = "legend-circle";
20
24
  static readonly legendBlockClass = "legend-block";
21
- static render(block: Block, data: MdtChartsDataSource, options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel, model: Model): void;
22
- static update(block: Block, data: MdtChartsDataSource, model: Model): void;
23
- static updateColors(block: Block, options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel): void;
24
- static getItemsByKeys(block: Block, keys: string[], condition?: SelectionCondition): Selection<HTMLDivElement, string, BaseType, unknown>;
25
- private static setContent;
26
- private static renderObject;
27
- private static renderContent;
28
- private static getObject;
29
- private static removeContent;
30
- private static fillCoordinate;
25
+ private readonly markerCreator;
26
+ render(block: Block, data: MdtChartsDataSource, options: TwoDimensionalOptionsModel | PolarOptionsModel, model: Model): void;
27
+ update(block: Block, data: MdtChartsDataSource, model: Model<TwoDimensionalOptionsModel | PolarOptionsModel>): void;
28
+ updateColors(block: Block, options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel): void;
29
+ static getItemsByKeys(block: Block, keys: string[], condition?: SelectionCondition): Selection<HTMLDivElement, ChartLegendEngineModel, BaseType, unknown>;
30
+ private setContent;
31
+ private renderObject;
32
+ private renderContent;
33
+ private getObject;
34
+ private removeContent;
35
+ private fillCoordinate;
31
36
  }