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
@@ -0,0 +1,19 @@
1
+ import { AxisLabelFormatter, MdtChartsConfig, MdtChartsField, MdtChartsTwoDimensionalOptions } from "../../config/config";
2
+ import { DesignerConfig } from "../../designer/designerConfig";
3
+ interface BaseConfigReader {
4
+ getValueFields(): MdtChartsField[];
5
+ }
6
+ export declare function getConfigReader(config: MdtChartsConfig, designerConfig: DesignerConfig): BaseConfigReader;
7
+ export declare class TwoDimConfigReader implements BaseConfigReader {
8
+ private designerConfig;
9
+ readonly options: MdtChartsTwoDimensionalOptions;
10
+ constructor(config: MdtChartsConfig, designerConfig: DesignerConfig);
11
+ getValueFields(): MdtChartsField[];
12
+ getAxisLabelFormatter(): AxisLabelFormatter;
13
+ }
14
+ export declare class PolarConfigReader implements BaseConfigReader {
15
+ private options;
16
+ constructor(config: MdtChartsConfig);
17
+ getValueFields(): MdtChartsField[];
18
+ }
19
+ export {};
@@ -0,0 +1,35 @@
1
+ export function getConfigReader(config, designerConfig) {
2
+ if (config.options.type === "2d")
3
+ return new TwoDimConfigReader(config, designerConfig);
4
+ if (config.options.type === "polar")
5
+ return new PolarConfigReader(config);
6
+ throw new Error(`Config reader for type "${config.options.type}" not exists`);
7
+ }
8
+ export class TwoDimConfigReader {
9
+ constructor(config, designerConfig) {
10
+ this.designerConfig = designerConfig;
11
+ this.options = config.options;
12
+ }
13
+ getValueFields() {
14
+ const fields = [];
15
+ this.options.charts.forEach(chart => {
16
+ fields.push(...chart.data.valueFields);
17
+ });
18
+ return fields;
19
+ }
20
+ getAxisLabelFormatter() {
21
+ var _a, _b;
22
+ if ((_a = this.options.axis.value.labels) === null || _a === void 0 ? void 0 : _a.format)
23
+ return (_b = this.options.axis.value.labels) === null || _b === void 0 ? void 0 : _b.format;
24
+ const valueFieldFormat = this.options.charts[0].data.valueFields[0].format;
25
+ return (v) => this.designerConfig.dataFormat.formatters(v, { type: valueFieldFormat });
26
+ }
27
+ }
28
+ export class PolarConfigReader {
29
+ constructor(config) {
30
+ this.options = config.options;
31
+ }
32
+ getValueFields() {
33
+ return [this.options.chart.data.valueField];
34
+ }
35
+ }
@@ -2,10 +2,10 @@ import { DataScope } from "../../model";
2
2
  import { DataRepositoryModel } from "./dataRepository";
3
3
  export declare const DEFAULT_MAX_RECORDS_AMOUNT = 50;
4
4
  export declare class DataModelInstance {
5
- repository: DataRepositoryModel;
6
- constructor();
5
+ readonly repository: DataRepositoryModel;
7
6
  private maxRecordsAmount;
8
7
  private scope;
8
+ constructor();
9
9
  initMaxRecordsAmount(amount: number): void;
10
10
  getMaxRecordsAmount(): number;
11
11
  initScope(scope: DataScope): void;
@@ -2,7 +2,6 @@ import { DataRepositoryModel } from "./dataRepository";
2
2
  export const DEFAULT_MAX_RECORDS_AMOUNT = 50;
3
3
  export class DataModelInstance {
4
4
  constructor() {
5
- //TODO: create dataScopeModel.
6
5
  this.maxRecordsAmount = DEFAULT_MAX_RECORDS_AMOUNT;
7
6
  this.repository = new DataRepositoryModel();
8
7
  }
@@ -1,9 +1,13 @@
1
- import { MdtChartsDataSource } from "../../../config/config";
1
+ import { DataOptions, MdtChartsDataSource, MdtChartsField } from "../../../config/config";
2
2
  export declare class DataRepositoryModel {
3
3
  private rawFullSource;
4
4
  private scopedFullSource;
5
5
  private sourceName;
6
- initSourceName(sourceName: string): void;
6
+ private keyField;
7
+ private valueFields;
8
+ initOptions(options: DataOptions, valueFields: MdtChartsField[]): void;
9
+ getValuesByKeyField(): any[];
10
+ getBiggestValueAndDecremented(): number[];
7
11
  initRawFullSource(rawSource: MdtChartsDataSource): void;
8
12
  getRawRows(): import("../../../config/config").MdtChartsDataRow[];
9
13
  getFirstRow(): import("../../../config/config").MdtChartsDataRow;
@@ -1,6 +1,19 @@
1
1
  export class DataRepositoryModel {
2
- initSourceName(sourceName) {
3
- this.sourceName = sourceName;
2
+ initOptions(options, valueFields) {
3
+ this.sourceName = options.dataSource;
4
+ this.keyField = options.keyField;
5
+ this.valueFields = valueFields;
6
+ }
7
+ getValuesByKeyField() {
8
+ return this.getRawRows().map(dataRow => dataRow[this.keyField.name]);
9
+ }
10
+ getBiggestValueAndDecremented() {
11
+ const values = [];
12
+ this.getRawRows().forEach(row => {
13
+ this.valueFields.forEach(vf => values.push(row[vf.name]));
14
+ });
15
+ const biggest = Math.max(...values);
16
+ return [biggest, biggest - 1];
4
17
  }
5
18
  initRawFullSource(rawSource) {
6
19
  this.rawFullSource = rawSource;
@@ -1,8 +1,9 @@
1
1
  import { MdtChartsConfig, MdtChartsDataSource } from "../../config/config";
2
+ import { DesignerConfig } from "../../designer/designerConfig";
2
3
  import { CanvasModel } from "./canvasModel/canvasModel";
3
4
  import { DataModelInstance } from "./dataModel/dataModel";
4
5
  export declare class ModelInstance {
5
- static create(config: MdtChartsConfig, data: MdtChartsDataSource): ModelInstance;
6
+ static create(config: MdtChartsConfig, data: MdtChartsDataSource, designerConfig: DesignerConfig): ModelInstance;
6
7
  private static initInitialParams;
7
8
  canvasModel: CanvasModel;
8
9
  dataModel: DataModelInstance;
@@ -1,18 +1,20 @@
1
1
  import { CanvasModel } from "./canvasModel/canvasModel";
2
+ import { getConfigReader } from "./configReader";
2
3
  import { DataModelInstance } from "./dataModel/dataModel";
3
4
  export class ModelInstance {
4
5
  constructor() {
5
6
  this.canvasModel = new CanvasModel();
6
7
  this.dataModel = new DataModelInstance();
7
8
  }
8
- static create(config, data) {
9
+ static create(config, data, designerConfig) {
9
10
  const modelInstance = new ModelInstance();
10
- this.initInitialParams(modelInstance, config, data);
11
+ this.initInitialParams(modelInstance, config, data, designerConfig);
11
12
  return modelInstance;
12
13
  }
13
- static initInitialParams(modelInstance, config, data) {
14
+ static initInitialParams(modelInstance, config, data, designerConfig) {
15
+ const configReader = getConfigReader(config, designerConfig);
14
16
  modelInstance.canvasModel.initBlockSize(config.canvas.size);
15
- modelInstance.dataModel.repository.initSourceName(config.options.data.dataSource);
17
+ modelInstance.dataModel.repository.initOptions(config.options.data, configReader.getValueFields());
16
18
  modelInstance.dataModel.repository.initRawFullSource(data);
17
19
  }
18
20
  }
@@ -3,9 +3,9 @@ import { DEFAULT_CARD_CHANGE_RANGE } from "./cardsModelService";
3
3
  export class CardsChangeService {
4
4
  getChangeModel(dataRow, changeOptions) {
5
5
  var _a;
6
- if (!changeOptions || !((_a = changeOptions.value) === null || _a === void 0 ? void 0 : _a.field))
6
+ if (!changeOptions || !((_a = changeOptions.value) === null || _a === void 0 ? void 0 : _a.name))
7
7
  return void 0;
8
- const value = dataRow[changeOptions.value.field];
8
+ const value = dataRow[changeOptions.value.name];
9
9
  return {
10
10
  description: changeOptions.description,
11
11
  value: Object.assign({}, changeOptions.value),
@@ -25,7 +25,7 @@ export class CardsModelService {
25
25
  }
26
26
  getCardColor(options, modelInstance) {
27
27
  const data = modelInstance.dataModel.repository.getFirstRow();
28
- const value = data[options.value.field];
28
+ const value = data[options.value.name];
29
29
  return getCardColor(value, options.color);
30
30
  }
31
31
  getCardsChangeModel(options, modelInstance) {
@@ -28,7 +28,8 @@ export class IntervalModel {
28
28
  start: 0,
29
29
  end: 0
30
30
  },
31
- type: 'datetime'
31
+ type: 'datetime',
32
+ formatter: null
32
33
  }
33
34
  },
34
35
  axis: {
@@ -42,7 +43,7 @@ export class IntervalModel {
42
43
  cssClass: 'key-axis',
43
44
  ticks: options.axis.key.ticks,
44
45
  labels: {
45
- maxSize: AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataModelRep.getScopedRows().map(d => d[options.data.keyField.name])).width,
46
+ maxSize: AxisModel.getLabelSizeLegacy(designerConfig.canvas.axisLabel.maxSize.main, dataModelRep.getScopedRows().map(d => d[options.data.keyField.name])).width,
46
47
  position: AxisModel.getKeyAxisLabelPosition(canvasModel, DataManagerModel.getDataValuesByKeyField(dataModelRep.getScopedFullSource(), options.data.dataSource, options.data.keyField.name).length),
47
48
  visible: true,
48
49
  defaultTooltip: designerConfig.elementsOptions.tooltip.position === 'fixed'
@@ -72,7 +73,7 @@ export class IntervalModel {
72
73
  charts: this.getChartsModel(options.chart, designerConfig.chartStyle),
73
74
  additionalElements: this.getAdditionalElements(options),
74
75
  tooltip: options.tooltip,
75
- chartSettings: TwoDimensionalModel.getChartsSettings(designerConfig.canvas.chartOptions.bar)
76
+ chartSettings: TwoDimensionalModel.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation)
76
77
  };
77
78
  }
78
79
  static getAdditionalElements(options) {
@@ -45,7 +45,12 @@ export class PolarModel {
45
45
  data: Object.assign({}, chart.data),
46
46
  tooltip: chart.tooltip,
47
47
  cssClasses: ChartStyleModelService.getCssClasses(0),
48
- style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig)
48
+ style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig),
49
+ legend: {
50
+ markerShape: "default",
51
+ barViewOptions: { hatch: { on: false }, width: 0 },
52
+ lineViewOptions: { dashedStyles: { on: false, dashSize: 0, gapSize: 0 }, width: 0 }
53
+ }
49
54
  });
50
55
  return chartsModel;
51
56
  }
@@ -0,0 +1,6 @@
1
+ import { ChartLegendModel, LineLikeChartDashOptions, LineLikeChartShapeOptions } from "../../model";
2
+ import { ChartOrientation, MdtChartsLineLikeChartDashedStyles, MdtChartsTwoDimensionalChart } from "../../../config/config";
3
+ import { MdtChartsLineLikeChartShape } from "../../../designer/designerConfig";
4
+ export declare function parseShape(chartOrientation: ChartOrientation, configOptions?: MdtChartsLineLikeChartShape): LineLikeChartShapeOptions;
5
+ export declare function parseDashStyles(configOptions?: MdtChartsLineLikeChartDashedStyles): LineLikeChartDashOptions;
6
+ export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart): ChartLegendModel;
@@ -0,0 +1,41 @@
1
+ import { LineCurveType } from "../../model";
2
+ export function parseShape(chartOrientation, configOptions) {
3
+ var _a;
4
+ const curveType = (_a = configOptions === null || configOptions === void 0 ? void 0 : configOptions.curve) === null || _a === void 0 ? void 0 : _a.type;
5
+ return {
6
+ curve: {
7
+ type: parseCurveType(chartOrientation, curveType)
8
+ }
9
+ };
10
+ }
11
+ function parseCurveType(chartOrientation, curveType) {
12
+ if (curveType === "monotone" || curveType == null) {
13
+ if (chartOrientation === "horizontal")
14
+ return LineCurveType.monotoneY;
15
+ return LineCurveType.monotoneX;
16
+ }
17
+ return LineCurveType.none;
18
+ }
19
+ export function parseDashStyles(configOptions) {
20
+ var _a, _b, _c;
21
+ const DEFAULT_DASH_SIZE_PX = 10;
22
+ const DEFAULT_GAP_SIZE_PX = 3;
23
+ return {
24
+ on: (_a = configOptions === null || configOptions === void 0 ? void 0 : configOptions.on) !== null && _a !== void 0 ? _a : false,
25
+ dashSize: (_b = configOptions === null || configOptions === void 0 ? void 0 : configOptions.dashSize) !== null && _b !== void 0 ? _b : DEFAULT_DASH_SIZE_PX,
26
+ gapSize: (_c = configOptions === null || configOptions === void 0 ? void 0 : configOptions.gapSize) !== null && _c !== void 0 ? _c : DEFAULT_GAP_SIZE_PX
27
+ };
28
+ }
29
+ export function getLegendMarkerOptions(chart) {
30
+ var _a, _b, _c, _d;
31
+ const shapeByType = {
32
+ area: "default",
33
+ bar: "bar",
34
+ line: "line"
35
+ };
36
+ return {
37
+ markerShape: shapeByType[chart.type],
38
+ barViewOptions: { hatch: { on: (_c = (_b = (_a = chart.barStyles) === null || _a === void 0 ? void 0 : _a.hatch) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false }, width: 10 },
39
+ lineViewOptions: { dashedStyles: parseDashStyles((_d = chart.lineStyles) === null || _d === void 0 ? void 0 : _d.dash), width: 30 }
40
+ };
41
+ }
@@ -1,9 +1,10 @@
1
- import { ChartOrientation, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions } from "../../config/config";
2
- import { BarOptionsCanvas, DesignerConfig } from "../../designer/designerConfig";
1
+ import { ChartOrientation, MdtChartsTwoDimensionalChart } from "../../config/config";
2
+ import { ChartOptionsCanvas, DesignerConfig } from "../../designer/designerConfig";
3
3
  import { TwoDimensionalOptionsModel, TwoDimChartElementsSettings } from "../model";
4
+ import { TwoDimConfigReader } from "../modelInstance/configReader";
4
5
  import { ModelInstance } from "../modelInstance/modelInstance";
5
6
  export declare class TwoDimensionalModel {
6
- static getOptions(options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
7
+ static getOptions(configReader: TwoDimConfigReader, designerConfig: DesignerConfig, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
7
8
  static getChartsEmbeddedLabelsFlag(charts: MdtChartsTwoDimensionalChart[], chartOrientation: ChartOrientation): boolean;
8
9
  /**
9
10
  * Сортирует список чартов в порядке: area - bar - line.
@@ -11,11 +12,10 @@ export declare class TwoDimensionalModel {
11
12
  * @param charts Чарты из конфига
12
13
  */
13
14
  static sortCharts(charts: MdtChartsTwoDimensionalChart[]): void;
14
- static getChartsSettings(barSettings: BarOptionsCanvas): TwoDimChartElementsSettings;
15
+ static getChartsSettings(chartOptions: ChartOptionsCanvas, chartOrientation: ChartOrientation): TwoDimChartElementsSettings;
15
16
  private static getChartsModel;
16
17
  private static findChartsWithEmbeddedKeyLabels;
17
18
  private static getEmbeddedLabelType;
18
19
  private static getAdditionalElements;
19
20
  private static getChartsByType;
20
- static getChartsValueFieldsAmount(charts: MdtChartsTwoDimensionalChart[]): number[];
21
21
  }
@@ -3,12 +3,14 @@ import { TwoDimensionalChartStyleModel } from "../chartStyleModel/TwoDimensional
3
3
  import { AxisModel } from "../featuresModel/axisModel";
4
4
  import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
5
5
  import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
6
+ import { getLegendMarkerOptions, parseDashStyles, parseShape } from "./twoDimensional/styles";
6
7
  export class TwoDimensionalModel {
7
- static getOptions(options, designerConfig, modelInstance) {
8
+ static getOptions(configReader, designerConfig, modelInstance) {
9
+ const options = configReader.options;
8
10
  const canvasModel = modelInstance.canvasModel;
9
11
  const dataModelRep = modelInstance.dataModel.repository;
10
12
  const scaleModel = new ScaleModel();
11
- const scaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleLinear(options, dataModelRep.getScopedRows(), canvasModel));
13
+ const scaleMarginRecalcer = new ScaleAxisRecalcer(() => scaleModel.getScaleLinear(options, dataModelRep.getScopedRows(), canvasModel, configReader));
12
14
  scaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
13
15
  const scaleValueInfo = scaleMarginRecalcer.getScaleValue();
14
16
  return {
@@ -29,7 +31,7 @@ export class TwoDimensionalModel {
29
31
  charts: this.getChartsModel(options.charts, options.orientation, designerConfig.chartStyle),
30
32
  additionalElements: this.getAdditionalElements(options),
31
33
  tooltip: options.tooltip,
32
- chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions.bar)
34
+ chartSettings: this.getChartsSettings(designerConfig.canvas.chartOptions, options.orientation)
33
35
  };
34
36
  }
35
37
  static getChartsEmbeddedLabelsFlag(charts, chartOrientation) {
@@ -47,9 +49,11 @@ export class TwoDimensionalModel {
47
49
  const chartOrder = ['area', 'bar', 'line'];
48
50
  charts.sort((chart1, chart2) => chartOrder.indexOf(chart1.type) - chartOrder.indexOf(chart2.type));
49
51
  }
50
- static getChartsSettings(barSettings) {
52
+ static getChartsSettings(chartOptions, chartOrientation) {
53
+ var _a;
51
54
  return {
52
- bar: Object.assign({}, barSettings)
55
+ bar: Object.assign({}, chartOptions.bar),
56
+ lineLike: { shape: parseShape(chartOrientation, (_a = chartOptions.line) === null || _a === void 0 ? void 0 : _a.shape) }
53
57
  };
54
58
  }
55
59
  static getChartsModel(charts, chartOrientation, chartStyleConfig) {
@@ -57,6 +61,7 @@ export class TwoDimensionalModel {
57
61
  this.sortCharts(charts);
58
62
  const chartsModel = [];
59
63
  charts.forEach((chart, index) => {
64
+ var _a, _b, _c, _d;
60
65
  chartsModel.push({
61
66
  type: chart.type,
62
67
  isSegmented: chart.isSegmented,
@@ -66,6 +71,9 @@ export class TwoDimensionalModel {
66
71
  style: styleModel.getChartStyle(chart, index),
67
72
  embeddedLabels: this.getEmbeddedLabelType(chart, chartOrientation),
68
73
  markersOptions: chart.markers,
74
+ lineViewOptions: { dashedStyles: parseDashStyles((_a = chart.lineStyles) === null || _a === void 0 ? void 0 : _a.dash) },
75
+ barViewOptions: { hatch: { on: (_d = (_c = (_b = chart.barStyles) === null || _b === void 0 ? void 0 : _b.hatch) === null || _c === void 0 ? void 0 : _c.on) !== null && _d !== void 0 ? _d : false } },
76
+ legend: getLegendMarkerOptions(chart),
69
77
  index
70
78
  });
71
79
  });
@@ -92,7 +100,4 @@ export class TwoDimensionalModel {
92
100
  static getChartsByType(charts, type) {
93
101
  return charts.filter(chart => chart.type === type);
94
102
  }
95
- static getChartsValueFieldsAmount(charts) {
96
- return charts.map(chart => chart.data.valueFields.length);
97
- }
98
103
  }
@@ -97,6 +97,9 @@
97
97
  white-space: nowrap;
98
98
  text-overflow: ellipsis;
99
99
  }
100
+ .legend-marker {
101
+ margin-right: 8px;
102
+ }
100
103
  .legend-circle {
101
104
  position: relative;
102
105
  bottom: -1px;
@@ -97,6 +97,9 @@
97
97
  white-space: nowrap;
98
98
  text-overflow: ellipsis;
99
99
  }
100
+ .legend-marker {
101
+ margin-right: 8px;
102
+ }
100
103
  .legend-circle {
101
104
  position: relative;
102
105
  bottom: -1px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdt-charts",
3
- "version": "1.13.2",
3
+ "version": "1.14.0",
4
4
  "description": "",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -31,9 +31,7 @@
31
31
  "typescript": "^4.1.3",
32
32
  "webpack": "^5.10.1",
33
33
  "webpack-bundle-analyzer": "^4.4.0",
34
- "webpack-cli": "^4.2.0"
35
- },
36
- "dependencies": {
34
+ "webpack-cli": "^4.2.0",
37
35
  "@types/chroma-js": "^2.1.3",
38
36
  "@types/d3-array": "^2.9.0",
39
37
  "@types/d3-axis": "^2.0.0",
@@ -43,7 +41,9 @@
43
41
  "@types/d3-scale": "^3.2.2",
44
42
  "@types/d3-selection": "^2.0.0",
45
43
  "@types/d3-shape": "^2.0.0",
46
- "@types/d3-transition": "^2.0.0",
44
+ "@types/d3-transition": "^2.0.0"
45
+ },
46
+ "dependencies": {
47
47
  "chroma-js": "^2.1.1",
48
48
  "d3-array": "^2.11.0",
49
49
  "d3-axis": "^2.0.0",
@@ -1,9 +0,0 @@
1
- import { Model } from "../model/model";
2
- import Engine from "./engine";
3
- import { Block } from "./block/block";
4
- import { MdtChartsDataSource } from "../config/config";
5
- export declare class ContentManager {
6
- static render(model: Model, data: MdtChartsDataSource, engine: Engine): void;
7
- static updateData(block: Block, model: Model, newData: MdtChartsDataSource): void;
8
- static updateColors(engine: Engine, model: Model): void;
9
- }
@@ -1,29 +0,0 @@
1
- import { TwoDimensionalManager } from "./twoDimensionalNotation/twoDimensionalManager";
2
- import { PolarManager } from "./polarNotation/polarManager";
3
- import { IntervalManager } from "./intervalNotation/intervalManager";
4
- export class ContentManager {
5
- static render(model, data, engine) {
6
- if (model.options.type === '2d')
7
- TwoDimensionalManager.render(engine, model);
8
- else if (model.options.type === 'polar')
9
- PolarManager.render(engine, model);
10
- else if (model.options.type === 'interval')
11
- IntervalManager.render(engine.block, model, data);
12
- }
13
- static updateData(block, model, newData) {
14
- if (model.options.type === '2d') {
15
- TwoDimensionalManager.updateData(block, model, newData);
16
- }
17
- else if (model.options.type === 'polar') {
18
- PolarManager.update(block, model, newData);
19
- }
20
- }
21
- static updateColors(engine, model) {
22
- if (model.options.type === '2d') {
23
- TwoDimensionalManager.updateColors(engine.block, model);
24
- }
25
- else if (model.options.type === 'polar') {
26
- PolarManager.updateColors(engine.block, model);
27
- }
28
- }
29
- }
@@ -1,11 +0,0 @@
1
- import { MarginSide } from "./canvasModel";
2
- export interface MarginLogData {
3
- side: MarginSide;
4
- byValue: number;
5
- }
6
- export declare class MarginModelService {
7
- private log;
8
- appendLog(key: string, side: MarginSide, byValue: number): void;
9
- getDataByKey(key: string): MarginLogData;
10
- private findLogByKey;
11
- }
@@ -1,26 +0,0 @@
1
- export class MarginModelService {
2
- constructor() {
3
- this.log = [];
4
- }
5
- appendLog(key, side, byValue) {
6
- const log = this.findLogByKey(key);
7
- if (log) {
8
- log.data = { side, byValue };
9
- return;
10
- }
11
- this.log.push({
12
- key,
13
- data: {
14
- side,
15
- byValue
16
- }
17
- });
18
- }
19
- getDataByKey(key) {
20
- var _a;
21
- return (_a = this.findLogByKey(key)) === null || _a === void 0 ? void 0 : _a.data;
22
- }
23
- findLogByKey(key) {
24
- return this.log.find(l => l.key === key);
25
- }
26
- }