mdt-charts 1.11.0 → 1.12.2

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 (55) hide show
  1. package/lib/config/config.d.ts +9 -3
  2. package/lib/engine/features/legend/legend.d.ts +10 -1
  3. package/lib/engine/features/legend/legend.js +10 -22
  4. package/lib/engine/features/legend/legendHelper.d.ts +4 -5
  5. package/lib/engine/features/legend/legendHelper.js +19 -23
  6. package/lib/engine/features/legend/legendHelperService.d.ts +12 -0
  7. package/lib/engine/features/legend/legendHelperService.js +30 -0
  8. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.d.ts +28 -0
  9. package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +50 -0
  10. package/lib/engine/intervalNotation/intervalManager.js +0 -3
  11. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +15 -0
  12. package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +40 -0
  13. package/lib/engine/polarNotation/polarManager.js +10 -5
  14. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.d.ts +15 -0
  15. package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +32 -0
  16. package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +9 -3
  17. package/lib/model/{dataManagerModel.d.ts → dataManagerModel/dataManagerModel.d.ts} +18 -7
  18. package/lib/model/{dataManagerModel.js → dataManagerModel/dataManagerModel.js} +51 -45
  19. package/lib/model/dataManagerModel/dataManagerModelService.d.ts +5 -0
  20. package/lib/model/dataManagerModel/dataManagerModelService.js +28 -0
  21. package/lib/model/featuresModel/axisModel.d.ts +5 -4
  22. package/lib/model/featuresModel/axisModel.js +14 -12
  23. package/lib/model/featuresModel/axisModelService.d.ts +4 -0
  24. package/lib/model/featuresModel/axisModelService.js +11 -0
  25. package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +4 -2
  26. package/lib/model/featuresModel/legendModel/legendCanvasModel.js +42 -29
  27. package/lib/model/featuresModel/legendModel/legendModel.d.ts +1 -4
  28. package/lib/model/featuresModel/legendModel/legendModel.js +15 -16
  29. package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +11 -0
  30. package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +42 -0
  31. package/lib/model/featuresModel/scaleModel.d.ts +3 -3
  32. package/lib/model/featuresModel/titleModel.js +1 -1
  33. package/lib/model/marginModel.d.ts +3 -2
  34. package/lib/model/marginModel.js +11 -7
  35. package/lib/model/model.d.ts +1 -2
  36. package/lib/model/modelBuilder.js +8 -8
  37. package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +2 -0
  38. package/lib/model/modelInstance/canvasModel/canvasModel.js +2 -0
  39. package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +7 -0
  40. package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +13 -0
  41. package/lib/model/modelInstance/dataModel.d.ts +11 -0
  42. package/lib/model/modelInstance/dataModel.js +23 -0
  43. package/lib/model/modelInstance/modelInstance.d.ts +3 -0
  44. package/lib/model/modelInstance/modelInstance.js +7 -1
  45. package/lib/model/notations/intervalModel.js +2 -3
  46. package/lib/model/notations/polarModel.d.ts +9 -3
  47. package/lib/model/notations/polarModel.js +24 -2
  48. package/lib/model/notations/twoDimensionalModel.d.ts +2 -2
  49. package/lib/model/notations/twoDimensionalModel.js +2 -3
  50. package/lib/style/charts-main.css +24 -7
  51. package/lib/style/charts-main.less +24 -7
  52. package/package.json +2 -2
  53. package/tsconfig.production.json +23 -0
  54. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
  55. package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
@@ -1,8 +1,9 @@
1
1
  import { AxisModel } from "./featuresModel/axisModel";
2
- import { DataManagerModel } from "./dataManagerModel";
3
- import { LegendModel, MIN_DONUT_BLOCK_SIZE } from "./featuresModel/legendModel/legendModel";
2
+ import { DataManagerModel } from "./dataManagerModel/dataManagerModel";
3
+ import { LegendModel } from "./featuresModel/legendModel/legendModel";
4
4
  import { AxisType } from "./modelBuilder";
5
5
  import { TwoDimensionalModel } from "./notations/twoDimensionalModel";
6
+ import { PolarModel } from "./notations/polarModel";
6
7
  export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
7
8
  export const AXIS_VERTICAL_LABEL_PADDING = 10;
8
9
  export class MarginModel {
@@ -25,10 +26,9 @@ export class MarginModel {
25
26
  }
26
27
  static recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, legendBlockModel, dataScope, options) {
27
28
  const canvasModel = modelInstance.canvasModel;
28
- let position = LegendModel.getLegendModel(config.options.type, config.options.legend.show, modelInstance.canvasModel).position;
29
+ let position = canvasModel.legendCanvas.getPosition();
29
30
  if (position !== 'off') {
30
- if (position === 'right' && canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE)
31
- position = 'bottom';
31
+ position = PolarModel.getLegendPositionByBlockSize(canvasModel); // reset position
32
32
  this.clearMarginByLegendBlockPosition(canvasModel, legendBlockModel);
33
33
  let allowableKeys = [...dataScope.allowableKeys];
34
34
  if (dataScope.hidedRecordsAmount !== 0 && position === 'bottom')
@@ -42,7 +42,7 @@ export class MarginModel {
42
42
  static recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope) {
43
43
  if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
44
44
  const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
45
- const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length);
45
+ const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length, config.options.axis.key);
46
46
  const marginOrient = config.options.axis.key.position === 'end' ? 'bottom' : 'top';
47
47
  if (axisConfig === 'rotated')
48
48
  modelInstance.canvasModel.setMarginSide(marginOrient, modelInstance.canvasModel.getMarginSide(marginOrient) + (axisLabelSize.width - axisLabelSize.height));
@@ -80,8 +80,12 @@ export class MarginModel {
80
80
  }
81
81
  }
82
82
  static recalcMarginWithLegend(modelInstance, config, legendMaxWidth, legendBlockModel, data) {
83
+ if (config.options.type === "polar") {
84
+ return;
85
+ }
83
86
  const canvasModel = modelInstance.canvasModel;
84
87
  const legendPosition = LegendModel.getLegendModel(config.options.type, config.options.legend.show, modelInstance.canvasModel).position;
88
+ modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
85
89
  if (legendPosition !== 'off') {
86
90
  const legendItemsContent = this.getLegendItemsContent(config.options, data);
87
91
  const legendSize = LegendModel.getLegendSize(config.options.type, legendPosition, legendItemsContent, legendMaxWidth, canvasModel.getBlockSize(), legendBlockModel);
@@ -123,6 +127,6 @@ export class MarginModel {
123
127
  });
124
128
  }
125
129
  static recalcMarginByTitle(canvasModel, titleBlockModel) {
126
- canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size);
130
+ canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size + titleBlockModel.margin.bottom);
127
131
  }
128
132
  }
@@ -1,10 +1,9 @@
1
- import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType } from "../config/config";
1
+ import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition } from "../config/config";
2
2
  import { DataType, DonutOptionsCanvas, Formatter, TooltipSettings, Transitions } from "../designer/designerConfig";
3
3
  declare type AxisType = "key" | "value";
4
4
  export declare type Orient = "top" | "bottom" | "left" | "right";
5
5
  export declare type ScaleKeyType = "band" | "point";
6
6
  export declare type ScaleValueType = "linear" | "datetime";
7
- export declare type AxisLabelPosition = "straight" | "rotated";
8
7
  export declare type LegendPosition = "off" | "top" | "bottom" | "left" | "right";
9
8
  export declare type EmbeddedLabelTypeModel = "none" | "key" | "value";
10
9
  export declare type DataOptions = {
@@ -1,7 +1,7 @@
1
1
  import { MarginModel } from './marginModel';
2
2
  import { TwoDimensionalModel } from './notations/twoDimensionalModel';
3
3
  import { PolarModel } from './notations/polarModel';
4
- import { DataManagerModel } from './dataManagerModel';
4
+ import { DataManagerModel } from './dataManagerModel/dataManagerModel';
5
5
  import { IntervalModel } from './notations/intervalModel';
6
6
  import { OtherComponentsModel } from './featuresModel/otherComponents';
7
7
  import { ConfigValidator } from './configsValidator/configValidator';
@@ -69,17 +69,17 @@ export function assembleModel(config, data, designerConfig) {
69
69
  resetFalsyValues(data, config.options.data.keyField.name);
70
70
  const otherComponents = OtherComponentsModel.getOtherComponentsModel({ elementsOptions: designerConfig.elementsOptions, notation: config.options.type, title: config.options.title }, modelInstance);
71
71
  MarginModel.initMargin(designerConfig, config, otherComponents, data, modelInstance);
72
- const dataScope = DataManagerModel.getDataScope(config, data, designerConfig, otherComponents.legendBlock, modelInstance);
73
- const preparedData = DataManagerModel.getPreparedData(data, dataScope.allowableKeys, config);
72
+ DataManagerModel.initDataScope(config, data, designerConfig, otherComponents.legendBlock, modelInstance);
73
+ const preparedData = DataManagerModel.getPreparedData(data, modelInstance.dataModel.getAllowableKeys(), config);
74
74
  if (config.options.type === '2d' && config.options.axis.key.visibility)
75
- MarginModel.recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope);
75
+ MarginModel.recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, modelInstance.dataModel.getScope());
76
76
  const blockCanvas = getBlockCanvas(config, modelInstance);
77
77
  const chartBlock = getChartBlockModel(modelInstance);
78
- const options = getOptions(config, designerConfig, modelInstance, dataScope, preparedData);
79
- const dataSettings = getDataSettings(dataScope, designerConfig);
78
+ const options = getOptions(config, designerConfig, modelInstance, modelInstance.dataModel.getScope(), preparedData);
79
+ const dataSettings = getDataSettings(modelInstance.dataModel.getScope(), designerConfig);
80
80
  const transitions = getTransitions(designerConfig);
81
- if (options.type === 'polar')
82
- MarginModel.recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, otherComponents.legendBlock, dataScope, options);
81
+ // if (options.type === 'polar')
82
+ // MarginModel.recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, otherComponents.legendBlock, modelInstance.dataModel.getScope(), options);
83
83
  modelInstance.canvasModel.roundMargin();
84
84
  return {
85
85
  blockCanvas,
@@ -1,9 +1,11 @@
1
1
  import { Size } from "../../../config/config";
2
2
  import { BlockMargin } from "../../model";
3
+ import { LegendCanvasModelInstance } from "./legendCanvasModel";
3
4
  import { TitleCanvasModel } from "./titleCanvas";
4
5
  declare type MarginSide = keyof BlockMargin;
5
6
  export declare class CanvasModel {
6
7
  titleCanvas: TitleCanvasModel;
8
+ legendCanvas: LegendCanvasModelInstance;
7
9
  private blockSize;
8
10
  private margin;
9
11
  constructor();
@@ -1,7 +1,9 @@
1
+ import { LegendCanvasModelInstance } from "./legendCanvasModel";
1
2
  import { TitleCanvasModel } from "./titleCanvas";
2
3
  export class CanvasModel {
3
4
  constructor() {
4
5
  this.titleCanvas = new TitleCanvasModel();
6
+ this.legendCanvas = new LegendCanvasModelInstance();
5
7
  }
6
8
  initMargin(margin) {
7
9
  this.margin = margin;
@@ -0,0 +1,7 @@
1
+ import { ILegendModel, LegendPosition } from "../../model";
2
+ export declare class LegendCanvasModelInstance {
3
+ private position;
4
+ getModel(): ILegendModel;
5
+ getPosition(): LegendPosition;
6
+ setPosition(position: LegendPosition): void;
7
+ }
@@ -0,0 +1,13 @@
1
+ export class LegendCanvasModelInstance {
2
+ getModel() {
3
+ return {
4
+ position: this.position
5
+ };
6
+ }
7
+ getPosition() {
8
+ return this.position;
9
+ }
10
+ setPosition(position) {
11
+ this.position = position;
12
+ }
13
+ }
@@ -0,0 +1,11 @@
1
+ import { DataScope } from "../model";
2
+ export declare const DEFAULT_MAX_RECORDS_AMOUNT = 50;
3
+ export declare class DataModelInstance {
4
+ private maxRecordsAmount;
5
+ private scope;
6
+ initMaxRecordsAmount(amount: number): void;
7
+ getMaxRecordsAmount(): number;
8
+ initScope(scope: DataScope): void;
9
+ getScope(): DataScope;
10
+ getAllowableKeys(): string[];
11
+ }
@@ -0,0 +1,23 @@
1
+ export const DEFAULT_MAX_RECORDS_AMOUNT = 50;
2
+ export class DataModelInstance {
3
+ constructor() {
4
+ this.maxRecordsAmount = DEFAULT_MAX_RECORDS_AMOUNT;
5
+ }
6
+ initMaxRecordsAmount(amount) {
7
+ if (typeof amount === "number" && amount > 0) {
8
+ this.maxRecordsAmount = amount;
9
+ }
10
+ }
11
+ getMaxRecordsAmount() {
12
+ return this.maxRecordsAmount;
13
+ }
14
+ initScope(scope) {
15
+ this.scope = scope;
16
+ }
17
+ getScope() {
18
+ return this.scope;
19
+ }
20
+ getAllowableKeys() {
21
+ return this.getScope().allowableKeys;
22
+ }
23
+ }
@@ -1,7 +1,10 @@
1
1
  import { MdtChartsConfig } from "../../main";
2
2
  import { CanvasModel } from "./canvasModel/canvasModel";
3
+ import { DataModelInstance } from "./dataModel";
3
4
  export declare class ModelInstance {
4
5
  static create(config: MdtChartsConfig): ModelInstance;
6
+ private static initInitialParams;
5
7
  canvasModel: CanvasModel;
8
+ dataModel: DataModelInstance;
6
9
  constructor();
7
10
  }
@@ -1,11 +1,17 @@
1
1
  import { CanvasModel } from "./canvasModel/canvasModel";
2
+ import { DataModelInstance } from "./dataModel";
2
3
  export class ModelInstance {
3
4
  constructor() {
4
5
  this.canvasModel = new CanvasModel();
6
+ this.dataModel = new DataModelInstance();
5
7
  }
6
8
  static create(config) {
7
9
  const modelInstance = new ModelInstance();
8
- modelInstance.canvasModel.initBlockSize(config.canvas.size);
10
+ this.initInitialParams(modelInstance, config);
9
11
  return modelInstance;
10
12
  }
13
+ static initInitialParams(modelInstance, config) {
14
+ modelInstance.canvasModel.initBlockSize(config.canvas.size);
15
+ modelInstance.dataModel.initMaxRecordsAmount(config.options.data.maxRecordsAmount);
16
+ }
11
17
  }
@@ -1,7 +1,6 @@
1
1
  import { AxisModel } from "../featuresModel/axisModel";
2
2
  import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
3
- import { DataManagerModel } from "../dataManagerModel";
4
- import { LegendModel } from "../featuresModel/legendModel/legendModel";
3
+ import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
5
4
  import { AxisType } from "../modelBuilder";
6
5
  import { ScaleModel, ScaleType } from "../featuresModel/scaleModel";
7
6
  import { TwoDimensionalModel } from "./twoDimensionalModel";
@@ -10,7 +9,7 @@ export class IntervalModel {
10
9
  const options = config.options;
11
10
  const canvasModel = modelInstance.canvasModel;
12
11
  return {
13
- legend: LegendModel.getLegendModel(config.options.type, config.options.legend.show, canvasModel),
12
+ legend: canvasModel.legendCanvas.getModel(),
14
13
  title: options.title,
15
14
  selectable: !!options.selectable,
16
15
  orient: options.orientation,
@@ -1,9 +1,15 @@
1
- import { MdtChartsDataSource, PolarOptions } from "../../config/config";
1
+ import { MdtChartsDataSource, MdtChartsPolarOptions } from "../../config/config";
2
2
  import { DesignerConfig } from "../../designer/designerConfig";
3
- import { PolarOptionsModel } from "../model";
3
+ import { PolarOptionsModel, LegendCoordinate } from "../model";
4
+ import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
4
5
  import { ModelInstance } from "../modelInstance/modelInstance";
6
+ /** If donut block has width less than this const, legend change postion from "right" to "bottom" */
7
+ export declare const MIN_DONUT_BLOCK_SIZE = 120;
5
8
  export declare class PolarModel {
6
- static getOptions(options: PolarOptions, data: MdtChartsDataSource, designerConfig: DesignerConfig, modelInstance: ModelInstance): PolarOptionsModel;
9
+ static getOptions(options: MdtChartsPolarOptions, data: MdtChartsDataSource, designerConfig: DesignerConfig, modelInstance: ModelInstance): PolarOptionsModel;
10
+ static getLegendPositionByBlockSize(canvasModel: CanvasModel): "bottom" | "right";
11
+ static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth: number, legendWidth: number, legendCoordinate: LegendCoordinate): boolean;
12
+ static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight: number, legendCoordinate: LegendCoordinate): boolean;
7
13
  private static getDonutSettings;
8
14
  private static getChartsModel;
9
15
  }
@@ -1,5 +1,6 @@
1
1
  import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
2
- import { LegendModel } from "../featuresModel/legendModel/legendModel";
2
+ /** If donut block has width less than this const, legend change postion from "right" to "bottom" */
3
+ export const MIN_DONUT_BLOCK_SIZE = 120;
3
4
  export class PolarModel {
4
5
  static getOptions(options, data, designerConfig, modelInstance) {
5
6
  return {
@@ -8,11 +9,32 @@ export class PolarModel {
8
9
  title: options.title,
9
10
  data: Object.assign({}, options.data),
10
11
  charts: this.getChartsModel(options.chart, data[options.data.dataSource].length, designerConfig.chartStyle),
11
- legend: LegendModel.getLegendModel(options.type, options.legend.show, modelInstance.canvasModel),
12
+ legend: modelInstance.canvasModel.legendCanvas.getModel(),
12
13
  tooltip: options.tooltip,
13
14
  chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart)
14
15
  };
15
16
  }
17
+ //TODO: type for returned value
18
+ static getLegendPositionByBlockSize(canvasModel) {
19
+ const widthCoefficientWhenLegendShouldInBottom = 1.5;
20
+ const avgLegendWidth = 100;
21
+ const blockWidth = canvasModel.getBlockSize().width;
22
+ const blockHeight = canvasModel.getBlockSize().height;
23
+ return canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE + avgLegendWidth
24
+ && blockWidth * widthCoefficientWhenLegendShouldInBottom < blockHeight
25
+ ? 'bottom'
26
+ : 'right';
27
+ }
28
+ static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth, legendWidth, legendCoordinate) {
29
+ const rightLegendMargin = legendCoordinate.right.margin;
30
+ return chartBlockWidth - legendWidth - rightLegendMargin.left - rightLegendMargin.right >= MIN_DONUT_BLOCK_SIZE;
31
+ }
32
+ static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight, legendCoordinate) {
33
+ const minHeightForLegend = 30;
34
+ const bottomLegendMargin = legendCoordinate.bottom.margin;
35
+ const heightForLegend = chartBlockHeight - bottomLegendMargin.bottom - bottomLegendMargin.top - MIN_DONUT_BLOCK_SIZE;
36
+ return heightForLegend >= minHeightForLegend;
37
+ }
16
38
  static getDonutSettings(settings, chartOptions) {
17
39
  return {
18
40
  padAngle: settings.padAngle,
@@ -1,9 +1,9 @@
1
- import { ChartOrientation, MdtChartsDataSource, TwoDimensionalChart, TwoDimensionalOptions } from "../../config/config";
1
+ import { ChartOrientation, MdtChartsDataSource, TwoDimensionalChart, MdtChartsTwoDimensionalOptions } from "../../config/config";
2
2
  import { BarOptionsCanvas, DesignerConfig } from "../../designer/designerConfig";
3
3
  import { DataScope, TwoDimensionalOptionsModel, TwoDimChartElementsSettings } from "../model";
4
4
  import { ModelInstance } from "../modelInstance/modelInstance";
5
5
  export declare class TwoDimensionalModel {
6
- static getOptions(options: TwoDimensionalOptions, designerConfig: DesignerConfig, dataScope: DataScope, data: MdtChartsDataSource, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
6
+ static getOptions(options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig, dataScope: DataScope, data: MdtChartsDataSource, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
7
7
  static getChartsEmbeddedLabelsFlag(charts: TwoDimensionalChart[], chartOrientation: ChartOrientation): boolean;
8
8
  /**
9
9
  * Сортирует список чартов в порядке: area - bar - line.
@@ -1,13 +1,12 @@
1
1
  import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
2
2
  import { TwoDimensionalChartStyleModel } from "../chartStyleModel/TwoDimensionalChartStyleModel";
3
3
  import { AxisModel } from "../featuresModel/axisModel";
4
- import { LegendModel } from "../featuresModel/legendModel/legendModel";
5
4
  import { ScaleModel } from "../featuresModel/scaleModel";
6
5
  export class TwoDimensionalModel {
7
6
  static getOptions(options, designerConfig, dataScope, data, modelInstance) {
8
7
  const canvasModel = modelInstance.canvasModel;
9
8
  return {
10
- legend: LegendModel.getLegendModel(options.type, options.legend.show, canvasModel),
9
+ legend: canvasModel.legendCanvas.getModel(),
11
10
  title: options.title,
12
11
  selectable: !!options.selectable,
13
12
  orient: options.orientation,
@@ -16,7 +15,7 @@ export class TwoDimensionalModel {
16
15
  value: ScaleModel.getScaleLinear(options, data, canvasModel)
17
16
  },
18
17
  axis: {
19
- key: AxisModel.getKeyAxis(options.charts, data, options.data, options.orientation, options.axis.key, designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip),
18
+ key: AxisModel.getKeyAxis(options, data, designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip),
20
19
  value: AxisModel.getValueAxis(options.orientation, options.axis.value, designerConfig.canvas.axisLabel, canvasModel)
21
20
  },
22
21
  type: options.type,
@@ -41,28 +41,45 @@
41
41
 
42
42
 
43
43
  /*========================================================================== Legend */
44
+ .legend-block {
45
+ display: flex;
46
+ height: 100%;
47
+ }
48
+ .legend-block-column {
49
+ flex-direction: column;
50
+ }
51
+ .legend-block-row {
52
+ flex-direction: row;
53
+ flex-wrap: wrap;
54
+ }
55
+ .legend-block-centered {
56
+ justify-content: center;
57
+ }
44
58
  .legend-item {
45
59
  cursor: default;
46
60
  transition: opacity 0.1s;
61
+ /* will-change: opacity; */
62
+ }
63
+ .legend-block-column .legend-item:not(:first-of-type) {
64
+ margin-top: 15px;
47
65
  }
48
66
  .legend-item-inline {
49
67
  white-space: nowrap;
68
+ overflow: hidden;
69
+ text-overflow: ellipsis;
50
70
  }
51
- .legend-item-inline:not(:first-of-type) {
71
+ .legend-wrapper-without-wrap .legend-item-inline:not(:first-of-type) {
52
72
  margin-left: 20px;
53
73
  }
74
+ .legend-wrapper-with-wrap .legend-item-inline {
75
+ margin: 5px;
76
+ }
54
77
  .legend-item-row {
55
78
  display: flex;
56
79
  }
57
80
  .legend-item-row > span {
58
81
  display: block;
59
82
  }
60
- .mt-15 {
61
- margin-top: 15px;
62
- }
63
- .mt-10 {
64
- margin-top: 10px;
65
- }
66
83
 
67
84
  .legend-label {
68
85
  font-size: 12px;
@@ -41,28 +41,45 @@
41
41
 
42
42
 
43
43
  /*========================================================================== Legend */
44
+ .legend-block {
45
+ display: flex;
46
+ height: 100%;
47
+ }
48
+ .legend-block-column {
49
+ flex-direction: column;
50
+ }
51
+ .legend-block-row {
52
+ flex-direction: row;
53
+ flex-wrap: wrap;
54
+ }
55
+ .legend-block-centered {
56
+ justify-content: center;
57
+ }
44
58
  .legend-item {
45
59
  cursor: default;
46
60
  transition: opacity 0.1s;
61
+ /* will-change: opacity; */
62
+ }
63
+ .legend-block-column .legend-item:not(:first-of-type) {
64
+ margin-top: 15px;
47
65
  }
48
66
  .legend-item-inline {
49
67
  white-space: nowrap;
68
+ overflow: hidden;
69
+ text-overflow: ellipsis;
50
70
  }
51
- .legend-item-inline:not(:first-of-type) {
71
+ .legend-wrapper-without-wrap .legend-item-inline:not(:first-of-type) {
52
72
  margin-left: 20px;
53
73
  }
74
+ .legend-wrapper-with-wrap .legend-item-inline {
75
+ margin: 5px;
76
+ }
54
77
  .legend-item-row {
55
78
  display: flex;
56
79
  }
57
80
  .legend-item-row > span {
58
81
  display: block;
59
82
  }
60
- .mt-15 {
61
- margin-top: 15px;
62
- }
63
- .mt-10 {
64
- margin-top: 10px;
65
- }
66
83
 
67
84
  .legend-label {
68
85
  font-size: 12px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdt-charts",
3
- "version": "1.11.0",
3
+ "version": "1.12.2",
4
4
  "description": "",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "build": "npx webpack --mode production",
9
9
  "watch": "npx webpack --mode development --watch",
10
10
  "test": "jest",
11
- "build-lib": "npx tsc -p ."
11
+ "build-lib": "npx tsc -p tsconfig.production.json"
12
12
  },
13
13
  "homepage": "https://github.com/VishulaKnow/charts",
14
14
  "author": "",
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./lib/",
4
+ "noImplicitAny": true,
5
+ "target": "es6",
6
+ "lib": ["ES2017", "DOM"],
7
+ "jsx": "react",
8
+ "allowJs": true,
9
+ "types": [
10
+ "jest"
11
+ ],
12
+ "declaration": true
13
+ },
14
+ "include": [
15
+ "src"
16
+ ],
17
+ "exclude": [
18
+ "node_modules",
19
+ "**/__tests__/*",
20
+ "src/playground/*",
21
+ "**/*Example.ts"
22
+ ]
23
+ }
@@ -1,14 +0,0 @@
1
- import { ChartOrientation } from "../../../config/config";
2
- import { Block } from "../../block/block";
3
- declare type AlertBlockPosition = 'top' | 'bottom' | 'right' | 'left';
4
- export declare class RecordOverflowAlert {
5
- private static readonly blockClass;
6
- static render(block: Block, hidedRecordsAmount: number, position: AlertBlockPosition, chartOrientation?: ChartOrientation): void;
7
- static update(block: Block, hidedRecordsAmount: number, position: AlertBlockPosition, chartOrientation?: ChartOrientation): void;
8
- private static setAlertPosition;
9
- private static getAlertText;
10
- private static getWordTextEndingByAmount;
11
- private static getBlockPositionAttrs;
12
- private static getLeftAttrForRightBlock;
13
- }
14
- export {};
@@ -1,97 +0,0 @@
1
- import { DomHelper } from '../../helpers/domHelper';
2
- import { Legend } from '../legend/legend';
3
- export class RecordOverflowAlert {
4
- static render(block, hidedRecordsAmount, position, chartOrientation = null) {
5
- const alertBlock = block.getWrapper()
6
- .append('div')
7
- .attr('class', this.blockClass)
8
- .text(this.getAlertText(hidedRecordsAmount, chartOrientation));
9
- const attrs = this.getBlockPositionAttrs(position, block);
10
- this.setAlertPosition(alertBlock, attrs);
11
- }
12
- static update(block, hidedRecordsAmount, position, chartOrientation = null) {
13
- let alertBlock = block.getWrapper()
14
- .select(`div.${this.blockClass}`);
15
- if (alertBlock.empty()) {
16
- if (hidedRecordsAmount === 0)
17
- return;
18
- else
19
- this.render(block, hidedRecordsAmount, position, chartOrientation);
20
- }
21
- else {
22
- if (hidedRecordsAmount === 0)
23
- alertBlock.remove();
24
- else
25
- alertBlock.text(this.getAlertText(hidedRecordsAmount, chartOrientation));
26
- }
27
- }
28
- static setAlertPosition(alertBlock, attrs) {
29
- alertBlock
30
- .style('position', 'absolute')
31
- .style('left', attrs.left)
32
- .style('right', attrs.right)
33
- .style('top', attrs.top)
34
- .style('bottom', attrs.bottom);
35
- }
36
- static getAlertText(hidedRecordsAmount, chartOrientation) {
37
- return `+ ${hidedRecordsAmount} ${this.getWordTextEndingByAmount(hidedRecordsAmount, chartOrientation)}`;
38
- }
39
- static getWordTextEndingByAmount(hidedRecordsAmount, chartOrientation) {
40
- const lastDigit = hidedRecordsAmount % 10;
41
- if (chartOrientation === 'vertical') {
42
- if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
43
- return 'столбцов';
44
- if (lastDigit === 1)
45
- return 'столбец';
46
- if (lastDigit >= 2 && lastDigit <= 4)
47
- return 'столбца';
48
- return 'столбцов';
49
- }
50
- else if (chartOrientation === 'horizontal') {
51
- if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
52
- return 'строк';
53
- if (lastDigit === 1)
54
- return 'строка';
55
- if (lastDigit >= 2 && lastDigit <= 4)
56
- return 'строки';
57
- return 'строк';
58
- }
59
- else {
60
- if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
61
- return 'категорий';
62
- if (lastDigit === 1)
63
- return 'категория';
64
- if (lastDigit >= 2 && lastDigit <= 4)
65
- return 'категории';
66
- return 'категорий';
67
- }
68
- }
69
- static getBlockPositionAttrs(position, block) {
70
- const attrs = {
71
- bottom: null,
72
- top: null,
73
- right: null,
74
- left: null
75
- };
76
- if (position === 'top') {
77
- attrs.right = '17px';
78
- attrs.top = '1rem';
79
- }
80
- if (position === 'right') {
81
- attrs.bottom = '20px';
82
- attrs.left = this.getLeftAttrForRightBlock(block) + 'px';
83
- }
84
- if (position === 'bottom') {
85
- attrs.left = '20px';
86
- attrs.bottom = '20px';
87
- }
88
- return attrs;
89
- }
90
- static getLeftAttrForRightBlock(block) {
91
- const legendBlock = block.getSvg().select(`.${Legend.objectClass}`);
92
- if (legendBlock.empty())
93
- return null;
94
- return DomHelper.getSelectionNumericAttr(legendBlock, 'x');
95
- }
96
- }
97
- RecordOverflowAlert.blockClass = 'record-overflow-alert';