mdt-charts 1.27.1 → 1.27.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.
- package/.prettierrc +6 -0
- package/lib/config/config.d.ts +13 -13
- package/lib/designer/designerConfig.d.ts +1 -1
- package/lib/engine/block/block.js +14 -14
- package/lib/engine/block/blockHelper.js +2 -2
- package/lib/engine/block/blockSvg.js +25 -28
- package/lib/engine/block/defs/LinearGradientDef.js +9 -8
- package/lib/engine/contentManager/contentManagerFactory.js +1 -1
- package/lib/engine/elementHighlighter/elementHighlighter.d.ts +3 -3
- package/lib/engine/elementHighlighter/elementHighlighter.js +52 -54
- package/lib/engine/elementHighlighter/selectHighlighter.js +7 -7
- package/lib/engine/engine.d.ts +4 -4
- package/lib/engine/engine.js +5 -5
- package/lib/engine/features/aggregator/aggregator.d.ts +1 -1
- package/lib/engine/features/aggregator/aggregator.js +43 -45
- package/lib/engine/features/axis/axis.d.ts +1 -1
- package/lib/engine/features/axis/axis.js +53 -48
- package/lib/engine/features/axis/axisDomHelper.d.ts +3 -3
- package/lib/engine/features/axis/axisDomHelper.js +6 -8
- package/lib/engine/features/axis/axisHelper.d.ts +2 -2
- package/lib/engine/features/axis/axisHelper.js +14 -21
- package/lib/engine/features/axis/axisLabelDomHelper.d.ts +3 -3
- package/lib/engine/features/axis/axisLabelDomHelper.js +74 -66
- package/lib/engine/features/axis/axisLabelsEventManager.js +11 -11
- package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +3 -3
- package/lib/engine/features/embeddedLabels/embeddedLabels.js +44 -44
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +1 -1
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +3 -6
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +2 -2
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +22 -20
- package/lib/engine/features/gridLine/gidLineHelper.d.ts +1 -1
- package/lib/engine/features/gridLine/gidLineHelper.js +5 -5
- package/lib/engine/features/gridLine/gridLine.js +14 -23
- package/lib/engine/features/legend/legend.js +27 -36
- package/lib/engine/features/legend/legendDomHelper.js +18 -9
- package/lib/engine/features/legend/legendEventsManager.js +18 -13
- package/lib/engine/features/legend/legendHelper.js +19 -19
- package/lib/engine/features/legend/legendHelperService.js +5 -5
- package/lib/engine/features/legend/legendMarkerCreator.js +23 -22
- package/lib/engine/features/legend/legendWidthCalculator.js +5 -7
- package/lib/engine/features/markDots/markDot.d.ts +2 -2
- package/lib/engine/features/markDots/markDot.js +35 -34
- package/lib/engine/features/markDots/markDotsHelper.js +6 -6
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +11 -11
- package/lib/engine/features/scale/scale.d.ts +4 -5
- package/lib/engine/features/scale/scale.js +16 -25
- package/lib/engine/features/tipBox/tipBox.d.ts +2 -2
- package/lib/engine/features/tipBox/tipBox.js +13 -17
- package/lib/engine/features/tipBox/tipBoxHelper.js +5 -5
- package/lib/engine/features/title/title.d.ts +1 -1
- package/lib/engine/features/title/title.js +8 -11
- package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +1 -1
- package/lib/engine/features/tolltip/newTooltip/newTooltip.js +6 -8
- package/lib/engine/features/tolltip/tooltip.d.ts +2 -2
- package/lib/engine/features/tolltip/tooltip.js +47 -42
- package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +2 -2
- package/lib/engine/features/tolltip/tooltipComponentsManager.js +49 -52
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +1 -1
- package/lib/engine/features/tolltip/tooltipDomHelper.js +41 -33
- package/lib/engine/features/tolltip/tooltipHelper.js +15 -11
- package/lib/engine/features/valueLabels/valueLabels.js +24 -37
- package/lib/engine/features/valueLabels/valueLabelsHelper.js +6 -6
- package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +9 -10
- package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +4 -4
- package/lib/engine/filterManager/filterEventManager.js +18 -15
- package/lib/engine/helpers/domHelper.d.ts +3 -4
- package/lib/engine/helpers/domHelper.js +9 -13
- package/lib/engine/helpers/fontResizer/fontResizer.js +2 -2
- package/lib/engine/helpers/helper.js +14 -9
- package/lib/engine/helpers/namesHelper.js +2 -2
- package/lib/engine/polarNotation/donut/DonutHelper.js +6 -8
- package/lib/engine/polarNotation/donut/donut.d.ts +3 -3
- package/lib/engine/polarNotation/donut/donut.js +47 -58
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +11 -11
- package/lib/engine/polarNotation/polarManager.js +3 -5
- package/lib/engine/transitionManager.js +4 -7
- package/lib/engine/twoDimensionalNotation/area/area.d.ts +1 -1
- package/lib/engine/twoDimensionalNotation/area/area.js +77 -62
- package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +4 -10
- package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +3 -3
- package/lib/engine/twoDimensionalNotation/area/areaHelper.js +21 -13
- package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +2 -2
- package/lib/engine/twoDimensionalNotation/bar/bar.js +70 -67
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +40 -35
- package/lib/engine/twoDimensionalNotation/dot/dotChart.js +60 -42
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +7 -7
- package/lib/engine/twoDimensionalNotation/line/line.d.ts +4 -4
- package/lib/engine/twoDimensionalNotation/line/line.js +45 -28
- package/lib/engine/twoDimensionalNotation/line/lineBuilder.js +18 -16
- package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +2 -4
- package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +6 -6
- package/lib/engine/twoDimensionalNotation/line/lineHelper.js +26 -17
- package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +1 -1
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +25 -21
- package/lib/engine/valueFormatter.d.ts +1 -1
- package/lib/main.d.ts +1 -0
- package/lib/main.js +8 -7
- package/lib/model/chartStyleModel/chartStyleModel.js +5 -3
- package/lib/model/chartStyleModel/colorRange.js +1 -3
- package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +9 -7
- package/lib/model/dataManagerModel/dataManagerModel.js +28 -16
- package/lib/model/featuresModel/axisModel.d.ts +6 -3
- package/lib/model/featuresModel/axisModel.js +59 -32
- package/lib/model/featuresModel/axisModelService.js +2 -2
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +1 -1
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +12 -12
- package/lib/model/featuresModel/legendModel/legendModel.js +2 -2
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +4 -5
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +4 -5
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +3 -5
- package/lib/model/featuresModel/scaleModel/scaleDomainService.js +10 -12
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +8 -4
- package/lib/model/featuresModel/scaleModel/scaleModel.js +20 -12
- package/lib/model/featuresModel/scaleModel/scaleModelServices.js +5 -5
- package/lib/model/featuresModel/tooltipModel.js +1 -1
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +5 -5
- package/lib/model/helpers/modelHelper.js +6 -4
- package/lib/model/helpers/twoDimensionalModelHelper.d.ts +1 -1
- package/lib/model/helpers/twoDimensionalModelHelper.js +23 -23
- package/lib/model/helpers/unitsReader.js +1 -1
- package/lib/model/margin/marginModel.js +1 -1
- package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -0
- package/lib/model/margin/twoDim/twoDimMarginModel.js +38 -28
- package/lib/model/model.d.ts +17 -4
- package/lib/model/modelBuilder.d.ts +4 -4
- package/lib/model/modelBuilder.js +19 -18
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +1 -1
- package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.d.ts +5 -0
- package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.js +8 -0
- package/lib/model/modelInstance/configReader.js +11 -10
- package/lib/model/modelInstance/dataModel/dataRepository.js +5 -5
- package/lib/model/modelInstance/modelInstance.d.ts +4 -2
- package/lib/model/modelInstance/modelInstance.js +5 -3
- package/lib/model/modelInstance/titleConfigReader.js +5 -5
- package/lib/model/notations/polar/donut/donutModel.js +1 -1
- package/lib/model/notations/polar/polarModel.js +6 -6
- package/lib/model/notations/twoDimensional/styles.d.ts +2 -2
- package/lib/model/notations/twoDimensional/styles.js +8 -8
- package/lib/model/notations/twoDimensionalModel.d.ts +0 -1
- package/lib/model/notations/twoDimensionalModel.js +32 -29
- package/package.json +59 -59
- package/tsconfig.production.json +14 -24
- package/README.md +0 -2
|
@@ -11,10 +11,10 @@ export class DataManagerModel {
|
|
|
11
11
|
return scopedData;
|
|
12
12
|
}
|
|
13
13
|
static initDataScope(config, data, designerConfig, legendBlock, modelInstance) {
|
|
14
|
-
if (config.options.type ===
|
|
14
|
+
if (config.options.type === "2d") {
|
|
15
15
|
this.initDataScopeFor2D(config.options, modelInstance, data, designerConfig);
|
|
16
16
|
}
|
|
17
|
-
else if (config.options.type ===
|
|
17
|
+
else if (config.options.type === "polar") {
|
|
18
18
|
this.initDataScopeForPolar(config.options, modelInstance, data, legendBlock, designerConfig.canvas.legendBlock);
|
|
19
19
|
}
|
|
20
20
|
this.initScopedData(data, modelInstance, config);
|
|
@@ -24,12 +24,12 @@ export class DataManagerModel {
|
|
|
24
24
|
modelInstance.dataModel.repository.initScopedFullSource(preparedData);
|
|
25
25
|
}
|
|
26
26
|
static getDataValuesByKeyField(data, dataSourceName, keyFieldName) {
|
|
27
|
-
return data[dataSourceName].map(dataRow => dataRow[keyFieldName]);
|
|
27
|
+
return data[dataSourceName].map((dataRow) => dataRow[keyFieldName]);
|
|
28
28
|
}
|
|
29
29
|
static initDataScopeFor2D(configOptions, modelInstance, data, designerConfig) {
|
|
30
30
|
modelInstance.dataModel.initMaxRecordsAmount(configOptions.data.maxRecordsAmount);
|
|
31
31
|
const axisLength = AxisModel.getAxisLength(configOptions.orientation, modelInstance.canvasModel);
|
|
32
|
-
const uniqueKeys = ModelHelper.getUniqueValues(data[configOptions.data.dataSource].map(d => d[configOptions.data.keyField.name]));
|
|
32
|
+
const uniqueKeys = ModelHelper.getUniqueValues(data[configOptions.data.dataSource].map((d) => d[configOptions.data.keyField.name]));
|
|
33
33
|
const dataLength = uniqueKeys.length;
|
|
34
34
|
const limit = this.getDataLimitByItemSize(this.getElementsInGroupAmount(configOptions), dataLength, axisLength, designerConfig.canvas.chartOptions.bar);
|
|
35
35
|
const allowableKeys = uniqueKeys.slice(0, limit);
|
|
@@ -40,7 +40,7 @@ export class DataManagerModel {
|
|
|
40
40
|
modelInstance.dataModel.initMaxRecordsAmount(configOptions.data.maxRecordsAmount);
|
|
41
41
|
const canvasModel = modelInstance.canvasModel;
|
|
42
42
|
const keyFieldName = configOptions.data.keyField.name;
|
|
43
|
-
const keys = data[configOptions.data.dataSource].map(dataRow => dataRow[keyFieldName]);
|
|
43
|
+
const keys = data[configOptions.data.dataSource].map((dataRow) => dataRow[keyFieldName]);
|
|
44
44
|
if (!configOptions.legend.show) {
|
|
45
45
|
canvasModel.legendCanvas.setPosition("off");
|
|
46
46
|
modelInstance.dataModel.initScope(this.getMaximumPossibleScope(keys, modelInstance.dataModel));
|
|
@@ -48,7 +48,8 @@ export class DataManagerModel {
|
|
|
48
48
|
}
|
|
49
49
|
let position = PolarModel.getLegendPositionByBlockSize(modelInstance.canvasModel);
|
|
50
50
|
let { amount: maxItemsNumber, size } = this.getLegendDataParams(position, keys, legendCanvas, canvasModel, legendBlock);
|
|
51
|
-
if (position === "right" &&
|
|
51
|
+
if (position === "right" &&
|
|
52
|
+
!PolarModel.doesChartBlockHasEnoughWidthForContainsLegend(canvasModel.getChartBlockWidth(), size.width, legendBlock.coordinate)) {
|
|
52
53
|
const doesFreeSpaceExist = PolarModel.doesChartBlockHasEnoughHeightForContainsLegend(canvasModel.getChartBlockHeight(), legendBlock.coordinate);
|
|
53
54
|
if (doesFreeSpaceExist) {
|
|
54
55
|
const newParams = this.getLegendDataParams("bottom", keys, legendCanvas, canvasModel, legendBlock);
|
|
@@ -66,16 +67,21 @@ export class DataManagerModel {
|
|
|
66
67
|
}
|
|
67
68
|
//TODO: position type
|
|
68
69
|
static getLegendDataParams(position, keys, legendCanvas, canvasModel, legendBlock) {
|
|
69
|
-
const legendItemContentOptions = keys.map(k => ({
|
|
70
|
+
const legendItemContentOptions = keys.map((k) => ({
|
|
70
71
|
text: k,
|
|
71
72
|
markerSize: styledElementValues.defaultLegendMarkerSizes,
|
|
72
73
|
wrapperSize: { marginRightPx: styledElementValues.legend.inlineDynamicItemWrapperMarginRightPx }
|
|
73
74
|
}));
|
|
74
|
-
if (position ===
|
|
75
|
+
if (position === "right") {
|
|
75
76
|
return LegendCanvasModel.findElementsAmountByLegendSize(legendItemContentOptions, position, this.polarMarginCalculator.getMaxLegendWidth(legendCanvas, canvasModel.getBlockSize().width), canvasModel.getChartBlockHeight() - legendBlock.coordinate.right.margin.bottom);
|
|
76
77
|
}
|
|
77
78
|
else {
|
|
78
|
-
return LegendCanvasModel.findElementsAmountByLegendSize(legendItemContentOptions, position, canvasModel.getChartBlockWidth() -
|
|
79
|
+
return LegendCanvasModel.findElementsAmountByLegendSize(legendItemContentOptions, position, canvasModel.getChartBlockWidth() -
|
|
80
|
+
legendBlock.coordinate.bottom.margin.left -
|
|
81
|
+
legendBlock.coordinate.bottom.margin.right, canvasModel.getChartBlockHeight() -
|
|
82
|
+
legendBlock.coordinate.bottom.margin.bottom -
|
|
83
|
+
legendBlock.coordinate.bottom.margin.top -
|
|
84
|
+
MIN_DONUT_BLOCK_SIZE);
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
static getMaximumPossibleScope(keys, dataModel) {
|
|
@@ -90,13 +96,13 @@ export class DataManagerModel {
|
|
|
90
96
|
* @param chartsLength
|
|
91
97
|
*/
|
|
92
98
|
static getElementsInGroupAmount(configOptions) {
|
|
93
|
-
const bars = this.getBarLikeChartsInGroupAmount(configOptions.charts,
|
|
94
|
-
const dots = configOptions.charts.some(chart => chart.type ===
|
|
99
|
+
const bars = this.getBarLikeChartsInGroupAmount(configOptions.charts, "bar");
|
|
100
|
+
const dots = configOptions.charts.some((chart) => chart.type === "dot") ? 1 : 0;
|
|
95
101
|
return Math.max(bars, dots);
|
|
96
102
|
}
|
|
97
103
|
static getBarLikeChartsInGroupAmount(charts, type) {
|
|
98
104
|
let barsAmount = 0;
|
|
99
|
-
charts.forEach(chart => {
|
|
105
|
+
charts.forEach((chart) => {
|
|
100
106
|
if (chart.type === type && chart.isSegmented)
|
|
101
107
|
barsAmount += 1; // в сегментированном баре все valueFields находятся внутри одного бара, поэтому бар всегда один.
|
|
102
108
|
else if (chart.type === type)
|
|
@@ -110,15 +116,21 @@ export class DataManagerModel {
|
|
|
110
116
|
return newData;
|
|
111
117
|
}
|
|
112
118
|
static getScopedChartData(data, allowableKeys, keyFieldName) {
|
|
113
|
-
return data.filter(d => allowableKeys.findIndex(key => key === d[keyFieldName]) !== -1);
|
|
119
|
+
return data.filter((d) => allowableKeys.findIndex((key) => key === d[keyFieldName]) !== -1);
|
|
114
120
|
}
|
|
115
121
|
static getDataLimitByItemSize(elementsInGroupAmount, dataLength, axisLength, barOptions) {
|
|
116
|
-
let sumSize = dataLength *
|
|
122
|
+
let sumSize = dataLength *
|
|
123
|
+
(elementsInGroupAmount * barOptions.minBarWidth +
|
|
124
|
+
(elementsInGroupAmount - 1) * barOptions.barDistance +
|
|
125
|
+
barOptions.groupMinDistance);
|
|
117
126
|
while (dataLength !== 0 && axisLength < sumSize) {
|
|
118
127
|
dataLength--;
|
|
119
128
|
// find whole space for bars in group + distance between bars + group distance
|
|
120
|
-
sumSize =
|
|
121
|
-
*
|
|
129
|
+
sumSize =
|
|
130
|
+
dataLength *
|
|
131
|
+
(elementsInGroupAmount * barOptions.minBarWidth +
|
|
132
|
+
(elementsInGroupAmount - 1) * barOptions.barDistance +
|
|
133
|
+
barOptions.groupMinDistance);
|
|
122
134
|
}
|
|
123
135
|
return dataLength;
|
|
124
136
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxisPosition, ChartOrientation, MdtChartsDataSource, NumberAxisOptions, AxisLabelPosition, MdtChartsTwoDimensionalOptions, DiscreteAxisOptions, NumberSecondaryAxisOptions, AxisLabelFormatter } from "../../config/config";
|
|
2
|
-
import { AxisModelOptions, Orient } from "../model";
|
|
2
|
+
import { AxisModelOptions, Orient, ScaleValueModel, TickAmountPolicy } from "../model";
|
|
3
3
|
import { AxisType } from "../modelBuilder";
|
|
4
4
|
import { AxisLabelCanvas, TooltipSettings } from "../../designer/designerConfig";
|
|
5
5
|
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
@@ -9,11 +9,12 @@ export interface LabelSize {
|
|
|
9
9
|
}
|
|
10
10
|
export declare const MINIMAL_VERTICAL_STEP_SIZE = 60;
|
|
11
11
|
export declare const MINIMAL_HORIZONTAL_STEP_SIZE = 100;
|
|
12
|
+
export declare const LABEL_ELEMENT_HEIGHT_PX = 17;
|
|
12
13
|
export declare class AxisModel {
|
|
13
14
|
private static service;
|
|
14
15
|
static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings, getZeroCoordinate?: () => number): AxisModelOptions;
|
|
15
|
-
static getMainValueAxis(defaultFormatter: AxisLabelFormatter, orient: ChartOrientation, position: AxisPosition, axisConfig: NumberAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel): AxisModelOptions;
|
|
16
|
-
static getSecondaryValueAxis(defaultFormatter: AxisLabelFormatter, orient: ChartOrientation, mainAxisPosition: AxisPosition, axisConfig: NumberSecondaryAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel): AxisModelOptions;
|
|
16
|
+
static getMainValueAxis(defaultFormatter: AxisLabelFormatter, orient: ChartOrientation, position: AxisPosition, axisConfig: NumberAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, scaleInfo: ScaleValueModel): AxisModelOptions;
|
|
17
|
+
static getSecondaryValueAxis(defaultFormatter: AxisLabelFormatter, orient: ChartOrientation, mainAxisPosition: AxisPosition, axisConfig: NumberSecondaryAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, scaleInfo: ScaleValueModel): AxisModelOptions;
|
|
17
18
|
private static getValueAxis;
|
|
18
19
|
static getAxisLength(chartOrientation: ChartOrientation, canvasModel: CanvasModel): number;
|
|
19
20
|
static getAxisOrient(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition): Orient;
|
|
@@ -22,5 +23,7 @@ export declare class AxisModel {
|
|
|
22
23
|
static getKeyAxisLabelPosition(canvasModel: CanvasModel, scopedDataLength: number, axisConfig?: DiscreteAxisOptions): AxisLabelPosition;
|
|
23
24
|
static getLabelSize(labelMaxWidth: number, labelTexts: string[]): LabelSize;
|
|
24
25
|
static getRoundValue(value: number): number;
|
|
26
|
+
static getTickAmountPolicy(orient: ChartOrientation, axisConfig: NumberAxisOptions | NumberSecondaryAxisOptions, scaleInfo: ScaleValueModel): TickAmountPolicy;
|
|
25
27
|
private static getKeyAxisTranslateModel;
|
|
28
|
+
private static getTickStep;
|
|
26
29
|
}
|
|
@@ -3,8 +3,10 @@ import { AxisType } from "../modelBuilder";
|
|
|
3
3
|
import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
|
|
4
4
|
import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
|
|
5
5
|
import { AxisModelService, AxisModelTickCalculator, showAllTicks } from "./axisModelService";
|
|
6
|
+
import { max, min } from "d3-array";
|
|
6
7
|
export const MINIMAL_VERTICAL_STEP_SIZE = 60;
|
|
7
8
|
export const MINIMAL_HORIZONTAL_STEP_SIZE = 100;
|
|
9
|
+
export const LABEL_ELEMENT_HEIGHT_PX = 17;
|
|
8
10
|
const DEFAULT_AXIS_LINE_VISIBLE = true;
|
|
9
11
|
export class AxisModel {
|
|
10
12
|
static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings, getZeroCoordinate) {
|
|
@@ -14,38 +16,42 @@ export class AxisModel {
|
|
|
14
16
|
const translate = this.getKeyAxisTranslateModel(orientation, axisConfig.position, canvasModel, getZeroCoordinate);
|
|
15
17
|
const tickCalculator = new AxisModelTickCalculator(data[dataOptions.dataSource], (_a = options.axis.key.labels) === null || _a === void 0 ? void 0 : _a.showRule);
|
|
16
18
|
return {
|
|
17
|
-
type:
|
|
19
|
+
type: "key",
|
|
18
20
|
orient: AxisModel.getAxisOrient(AxisType.Key, orientation, axisConfig.position),
|
|
19
21
|
translate,
|
|
20
|
-
cssClass:
|
|
22
|
+
cssClass: "key-axis",
|
|
21
23
|
ticks: axisConfig.ticks,
|
|
22
24
|
labels: {
|
|
23
|
-
maxSize: AxisModel.getLabelSize(labelConfig.maxSize.main, data[dataOptions.dataSource].map(d => d[dataOptions.keyField.name])).width,
|
|
24
|
-
position: AxisModel.getKeyAxisLabelPosition(canvasModel, DataManagerModel.getDataValuesByKeyField(data, dataOptions.dataSource, dataOptions.keyField.name)
|
|
25
|
+
maxSize: AxisModel.getLabelSize(labelConfig.maxSize.main, data[dataOptions.dataSource].map((d) => d[dataOptions.keyField.name])).width,
|
|
26
|
+
position: AxisModel.getKeyAxisLabelPosition(canvasModel, DataManagerModel.getDataValuesByKeyField(data, dataOptions.dataSource, dataOptions.keyField.name)
|
|
27
|
+
.length, axisConfig),
|
|
25
28
|
visible: !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(charts, orientation),
|
|
26
|
-
defaultTooltip: tooltipSettings.position ===
|
|
29
|
+
defaultTooltip: tooltipSettings.position === "fixed",
|
|
27
30
|
showTick: tickCalculator.createFunctionCalculator(this.getAxisLength(orientation, canvasModel)),
|
|
28
|
-
linearTickStep: MINIMAL_HORIZONTAL_STEP_SIZE
|
|
31
|
+
linearTickStep: MINIMAL_HORIZONTAL_STEP_SIZE,
|
|
32
|
+
tickAmountSettings: {
|
|
33
|
+
policy: { type: "auto" }
|
|
34
|
+
}
|
|
29
35
|
},
|
|
30
36
|
visibility: axisConfig.visibility,
|
|
31
37
|
line: {
|
|
32
38
|
visible: (_c = (_b = axisConfig.line) === null || _b === void 0 ? void 0 : _b.visible) !== null && _c !== void 0 ? _c : DEFAULT_AXIS_LINE_VISIBLE
|
|
33
39
|
},
|
|
34
40
|
browserTooltip: {
|
|
35
|
-
format: value => value
|
|
41
|
+
format: (value) => value
|
|
36
42
|
}
|
|
37
43
|
};
|
|
38
44
|
}
|
|
39
|
-
static getMainValueAxis(defaultFormatter, orient, position, axisConfig, labelConfig, canvasModel) {
|
|
40
|
-
return this.getValueAxis(defaultFormatter, orient, position,
|
|
45
|
+
static getMainValueAxis(defaultFormatter, orient, position, axisConfig, labelConfig, canvasModel, scaleInfo) {
|
|
46
|
+
return this.getValueAxis(defaultFormatter, orient, position, "value-axis", axisConfig, labelConfig, canvasModel, scaleInfo);
|
|
41
47
|
}
|
|
42
|
-
static getSecondaryValueAxis(defaultFormatter, orient, mainAxisPosition, axisConfig, labelConfig, canvasModel) {
|
|
43
|
-
return this.getValueAxis(defaultFormatter, orient, mainAxisPosition === "start" ? "end" : "start",
|
|
48
|
+
static getSecondaryValueAxis(defaultFormatter, orient, mainAxisPosition, axisConfig, labelConfig, canvasModel, scaleInfo) {
|
|
49
|
+
return this.getValueAxis(defaultFormatter, orient, mainAxisPosition === "start" ? "end" : "start", "value-secondary-axis", axisConfig, labelConfig, canvasModel, scaleInfo);
|
|
44
50
|
}
|
|
45
|
-
static getValueAxis(defaultFormatter, orient, position, cssClass, axisConfig, labelConfig, canvasModel) {
|
|
46
|
-
var _a, _b
|
|
51
|
+
static getValueAxis(defaultFormatter, orient, position, cssClass, axisConfig, labelConfig, canvasModel, scaleInfo) {
|
|
52
|
+
var _a, _b;
|
|
47
53
|
return {
|
|
48
|
-
type:
|
|
54
|
+
type: "value",
|
|
49
55
|
orient: AxisModel.getAxisOrient(AxisType.Value, orient, position),
|
|
50
56
|
translate: {
|
|
51
57
|
translateX: AxisModel.getAxisTranslateX(AxisType.Value, orient, position, canvasModel),
|
|
@@ -55,23 +61,26 @@ export class AxisModel {
|
|
|
55
61
|
ticks: axisConfig.ticks,
|
|
56
62
|
labels: {
|
|
57
63
|
maxSize: labelConfig.maxSize.main,
|
|
58
|
-
position:
|
|
64
|
+
position: "straight",
|
|
59
65
|
visible: true,
|
|
60
66
|
defaultTooltip: true,
|
|
61
67
|
showTick: showAllTicks,
|
|
62
|
-
linearTickStep:
|
|
68
|
+
linearTickStep: this.getTickStep(orient, axisConfig),
|
|
69
|
+
tickAmountSettings: {
|
|
70
|
+
policy: this.getTickAmountPolicy(orient, axisConfig, scaleInfo)
|
|
71
|
+
}
|
|
63
72
|
},
|
|
64
73
|
visibility: axisConfig.visibility,
|
|
65
74
|
line: {
|
|
66
|
-
visible: (
|
|
75
|
+
visible: (_b = (_a = axisConfig.line) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : DEFAULT_AXIS_LINE_VISIBLE
|
|
67
76
|
},
|
|
68
77
|
browserTooltip: {
|
|
69
|
-
format: value => defaultFormatter(value)
|
|
78
|
+
format: (value) => defaultFormatter(value)
|
|
70
79
|
}
|
|
71
80
|
};
|
|
72
81
|
}
|
|
73
82
|
static getAxisLength(chartOrientation, canvasModel) {
|
|
74
|
-
if (chartOrientation ===
|
|
83
|
+
if (chartOrientation === "horizontal") {
|
|
75
84
|
return canvasModel.getChartBlockHeight();
|
|
76
85
|
}
|
|
77
86
|
else {
|
|
@@ -79,28 +88,28 @@ export class AxisModel {
|
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
90
|
static getAxisOrient(axisType, chartOrientation, axisPosition) {
|
|
82
|
-
if (chartOrientation ===
|
|
83
|
-
if (axisPosition ===
|
|
84
|
-
return axisType === AxisType.Key ?
|
|
85
|
-
return axisType === AxisType.Key ?
|
|
91
|
+
if (chartOrientation === "vertical") {
|
|
92
|
+
if (axisPosition === "start")
|
|
93
|
+
return axisType === AxisType.Key ? "top" : "left";
|
|
94
|
+
return axisType === AxisType.Key ? "bottom" : "right";
|
|
86
95
|
}
|
|
87
|
-
if (axisPosition ===
|
|
88
|
-
return axisType === AxisType.Key ?
|
|
89
|
-
return axisType === AxisType.Key ?
|
|
96
|
+
if (axisPosition === "start")
|
|
97
|
+
return axisType === AxisType.Key ? "left" : "top";
|
|
98
|
+
return axisType === AxisType.Key ? "right" : "bottom";
|
|
90
99
|
}
|
|
91
100
|
static getAxisTranslateX(axisType, chartOrientation, axisPosition, canvasModel) {
|
|
92
101
|
const orient = AxisModel.getAxisOrient(axisType, chartOrientation, axisPosition);
|
|
93
|
-
if (orient ===
|
|
102
|
+
if (orient === "top" || orient === "left")
|
|
94
103
|
return canvasModel.getMarginSide("left");
|
|
95
|
-
else if (orient ===
|
|
104
|
+
else if (orient === "bottom")
|
|
96
105
|
return canvasModel.getMarginSide("left");
|
|
97
106
|
return canvasModel.getBlockSize().width - canvasModel.getMarginSide("right");
|
|
98
107
|
}
|
|
99
108
|
static getAxisTranslateY(axisType, chartOrientation, axisPosition, canvasModel) {
|
|
100
109
|
const orient = AxisModel.getAxisOrient(axisType, chartOrientation, axisPosition);
|
|
101
|
-
if (orient ===
|
|
110
|
+
if (orient === "top" || orient === "left")
|
|
102
111
|
return canvasModel.getMarginSide("top");
|
|
103
|
-
else if (orient ===
|
|
112
|
+
else if (orient === "bottom")
|
|
104
113
|
return canvasModel.getBlockSize().height - canvasModel.getMarginSide("bottom");
|
|
105
114
|
return canvasModel.getMarginSide("top");
|
|
106
115
|
}
|
|
@@ -109,9 +118,10 @@ export class AxisModel {
|
|
|
109
118
|
return this.service.getKeyAxisLabelPosition(canvasModel.getChartBlockWidth(), scopedDataLength, (_a = axisConfig === null || axisConfig === void 0 ? void 0 : axisConfig.labels) === null || _a === void 0 ? void 0 : _a.position);
|
|
110
119
|
}
|
|
111
120
|
static getLabelSize(labelMaxWidth, labelTexts) {
|
|
112
|
-
const LABEL_ELEMENT_HEIGHT_PX = 17;
|
|
113
121
|
const ONE_UPPER_SYMBOL_WIDTH_PX = 8;
|
|
114
|
-
const longestLabelLength = labelTexts.length
|
|
122
|
+
const longestLabelLength = labelTexts.length
|
|
123
|
+
? Math.max(...labelTexts.map((t) => ModelHelper.getStringScore(t)))
|
|
124
|
+
: 0;
|
|
115
125
|
const longestLabelWidth = ONE_UPPER_SYMBOL_WIDTH_PX * longestLabelLength;
|
|
116
126
|
return {
|
|
117
127
|
height: LABEL_ELEMENT_HEIGHT_PX,
|
|
@@ -131,6 +141,19 @@ export class AxisModel {
|
|
|
131
141
|
const roundedNumber = roundedFirstTwoDigits * Math.pow(10, valueStr.length - 2);
|
|
132
142
|
return sign * roundedNumber;
|
|
133
143
|
}
|
|
144
|
+
static getTickAmountPolicy(orient, axisConfig, scaleInfo) {
|
|
145
|
+
const axisLength = scaleInfo.range.end - scaleInfo.range.start;
|
|
146
|
+
const linearTickStep = this.getTickStep(orient, axisConfig);
|
|
147
|
+
let tickAmountPolicy;
|
|
148
|
+
if (Math.floor(axisLength / linearTickStep) > 2) {
|
|
149
|
+
tickAmountPolicy = { type: "amount", amount: Math.floor(axisLength / linearTickStep) };
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const roundedMaxValue = this.getRoundValue(max(scaleInfo.domain));
|
|
153
|
+
tickAmountPolicy = { type: "constant", values: [min(scaleInfo.domain), roundedMaxValue] };
|
|
154
|
+
}
|
|
155
|
+
return tickAmountPolicy;
|
|
156
|
+
}
|
|
134
157
|
static getKeyAxisTranslateModel(chartOrientation, axisPosition, canvasModel, getZeroCoordinate) {
|
|
135
158
|
let translateY;
|
|
136
159
|
let translateX;
|
|
@@ -151,5 +174,9 @@ export class AxisModel {
|
|
|
151
174
|
translateY
|
|
152
175
|
};
|
|
153
176
|
}
|
|
177
|
+
static getTickStep(orient, axisConfig) {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
return ((_b = (_a = axisConfig.labels) === null || _a === void 0 ? void 0 : _a.stepSize) !== null && _b !== void 0 ? _b : (orient === "horizontal" ? MINIMAL_HORIZONTAL_STEP_SIZE : MINIMAL_VERTICAL_STEP_SIZE));
|
|
180
|
+
}
|
|
154
181
|
}
|
|
155
182
|
AxisModel.service = new AxisModelService();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataLegendParams } from "../../dataManagerModel/dataManagerModel";
|
|
2
2
|
import { LegendPosition } from "../../model";
|
|
3
|
-
export declare type LegendItemsDirection =
|
|
3
|
+
export declare type LegendItemsDirection = "row" | "column";
|
|
4
4
|
export interface LegendItemContentOptions {
|
|
5
5
|
text: string;
|
|
6
6
|
markerSize: {
|
|
@@ -6,16 +6,16 @@ export class LegendCanvasModel {
|
|
|
6
6
|
document.body.append(legendWrapper);
|
|
7
7
|
let amount = 0;
|
|
8
8
|
for (let i = 0; i < items.length; i++) {
|
|
9
|
-
const itemWrapper = document.createElement(
|
|
10
|
-
const colorBlock = document.createElement(
|
|
11
|
-
const textBlock = document.createElement(
|
|
9
|
+
const itemWrapper = document.createElement("div");
|
|
10
|
+
const colorBlock = document.createElement("span");
|
|
11
|
+
const textBlock = document.createElement("span");
|
|
12
12
|
itemWrapper.classList.add("legend-item");
|
|
13
|
-
if (position ===
|
|
14
|
-
itemWrapper.classList.add(
|
|
15
|
-
textBlock.classList.add(
|
|
13
|
+
if (position === "bottom" || position === "top") {
|
|
14
|
+
itemWrapper.classList.add("legend-item-inline");
|
|
15
|
+
textBlock.classList.add("legend-label-nowrap");
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
itemWrapper.classList.add(
|
|
18
|
+
itemWrapper.classList.add("legend-item-row");
|
|
19
19
|
}
|
|
20
20
|
// colorBlock.classList.add(CLASSES.legendColor);
|
|
21
21
|
colorBlock.style.display = "inline-block";
|
|
@@ -30,7 +30,7 @@ export class LegendCanvasModel {
|
|
|
30
30
|
amount++;
|
|
31
31
|
if (legendWrapper.offsetHeight > legendBlockHeight) {
|
|
32
32
|
itemWrapper.remove();
|
|
33
|
-
if (legendBlockHeight - legendWrapper.offsetHeight >= 15 && position !==
|
|
33
|
+
if (legendBlockHeight - legendWrapper.offsetHeight >= 15 && position !== "bottom" && position !== "top")
|
|
34
34
|
amount = amount; //TODO: remove
|
|
35
35
|
else
|
|
36
36
|
amount -= 1;
|
|
@@ -48,15 +48,15 @@ export class LegendCanvasModel {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
static getLegendWrapperEl(legendBlockWidth, itemsDirection) {
|
|
51
|
-
const legendWrapper = document.createElement(
|
|
52
|
-
legendWrapper.style.opacity =
|
|
53
|
-
legendWrapper.style.position =
|
|
51
|
+
const legendWrapper = document.createElement("div");
|
|
52
|
+
legendWrapper.style.opacity = "0";
|
|
53
|
+
legendWrapper.style.position = "absolute";
|
|
54
54
|
legendWrapper.style.display = "flex";
|
|
55
55
|
if (itemsDirection === "column")
|
|
56
56
|
legendWrapper.classList.add("legend-block-column");
|
|
57
57
|
else
|
|
58
58
|
legendWrapper.classList.add("legend-block-row", "legend-wrapper-with-wrap");
|
|
59
|
-
legendWrapper.style.maxWidth = legendBlockWidth +
|
|
59
|
+
legendWrapper.style.maxWidth = legendBlockWidth + "px";
|
|
60
60
|
return legendWrapper;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -31,11 +31,11 @@ export class LegendModel {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
static getLegendItemClass(itemsPosition) {
|
|
34
|
-
return itemsPosition ===
|
|
34
|
+
return itemsPosition === "column" ? "legend-item-row" : "legend-item-inline";
|
|
35
35
|
}
|
|
36
36
|
static appendToGlobalMarginValuesLegendMargin(canvasModel, position, legendBlockModel) {
|
|
37
37
|
const legendCoordinate = legendBlockModel.coordinate;
|
|
38
|
-
if (position ===
|
|
38
|
+
if (position === "left" || position === "right")
|
|
39
39
|
canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.left + legendCoordinate[position].margin.right);
|
|
40
40
|
else
|
|
41
41
|
canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom);
|
|
@@ -12,7 +12,7 @@ export class LegendPolarMarginCalculator {
|
|
|
12
12
|
const maxWidthNumber = parseInt(maxWidth);
|
|
13
13
|
if (unit === "px")
|
|
14
14
|
return maxWidthNumber;
|
|
15
|
-
return maxWidthNumber / 100 * blockWidth;
|
|
15
|
+
return (maxWidthNumber / 100) * blockWidth;
|
|
16
16
|
}
|
|
17
17
|
updateMarginObj(legendBlockModel, legendPosition, legendSize, canvasModel) {
|
|
18
18
|
if (legendSize !== 0) {
|
|
@@ -10,13 +10,13 @@ export class TwoDimLegendModel {
|
|
|
10
10
|
const canvasModel = modelInstance.canvasModel;
|
|
11
11
|
const legendPosition = this.getLegendModel(legendOptions).position;
|
|
12
12
|
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
13
|
-
if (legendPosition !==
|
|
13
|
+
if (legendPosition !== "off") {
|
|
14
14
|
const legendItemInfo = this.configReader.getLegendItemInfo();
|
|
15
|
-
const legendSize = LegendCanvasModel.findElementsAmountByLegendSize(legendItemInfo.map(i => ({
|
|
15
|
+
const legendSize = LegendCanvasModel.findElementsAmountByLegendSize(legendItemInfo.map((i) => ({
|
|
16
16
|
text: i.text,
|
|
17
17
|
markerSize: Object.assign(Object.assign({}, styledElementValues.defaultLegendMarkerSizes), { widthPx: getWidthOfLegendMarkerByType(i.chartType) }),
|
|
18
18
|
wrapperSize: { marginRightPx: styledElementValues.legend.inlineItemWrapperMarginRightPx }
|
|
19
|
-
})),
|
|
19
|
+
})), "top", modelInstance.canvasModel.getBlockSize().width, legendBlockModel.static.maxLinesAmount * styledElementValues.legend.inlineLegendOneLineHeightPx).size.height;
|
|
20
20
|
canvasModel.increaseMarginSide(legendPosition, legendSize);
|
|
21
21
|
if (legendSize !== 0)
|
|
22
22
|
LegendModel.appendToGlobalMarginValuesLegendMargin(canvasModel, legendPosition, legendBlockModel);
|
|
@@ -25,8 +25,7 @@ export class TwoDimLegendModel {
|
|
|
25
25
|
}
|
|
26
26
|
getLegendModel(legendOptions) {
|
|
27
27
|
var _a;
|
|
28
|
-
const position = legendOptions.show
|
|
29
|
-
? (_a = legendOptions.position) !== null && _a !== void 0 ? _a : "top" : "off";
|
|
28
|
+
const position = legendOptions.show ? (_a = legendOptions.position) !== null && _a !== void 0 ? _a : "top" : "off";
|
|
30
29
|
return {
|
|
31
30
|
position
|
|
32
31
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ScaleLinear
|
|
1
|
+
import { ScaleLinear } from "d3-scale";
|
|
2
2
|
import { ChartOrientation, DiscreteAxisOptions } from "../../../config/config";
|
|
3
3
|
import { ScaleValueModel } from "../../model";
|
|
4
4
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
5
5
|
export declare const keyAxisLabelVerticalLog = "keyAxisLabel_vertical_margin_log";
|
|
6
6
|
export declare const keyAxisLabelHorizontalLog = "keyAxisLabel_horizontal_margin_log";
|
|
7
|
-
interface
|
|
7
|
+
export interface ScaleValueCalculatedInfo {
|
|
8
8
|
scale: ScaleValueModel;
|
|
9
|
-
scaleFn: ScaleLinear<number, number, never
|
|
9
|
+
scaleFn: ScaleLinear<number, number, never>;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Предназначен для получения нового scaleValue и уменьшения globalMargin, если ось ключей находится где-то внутри chartBlock, а не на его границе
|
|
@@ -15,6 +15,5 @@ export declare class ScaleAxisRecalcer {
|
|
|
15
15
|
private generateScaleLinear;
|
|
16
16
|
constructor(generateScaleLinear: () => ScaleValueModel);
|
|
17
17
|
recalculateMargin(canvasModel: CanvasModel, chartOrientation: ChartOrientation, keyAxis: DiscreteAxisOptions): void;
|
|
18
|
-
getScaleValue():
|
|
18
|
+
getScaleValue(): ScaleValueCalculatedInfo;
|
|
19
19
|
}
|
|
20
|
-
export {};
|
|
@@ -9,14 +9,12 @@ export class ScaleAxisRecalcer {
|
|
|
9
9
|
this.generateScaleLinear = generateScaleLinear;
|
|
10
10
|
}
|
|
11
11
|
recalculateMargin(canvasModel, chartOrientation, keyAxis) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const scaleValueFn = Scale.getScaleValue(scaleValue);
|
|
15
|
-
const coordinateOnChartBlock = (keyAxis.position === "start"
|
|
12
|
+
const { scaleFn: scaleValueFn } = this.getScaleValue();
|
|
13
|
+
const coordinateOnChartBlock = keyAxis.position === "start"
|
|
16
14
|
? scaleValueFn(0)
|
|
17
15
|
: (chartOrientation === "vertical"
|
|
18
16
|
? canvasModel.getChartBlockHeight()
|
|
19
|
-
: canvasModel.getChartBlockWidth()) - scaleValueFn(0)
|
|
17
|
+
: canvasModel.getChartBlockWidth()) - scaleValueFn(0);
|
|
20
18
|
const key = chartOrientation === "vertical" ? keyAxisLabelVerticalLog : keyAxisLabelHorizontalLog;
|
|
21
19
|
const logInfo = canvasModel.marginService.getDataByKey(key);
|
|
22
20
|
if (logInfo) {
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export function getResolvedDomain(domain, dataRows) {
|
|
2
|
-
return typeof domain ===
|
|
3
|
-
? domain({ data: dataRows })
|
|
4
|
-
: domain;
|
|
2
|
+
return typeof domain === "function" ? domain({ data: dataRows }) : domain;
|
|
5
3
|
}
|
|
6
|
-
export function getScaleLinearDomain(configDomain, dataRows, configOptions, valueGroup =
|
|
4
|
+
export function getScaleLinearDomain(configDomain, dataRows, configOptions, valueGroup = "main") {
|
|
7
5
|
const calculator = new ScaleDomainCalculator();
|
|
8
6
|
let domainPeekMin;
|
|
9
7
|
let domainPeekMax;
|
|
10
8
|
const resolvedConfigDomain = getResolvedDomain(configDomain, dataRows);
|
|
11
|
-
const charts = configOptions.charts.filter(chart => {
|
|
9
|
+
const charts = configOptions.charts.filter((chart) => {
|
|
12
10
|
var _a;
|
|
13
11
|
return ((_a = chart.data.valueGroup) !== null && _a !== void 0 ? _a : "main") === valueGroup;
|
|
14
12
|
});
|
|
@@ -20,17 +18,17 @@ export function getScaleLinearDomain(configDomain, dataRows, configOptions, valu
|
|
|
20
18
|
domainPeekMax = calculator.getScaleMaxValue(charts, dataRows);
|
|
21
19
|
else
|
|
22
20
|
domainPeekMax = resolvedConfigDomain.end;
|
|
23
|
-
if (configOptions.axis.key.position ===
|
|
21
|
+
if (configOptions.axis.key.position === "start")
|
|
24
22
|
return [domainPeekMin, domainPeekMax];
|
|
25
23
|
return [domainPeekMax, domainPeekMin];
|
|
26
24
|
}
|
|
27
25
|
export class ScaleDomainCalculator {
|
|
28
26
|
getScaleMinValue(charts, dataRows) {
|
|
29
27
|
let min = 0;
|
|
30
|
-
charts.forEach(chart => {
|
|
31
|
-
dataRows.forEach(dataRow => {
|
|
28
|
+
charts.forEach((chart) => {
|
|
29
|
+
dataRows.forEach((dataRow) => {
|
|
32
30
|
let sumInRow = 0;
|
|
33
|
-
chart.data.valueFields.forEach(field => {
|
|
31
|
+
chart.data.valueFields.forEach((field) => {
|
|
34
32
|
if (chart.isSegmented && dataRow[field.name] < 0) {
|
|
35
33
|
sumInRow += dataRow[field.name];
|
|
36
34
|
}
|
|
@@ -45,10 +43,10 @@ export class ScaleDomainCalculator {
|
|
|
45
43
|
}
|
|
46
44
|
getScaleMaxValue(charts, dataRows) {
|
|
47
45
|
let max = 0;
|
|
48
|
-
charts.forEach(chart => {
|
|
49
|
-
dataRows.forEach(dataRow => {
|
|
46
|
+
charts.forEach((chart) => {
|
|
47
|
+
dataRows.forEach((dataRow) => {
|
|
50
48
|
let sumInRow = 0;
|
|
51
|
-
chart.data.valueFields.forEach(field => {
|
|
49
|
+
chart.data.valueFields.forEach((field) => {
|
|
52
50
|
if (chart.isSegmented && dataRow[field.name] > 0)
|
|
53
51
|
sumInRow += dataRow[field.name];
|
|
54
52
|
else if (dataRow[field.name] > sumInRow)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScaleKeyModel, ScaleValueModel } from "../../model";
|
|
2
|
-
import {
|
|
2
|
+
import { MdtChartsTwoDimensionalOptions, MdtChartsDataRow } from "../../../config/config";
|
|
3
3
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
import { TwoDimConfigReader } from "../../modelInstance/configReader";
|
|
5
5
|
export declare enum ScaleType {
|
|
@@ -7,8 +7,12 @@ export declare enum ScaleType {
|
|
|
7
7
|
Value = 1
|
|
8
8
|
}
|
|
9
9
|
export declare class ScaleModel {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
private readonly options;
|
|
11
|
+
private readonly canvasModel;
|
|
12
|
+
constructor(options: MdtChartsTwoDimensionalOptions, canvasModel: CanvasModel);
|
|
13
|
+
getScaleKey(allowableKeys: string[]): ScaleKeyModel;
|
|
14
|
+
getScaleLinear(dataRows: MdtChartsDataRow[], configReader?: TwoDimConfigReader): ScaleValueModel;
|
|
15
|
+
getScaleSecondaryLinear(dataRows: MdtChartsDataRow[], configReader?: TwoDimConfigReader): ScaleValueModel;
|
|
16
|
+
private getChartsByTypes;
|
|
13
17
|
private getScaleKeyType;
|
|
14
18
|
}
|