abstract-chart 9.0.1 → 10.0.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.
- package/CHANGELOG.md +4 -0
- package/lib/axis.js +24 -76
- package/lib/axis.js.map +1 -1
- package/lib/chart.d.ts +1 -1
- package/lib/chart.d.ts.map +1 -1
- package/lib/chart.js +128 -191
- package/lib/chart.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -18
- package/lib/index.js.map +1 -1
- package/package.json +4 -3
- package/src/chart.ts +1 -1
- package/src/index.ts +2 -2
package/lib/chart.js
CHANGED
|
@@ -1,108 +1,49 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createChart = createChart;
|
|
37
|
-
exports.createChartPoint = createChartPoint;
|
|
38
|
-
exports.createChartLine = createChartLine;
|
|
39
|
-
exports.createChartStackConfig = createChartStackConfig;
|
|
40
|
-
exports.createChartStack = createChartStack;
|
|
41
|
-
exports.createChartDataAxis = createChartDataAxis;
|
|
42
|
-
exports.inverseTransformPoint = inverseTransformPoint;
|
|
43
|
-
exports.renderChart = renderChart;
|
|
44
|
-
exports.generateBackground = generateBackground;
|
|
45
|
-
exports.xAxises = xAxises;
|
|
46
|
-
exports.yAxises = yAxises;
|
|
47
|
-
exports.generateDataAxisesX = generateDataAxisesX;
|
|
48
|
-
exports.generateDataAxisesY = generateDataAxisesY;
|
|
49
|
-
exports.generateStack = generateStack;
|
|
50
|
-
exports.generateLines = generateLines;
|
|
51
|
-
exports.generatePoints = generatePoints;
|
|
52
|
-
exports.generateBars = generateBars;
|
|
53
|
-
exports.generateXAxisGridLines = generateXAxisGridLines;
|
|
54
|
-
exports.generateXAxisLabels = generateXAxisLabels;
|
|
55
|
-
exports.generateXAxisLabel = generateXAxisLabel;
|
|
56
|
-
exports.generateYAxisLines = generateYAxisLines;
|
|
57
|
-
exports.generateYAxisLabels = generateYAxisLabels;
|
|
58
|
-
exports.generateYAxisLabel = generateYAxisLabel;
|
|
59
1
|
/* eslint-disable max-lines */
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
2
|
+
import * as AI from "abstract-image";
|
|
3
|
+
import * as Axis from "./axis.js";
|
|
4
|
+
import { exhaustiveCheck } from "ts-exhaustive-check";
|
|
63
5
|
const axisLabelPosFactor = 0.65;
|
|
64
|
-
function createChart(props) {
|
|
65
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
|
|
6
|
+
export function createChart(props) {
|
|
66
7
|
return {
|
|
67
|
-
width:
|
|
68
|
-
height:
|
|
69
|
-
chartPoints:
|
|
70
|
-
chartLines:
|
|
71
|
-
chartStack:
|
|
72
|
-
chartBars:
|
|
73
|
-
chartDataAxisesBottom:
|
|
74
|
-
chartDataAxisesTop:
|
|
75
|
-
chartDataAxisesLeft:
|
|
76
|
-
chartDataAxisesRight:
|
|
77
|
-
xAxisesBottom:
|
|
78
|
-
xAxisesTop:
|
|
79
|
-
yAxisesLeft:
|
|
80
|
-
yAxisesRight:
|
|
81
|
-
backgroundColor:
|
|
82
|
-
font:
|
|
83
|
-
fontSize:
|
|
84
|
-
textColor:
|
|
85
|
-
textOutlineColor:
|
|
86
|
-
labelLayout:
|
|
8
|
+
width: props.width ?? 600,
|
|
9
|
+
height: props.height ?? 600,
|
|
10
|
+
chartPoints: props.chartPoints ?? [],
|
|
11
|
+
chartLines: props.chartLines ?? [],
|
|
12
|
+
chartStack: props.chartStack ?? createChartStack({}),
|
|
13
|
+
chartBars: props.chartBars ?? [],
|
|
14
|
+
chartDataAxisesBottom: props.chartDataAxisesBottom ?? [],
|
|
15
|
+
chartDataAxisesTop: props.chartDataAxisesTop ?? [],
|
|
16
|
+
chartDataAxisesLeft: props.chartDataAxisesLeft ?? [],
|
|
17
|
+
chartDataAxisesRight: props.chartDataAxisesRight ?? [],
|
|
18
|
+
xAxisesBottom: props.xAxisesBottom ?? [],
|
|
19
|
+
xAxisesTop: props.xAxisesTop ?? [],
|
|
20
|
+
yAxisesLeft: props.yAxisesLeft ?? [],
|
|
21
|
+
yAxisesRight: props.yAxisesRight ?? [],
|
|
22
|
+
backgroundColor: props.backgroundColor ?? AI.white,
|
|
23
|
+
font: props.font ?? "Arial",
|
|
24
|
+
fontSize: props.fontSize ?? 12,
|
|
25
|
+
textColor: props.textColor ?? AI.black,
|
|
26
|
+
textOutlineColor: props.textOutlineColor ?? AI.transparent,
|
|
27
|
+
labelLayout: props.labelLayout ?? "original",
|
|
87
28
|
padding: {
|
|
88
|
-
top:
|
|
89
|
-
right:
|
|
90
|
-
bottom:
|
|
91
|
-
left:
|
|
29
|
+
top: props.padding?.top ?? 10,
|
|
30
|
+
right: props.padding?.right ?? 10,
|
|
31
|
+
bottom: props.padding?.bottom ?? 10,
|
|
32
|
+
left: props.padding?.left ?? 10,
|
|
92
33
|
},
|
|
93
34
|
axisWidth: {
|
|
94
|
-
top:
|
|
95
|
-
right:
|
|
96
|
-
bottom:
|
|
97
|
-
left:
|
|
35
|
+
top: props.axisWidth?.top ?? 50,
|
|
36
|
+
right: props.axisWidth?.right ?? 50,
|
|
37
|
+
bottom: props.axisWidth?.bottom ?? 50,
|
|
38
|
+
left: props.axisWidth?.left ?? 50,
|
|
98
39
|
},
|
|
99
|
-
xGrid: { color:
|
|
100
|
-
yGrid: { color:
|
|
101
|
-
xPixelsPerTick:
|
|
102
|
-
yPixelsPerTick:
|
|
40
|
+
xGrid: { color: props.xGrid?.color ?? AI.gray, thickness: props.xGrid?.thickness ?? 1 },
|
|
41
|
+
yGrid: { color: props.yGrid?.color ?? AI.gray, thickness: props.yGrid?.thickness ?? 1 },
|
|
42
|
+
xPixelsPerTick: props.xPixelsPerTick ?? 40,
|
|
43
|
+
yPixelsPerTick: props.yPixelsPerTick ?? 40,
|
|
103
44
|
};
|
|
104
45
|
}
|
|
105
|
-
function createChartPoint(props) {
|
|
46
|
+
export function createChartPoint(props) {
|
|
106
47
|
const { shape = "circle", position = AI.createPoint(0, 0), color = AI.black, strokeColor = AI.black, strokeThickness = 1, size = AI.createSize(6, 6), label = "", xAxis = "bottom", yAxis = "left", fontSize, textColor, textOutlineColor, id, } = props || {};
|
|
107
48
|
return {
|
|
108
49
|
shape,
|
|
@@ -120,19 +61,19 @@ function createChartPoint(props) {
|
|
|
120
61
|
id,
|
|
121
62
|
};
|
|
122
63
|
}
|
|
123
|
-
function createChartLine(props) {
|
|
64
|
+
export function createChartLine(props) {
|
|
124
65
|
const { points = [], color = AI.black, thickness = 1, label = "", xAxis = "bottom", yAxis = "left", fontSize, textColor, textOutlineColor, id, } = props || {};
|
|
125
66
|
return { points, color, thickness, label, xAxis, yAxis, fontSize, textColor, textOutlineColor, id };
|
|
126
67
|
}
|
|
127
|
-
function createChartStackConfig(props) {
|
|
68
|
+
export function createChartStackConfig(props) {
|
|
128
69
|
const { color = AI.black, label = "" } = props || {};
|
|
129
70
|
return { color, label };
|
|
130
71
|
}
|
|
131
|
-
function createChartStack(props) {
|
|
72
|
+
export function createChartStack(props) {
|
|
132
73
|
const { points = [], xAxis = "bottom", yAxis = "left", config = [createChartStackConfig({})] } = props || {};
|
|
133
74
|
return { points, xAxis, yAxis, config };
|
|
134
75
|
}
|
|
135
|
-
function createChartDataAxis(points, label, labelRotation, tickLabelDisp, labelColor, tickLabelColor, thickness, axisColor, tickFontSize, axisFontSize, id) {
|
|
76
|
+
export function createChartDataAxis(points, label, labelRotation, tickLabelDisp, labelColor, tickLabelColor, thickness, axisColor, tickFontSize, axisFontSize, id) {
|
|
136
77
|
return {
|
|
137
78
|
points,
|
|
138
79
|
label,
|
|
@@ -147,7 +88,7 @@ function createChartDataAxis(points, label, labelRotation, tickLabelDisp, labelC
|
|
|
147
88
|
id,
|
|
148
89
|
};
|
|
149
90
|
}
|
|
150
|
-
function inverseTransformPoint(point, chart, xAxis, yAxis) {
|
|
91
|
+
export function inverseTransformPoint(point, chart, xAxis, yAxis) {
|
|
151
92
|
const padding = finalPadding(chart);
|
|
152
93
|
const xMin = padding.left;
|
|
153
94
|
const xMax = chart.width - padding.right;
|
|
@@ -180,8 +121,7 @@ function finalPadding(chart) {
|
|
|
180
121
|
chart.axisWidth.right,
|
|
181
122
|
};
|
|
182
123
|
}
|
|
183
|
-
function renderChart(chart) {
|
|
184
|
-
var _a, _b, _c, _d;
|
|
124
|
+
export function renderChart(chart) {
|
|
185
125
|
const { width, height, xAxisesBottom, xAxisesTop, yAxisesLeft, yAxisesRight } = chart;
|
|
186
126
|
const padding = finalPadding(chart);
|
|
187
127
|
const gridWidth = width - padding.left - padding.right;
|
|
@@ -193,15 +133,15 @@ function renderChart(chart) {
|
|
|
193
133
|
const renderedBackground = generateBackground(xMin, xMax, yMin, yMax, chart);
|
|
194
134
|
const xNumTicks = gridWidth / chart.xPixelsPerTick;
|
|
195
135
|
const [xleft, xRight] = [
|
|
196
|
-
yAxisesLeft[0] ?
|
|
197
|
-
yAxisesRight[0] ?
|
|
136
|
+
yAxisesLeft[0] ? yAxisesLeft[0].thickness ?? 1 : chart.xGrid.thickness / 2,
|
|
137
|
+
yAxisesRight[0] ? yAxisesRight[0].thickness ?? 1 : chart.xGrid.thickness / 2,
|
|
198
138
|
];
|
|
199
139
|
const [xAxisBottom, yAxisGridBottom] = xAxises("bottom", xNumTicks, xAxisesBottom, xMin, xMax, yMin, yMax, xleft, xRight, chart);
|
|
200
140
|
const [xAxisTop, yAxisGridTop] = xAxises("top", xNumTicks, xAxisesTop, xMin, xMax, yMin, yMax, xleft, xRight, chart);
|
|
201
141
|
const yNumTicks = gridHeight / chart.yPixelsPerTick;
|
|
202
142
|
const [yBottom, yTop] = [
|
|
203
|
-
xAxisesBottom[0] ?
|
|
204
|
-
xAxisesTop[0] ?
|
|
143
|
+
xAxisesBottom[0] ? xAxisesBottom[0].thickness ?? 1 : chart.xGrid.thickness / 2,
|
|
144
|
+
xAxisesTop[0] ? xAxisesTop[0].thickness ?? 1 : chart.xGrid.thickness / 2,
|
|
205
145
|
];
|
|
206
146
|
const [yAxisLeft, xAxisGridLeft] = yAxises("left", yNumTicks, yAxisesLeft, xMin, xMax, yMin, yMax, yBottom, yTop, chart);
|
|
207
147
|
const [yAxisRight, xAxisGridRight] = yAxises("right", yNumTicks, yAxisesRight, xMin, xMax, yMin, yMax, yBottom, yTop, chart);
|
|
@@ -238,11 +178,10 @@ function renderChart(chart) {
|
|
|
238
178
|
const size = AI.createSize(width, height);
|
|
239
179
|
return AI.createAbstractImage(topLeft, size, AI.white, components);
|
|
240
180
|
}
|
|
241
|
-
function generateBackground(xMin, xMax, yMin, yMax, chart) {
|
|
181
|
+
export function generateBackground(xMin, xMax, yMin, yMax, chart) {
|
|
242
182
|
return AI.createRectangle(AI.createPoint(xMin, yMax), AI.createPoint(xMax, yMin), AI.transparent, 0, chart.backgroundColor);
|
|
243
183
|
}
|
|
244
|
-
function xAxises(xAxis, xNumTicks, axises, xMin, xMax, yMin, yMax, xMinLineThicknessAdjustment, xMaxLineThicknessAdjustment, chart) {
|
|
245
|
-
var _a, _b, _c, _d;
|
|
184
|
+
export function xAxises(xAxis, xNumTicks, axises, xMin, xMax, yMin, yMax, xMinLineThicknessAdjustment, xMaxLineThicknessAdjustment, chart) {
|
|
246
185
|
const components = Array();
|
|
247
186
|
const gridLineComponents = Array();
|
|
248
187
|
let lineY = xAxis === "bottom" ? yMin : yMax;
|
|
@@ -253,17 +192,17 @@ function xAxises(xAxis, xNumTicks, axises, xMin, xMax, yMin, yMax, xMinLineThick
|
|
|
253
192
|
if (chart.xGrid && !axis.noTicks) {
|
|
254
193
|
gridLineComponents.push(generateXAxisGridLines(xMin, xMax, lineY + dirFactor * 10, fullGrid ? yMax : lineY, xTicks, axis, chart.xGrid));
|
|
255
194
|
}
|
|
256
|
-
const thickness =
|
|
195
|
+
const thickness = axis.thickness ?? 1;
|
|
257
196
|
const lineDisp = ix == 0 ? (xAxis === "bottom" ? thickness / 2 : -thickness / 2) : 0;
|
|
258
|
-
components.push(AI.createLine({ x: xMin - (ix == 0 ? xMinLineThicknessAdjustment : chart.xGrid.thickness / 2), y: lineY + lineDisp }, { x: xMax + (ix == 0 ? xMaxLineThicknessAdjustment : chart.xGrid.thickness / 2), y: lineY + lineDisp },
|
|
197
|
+
components.push(AI.createLine({ x: xMin - (ix == 0 ? xMinLineThicknessAdjustment : chart.xGrid.thickness / 2), y: lineY + lineDisp }, { x: xMax + (ix == 0 ? xMaxLineThicknessAdjustment : chart.xGrid.thickness / 2), y: lineY + lineDisp }, axis.axisColor ?? AI.gray, thickness));
|
|
259
198
|
if (!axis.noTicks) {
|
|
260
199
|
components.push(generateXAxisLabels(xMin, xMax, lineY + dirFactor * 12, xAxis === "bottom" ? "down" : "up", xTicks, axis, chart));
|
|
261
200
|
}
|
|
262
201
|
if (axis.label) {
|
|
263
|
-
const axisLabelPosY = lineY + dirFactor * (axisWidth - (
|
|
202
|
+
const axisLabelPosY = lineY + dirFactor * (axisWidth - (axis.axisFontSize ?? chart.fontSize));
|
|
264
203
|
switch (chart.labelLayout) {
|
|
265
204
|
case "original":
|
|
266
|
-
components.push(generateXAxisLabel(xMax + chart.padding.right, lineY + (
|
|
205
|
+
components.push(generateXAxisLabel(xMax + chart.padding.right, lineY + (axis.tickLabelDisp ?? 10), "uniform", "down", axis, chart));
|
|
267
206
|
break;
|
|
268
207
|
case "end":
|
|
269
208
|
components.push(generateXAxisLabel(xMax, axisLabelPosY, "left", "uniform", axis, chart));
|
|
@@ -272,15 +211,14 @@ function xAxises(xAxis, xNumTicks, axises, xMin, xMax, yMin, yMax, xMinLineThick
|
|
|
272
211
|
components.push(generateXAxisLabel((xMin + xMax) / 2, axisLabelPosY, "uniform", "uniform", axis, chart));
|
|
273
212
|
break;
|
|
274
213
|
default:
|
|
275
|
-
return
|
|
214
|
+
return exhaustiveCheck(chart.labelLayout);
|
|
276
215
|
}
|
|
277
216
|
}
|
|
278
217
|
lineY += dirFactor * axisWidth;
|
|
279
218
|
}
|
|
280
219
|
return [AI.createGroup(xAxis + "XAxis", components), AI.createGroup(xAxis + "XAxisGridLines", gridLineComponents)];
|
|
281
220
|
}
|
|
282
|
-
function yAxises(yAxis, yNumTicks, axises, xMin, xMax, yMin, yMax, yMinLineThicknessAdjustment, yMaxLineThicknessAdjustment, chart) {
|
|
283
|
-
var _a, _b, _c, _d;
|
|
221
|
+
export function yAxises(yAxis, yNumTicks, axises, xMin, xMax, yMin, yMax, yMinLineThicknessAdjustment, yMaxLineThicknessAdjustment, chart) {
|
|
284
222
|
const components = Array();
|
|
285
223
|
const gridLineComponents = Array();
|
|
286
224
|
let lineX = yAxis === "left" ? xMin : xMax;
|
|
@@ -291,14 +229,14 @@ function yAxises(yAxis, yNumTicks, axises, xMin, xMax, yMin, yMax, yMinLineThick
|
|
|
291
229
|
if (chart.yGrid && !axis.noTicks) {
|
|
292
230
|
gridLineComponents.push(generateYAxisLines(lineX + dirFactor * 10, fullGrid ? xMax : lineX, yMin, yMax, yTicks, axis, chart.yGrid, chart.xGrid));
|
|
293
231
|
}
|
|
294
|
-
const thickness =
|
|
232
|
+
const thickness = axis.thickness ?? 1;
|
|
295
233
|
const lineDisp = ix == 0 ? (yAxis === "left" ? -thickness / 2 : thickness / 2) : 0;
|
|
296
|
-
components.push(AI.createLine({ x: lineX + lineDisp, y: yMin + (ix == 0 ? yMinLineThicknessAdjustment : chart.yGrid.thickness / 2) }, { x: lineX + lineDisp, y: yMax - (ix == 0 ? yMaxLineThicknessAdjustment : chart.yGrid.thickness / 2) },
|
|
234
|
+
components.push(AI.createLine({ x: lineX + lineDisp, y: yMin + (ix == 0 ? yMinLineThicknessAdjustment : chart.yGrid.thickness / 2) }, { x: lineX + lineDisp, y: yMax - (ix == 0 ? yMaxLineThicknessAdjustment : chart.yGrid.thickness / 2) }, axis.axisColor ?? AI.gray, axis.thickness ?? 1));
|
|
297
235
|
if (!axis.noTicks) {
|
|
298
236
|
components.push(generateYAxisLabels(lineX + dirFactor * 12, yMin, yMax, yAxis, yTicks, axis, chart));
|
|
299
237
|
}
|
|
300
238
|
if (axis.label) {
|
|
301
|
-
const axisLabelPosX = lineX + dirFactor * (axisWidth - (
|
|
239
|
+
const axisLabelPosX = lineX + dirFactor * (axisWidth - (axis.axisFontSize ?? chart.fontSize));
|
|
302
240
|
const rotation = yAxis === "left" ? -90 : 90;
|
|
303
241
|
switch (chart.labelLayout) {
|
|
304
242
|
case "original":
|
|
@@ -311,15 +249,14 @@ function yAxises(yAxis, yNumTicks, axises, xMin, xMax, yMin, yMax, yMinLineThick
|
|
|
311
249
|
components.push(generateYAxisLabel(axisLabelPosX, (yMin + yMax) / 2, rotation, "uniform", "uniform", axis, chart));
|
|
312
250
|
break;
|
|
313
251
|
default:
|
|
314
|
-
return
|
|
252
|
+
return exhaustiveCheck(chart.labelLayout);
|
|
315
253
|
}
|
|
316
254
|
}
|
|
317
255
|
lineX += dirFactor * axisWidth;
|
|
318
256
|
}
|
|
319
257
|
return [AI.createGroup("YAxisLeft", components), AI.createGroup("YAxisLeftGridLines", gridLineComponents)];
|
|
320
258
|
}
|
|
321
|
-
function generateDataAxisesX(xAxis, axises, numTicks, xMin, xMax, yMin, yMax, chart) {
|
|
322
|
-
var _a, _b, _c, _d;
|
|
259
|
+
export function generateDataAxisesX(xAxis, axises, numTicks, xMin, xMax, yMin, yMax, chart) {
|
|
323
260
|
const components = Array();
|
|
324
261
|
let lineY = xAxis === "bottom"
|
|
325
262
|
? yMin + chart.xAxisesBottom.length * chart.axisWidth.bottom
|
|
@@ -330,7 +267,6 @@ function generateDataAxisesX(xAxis, axises, numTicks, xMin, xMax, yMin, yMax, ch
|
|
|
330
267
|
const max = Math.max(...axis.points.map((p) => p.y));
|
|
331
268
|
const linear = Axis.createLinearAxis(min, max, axis.label, axis.labelColor, axis.labelRotation, axis.tickLabelDisp, axis.thickness, axis.axisColor, axis.id);
|
|
332
269
|
const findX = (y) => {
|
|
333
|
-
var _a, _b;
|
|
334
270
|
for (let i = 0; i < axis.points.length; ++i) {
|
|
335
271
|
const p0 = i > 0 ? axis.points[i - 1] : undefined;
|
|
336
272
|
const p1 = axis.points[i];
|
|
@@ -346,12 +282,11 @@ function generateDataAxisesX(xAxis, axises, numTicks, xMin, xMax, yMin, yMax, ch
|
|
|
346
282
|
return p1.x;
|
|
347
283
|
}
|
|
348
284
|
}
|
|
349
|
-
return
|
|
285
|
+
return axis.points[axis.points.length - 1]?.x ?? 0;
|
|
350
286
|
};
|
|
351
287
|
const yValues = Axis.getTicks(numTicks, linear).map((t) => t.value);
|
|
352
288
|
const lineY2 = lineY;
|
|
353
289
|
components.push(...yValues.flatMap((y) => {
|
|
354
|
-
var _a, _b, _c, _d;
|
|
355
290
|
const tickX = findX(y);
|
|
356
291
|
const x = Axis.transformValue(tickX, xMin, xMax, chart.xAxisesBottom[0]);
|
|
357
292
|
const start = AI.createPoint(x, lineY2);
|
|
@@ -359,14 +294,14 @@ function generateDataAxisesX(xAxis, axises, numTicks, xMin, xMax, yMin, yMax, ch
|
|
|
359
294
|
const textPos = AI.createPoint(x, lineY2 + dirFactor * 12);
|
|
360
295
|
return [
|
|
361
296
|
AI.createLine(start, end, chart.xGrid.color, chart.xGrid.thickness),
|
|
362
|
-
AI.createText(textPos, formatNumber(y), chart.font,
|
|
297
|
+
AI.createText(textPos, formatNumber(y), chart.font, axis.tickFontSize ?? chart.fontSize, axis.labelColor ?? AI.black, "normal", axis.labelRotation ?? 0, "center", "uniform", xAxis === "bottom" ? "down" : "up", 0, axis.labelColor ?? AI.black, false),
|
|
363
298
|
];
|
|
364
299
|
}));
|
|
365
|
-
components.push(AI.createLine({ x: xMin, y: lineY }, { x: xMax, y: lineY },
|
|
366
|
-
const axisLabelPosY = lineY + dirFactor * (axisWidth - (
|
|
300
|
+
components.push(AI.createLine({ x: xMin, y: lineY }, { x: xMax, y: lineY }, axis.axisColor ?? AI.gray, axis.thickness ?? 1));
|
|
301
|
+
const axisLabelPosY = lineY + dirFactor * (axisWidth - (axis.axisFontSize ?? chart.fontSize));
|
|
367
302
|
switch (chart.labelLayout) {
|
|
368
303
|
case "original":
|
|
369
|
-
components.push(generateXAxisLabel(xMax + chart.padding.right, yMin + (
|
|
304
|
+
components.push(generateXAxisLabel(xMax + chart.padding.right, yMin + (axis.tickLabelDisp ?? 10), "uniform", "up", linear, chart));
|
|
370
305
|
break;
|
|
371
306
|
case "end":
|
|
372
307
|
components.push(generateXAxisLabel(xMax, axisLabelPosY, "left", "uniform", linear, chart));
|
|
@@ -375,14 +310,13 @@ function generateDataAxisesX(xAxis, axises, numTicks, xMin, xMax, yMin, yMax, ch
|
|
|
375
310
|
components.push(generateXAxisLabel((xMin + xMax) / 2, axisLabelPosY, "uniform", "uniform", linear, chart));
|
|
376
311
|
break;
|
|
377
312
|
default:
|
|
378
|
-
return
|
|
313
|
+
return exhaustiveCheck(chart.labelLayout);
|
|
379
314
|
}
|
|
380
315
|
lineY += dirFactor * axisWidth;
|
|
381
316
|
}
|
|
382
317
|
return AI.createGroup(xAxis + "XDataAxis", components);
|
|
383
318
|
}
|
|
384
|
-
function generateDataAxisesY(yAxis, axises, numTicks, xMin, xMax, yMin, yMax, chart) {
|
|
385
|
-
var _a, _b, _c, _d;
|
|
319
|
+
export function generateDataAxisesY(yAxis, axises, numTicks, xMin, xMax, yMin, yMax, chart) {
|
|
386
320
|
const components = Array();
|
|
387
321
|
let lineX = yAxis === "left"
|
|
388
322
|
? xMin - chart.yAxisesLeft.length * chart.axisWidth.left
|
|
@@ -393,7 +327,6 @@ function generateDataAxisesY(yAxis, axises, numTicks, xMin, xMax, yMin, yMax, ch
|
|
|
393
327
|
const max = Math.max(...axis.points.map((p) => p.y));
|
|
394
328
|
const linear = Axis.createLinearAxis(min, max, axis.label, axis.labelColor, axis.labelRotation, axis.tickLabelDisp, axis.thickness, axis.axisColor, axis.id);
|
|
395
329
|
const findX = (y) => {
|
|
396
|
-
var _a, _b;
|
|
397
330
|
for (let i = 0; i < axis.points.length; ++i) {
|
|
398
331
|
const p0 = i > 0 ? axis.points[i - 1] : undefined;
|
|
399
332
|
const p1 = axis.points[i];
|
|
@@ -409,12 +342,11 @@ function generateDataAxisesY(yAxis, axises, numTicks, xMin, xMax, yMin, yMax, ch
|
|
|
409
342
|
return p1.x;
|
|
410
343
|
}
|
|
411
344
|
}
|
|
412
|
-
return
|
|
345
|
+
return axis.points[axis.points.length - 1]?.x ?? 0;
|
|
413
346
|
};
|
|
414
347
|
const yValues = Axis.getTicks(numTicks, linear).map((t) => t.value);
|
|
415
348
|
const lineX2 = lineX;
|
|
416
349
|
components.push(...yValues.flatMap((y) => {
|
|
417
|
-
var _a, _b, _c;
|
|
418
350
|
const tickY = findX(y);
|
|
419
351
|
const yPx = Axis.transformValue(tickY, yMin, yMax, chart.yAxisesLeft[0]);
|
|
420
352
|
const start = AI.createPoint(lineX2, yPx);
|
|
@@ -422,15 +354,15 @@ function generateDataAxisesY(yAxis, axises, numTicks, xMin, xMax, yMin, yMax, ch
|
|
|
422
354
|
const textPos = AI.createPoint(lineX2 + dirFactor * 12, yPx);
|
|
423
355
|
return [
|
|
424
356
|
AI.createLine(start, end, chart.xGrid.color, chart.xGrid.thickness),
|
|
425
|
-
AI.createText(textPos, formatNumber(y), chart.font,
|
|
357
|
+
AI.createText(textPos, formatNumber(y), chart.font, axis.tickFontSize ?? chart.fontSize, axis.labelColor ?? AI.black, "normal", 0, "center", yAxis, "uniform", 0, axis.labelColor ?? AI.black, false),
|
|
426
358
|
];
|
|
427
359
|
}));
|
|
428
|
-
components.push(AI.createLine({ x: lineX, y: yMin }, { x: lineX, y: yMax },
|
|
360
|
+
components.push(AI.createLine({ x: lineX, y: yMin }, { x: lineX, y: yMax }, axis.axisColor ?? AI.gray, axis.thickness ?? 1));
|
|
429
361
|
const rotation = yAxis === "left" ? -90 : 90;
|
|
430
|
-
const axisLabelPosX = lineX + dirFactor * (axisWidth - (
|
|
362
|
+
const axisLabelPosX = lineX + dirFactor * (axisWidth - (axis.axisFontSize ?? chart.fontSize));
|
|
431
363
|
switch (chart.labelLayout) {
|
|
432
364
|
case "original":
|
|
433
|
-
components.push(generateYAxisLabel(xMax + chart.padding.right, yMin + (
|
|
365
|
+
components.push(generateYAxisLabel(xMax + chart.padding.right, yMin + (axis.tickLabelDisp ?? 10), rotation, "uniform", "up", linear, chart));
|
|
434
366
|
break;
|
|
435
367
|
case "end":
|
|
436
368
|
components.push(generateYAxisLabel(axisLabelPosX, yMax, rotation, "left", "uniform", linear, chart));
|
|
@@ -439,27 +371,32 @@ function generateDataAxisesY(yAxis, axises, numTicks, xMin, xMax, yMin, yMax, ch
|
|
|
439
371
|
components.push(generateYAxisLabel(axisLabelPosX, (yMin + yMax) / 2, rotation, "uniform", "uniform", linear, chart));
|
|
440
372
|
break;
|
|
441
373
|
default:
|
|
442
|
-
return
|
|
374
|
+
return exhaustiveCheck(chart.labelLayout);
|
|
443
375
|
}
|
|
444
376
|
lineX += dirFactor * axisWidth;
|
|
445
377
|
}
|
|
446
378
|
return AI.createGroup(yAxis + "YDataAxis", components);
|
|
447
379
|
}
|
|
448
|
-
function generateStack(xMin, xMax, yMin, yMax, chart) {
|
|
380
|
+
export function generateStack(xMin, xMax, yMin, yMax, chart) {
|
|
449
381
|
const pointsPos = chart.chartStack.points.map((stackPoint) => ({
|
|
450
382
|
x: stackPoint.x,
|
|
451
383
|
ys: [...stackPoint.ys.map((y) => Math.min(0, y))],
|
|
452
384
|
}));
|
|
453
|
-
const stackPos = generateUnsignedStack(xMin, xMax, yMin, yMax,
|
|
385
|
+
const stackPos = generateUnsignedStack(xMin, xMax, yMin, yMax, {
|
|
386
|
+
...chart,
|
|
387
|
+
chartStack: { ...chart.chartStack, points: pointsPos },
|
|
388
|
+
});
|
|
454
389
|
const pointsNeg = chart.chartStack.points.map((stackPoint) => ({
|
|
455
390
|
x: stackPoint.x,
|
|
456
391
|
ys: [...stackPoint.ys.map((y) => Math.max(0, y))],
|
|
457
392
|
}));
|
|
458
|
-
const stackNeg = generateUnsignedStack(xMin, xMax, yMin, yMax,
|
|
393
|
+
const stackNeg = generateUnsignedStack(xMin, xMax, yMin, yMax, {
|
|
394
|
+
...chart,
|
|
395
|
+
chartStack: { ...chart.chartStack, points: pointsNeg },
|
|
396
|
+
});
|
|
459
397
|
return AI.createGroup("Stacks", [stackPos, stackNeg]);
|
|
460
398
|
}
|
|
461
399
|
function generateUnsignedStack(xMin, xMax, yMin, yMax, chart) {
|
|
462
|
-
var _a, _b;
|
|
463
400
|
if (chart.chartStack.points.length < 2) {
|
|
464
401
|
return AI.createGroup("stack", []);
|
|
465
402
|
}
|
|
@@ -475,7 +412,7 @@ function generateUnsignedStack(xMin, xMax, yMin, yMax, chart) {
|
|
|
475
412
|
});
|
|
476
413
|
// Transpose the xPoints data to lines.
|
|
477
414
|
const lines = [];
|
|
478
|
-
for (let i = 0; i < (
|
|
415
|
+
for (let i = 0; i < (xPoints[0]?.length ?? 0); ++i) {
|
|
479
416
|
lines[i] = [];
|
|
480
417
|
for (const points of xPoints) {
|
|
481
418
|
lines[i].push(points[i]);
|
|
@@ -495,18 +432,17 @@ function generateUnsignedStack(xMin, xMax, yMin, yMax, chart) {
|
|
|
495
432
|
});
|
|
496
433
|
return AI.createGroup("Stack", polygons);
|
|
497
434
|
}
|
|
498
|
-
function generateLines(xMin, xMax, yMin, yMax, chart) {
|
|
435
|
+
export function generateLines(xMin, xMax, yMin, yMax, chart) {
|
|
499
436
|
const lines = chart.chartLines.map((l) => {
|
|
500
|
-
var _a, _b, _c, _d, _e;
|
|
501
437
|
if (l.points.length < 2) {
|
|
502
|
-
return AI.createGroup(
|
|
438
|
+
return AI.createGroup(l.label.split("<")[0] ?? "UNKNOWN", []);
|
|
503
439
|
}
|
|
504
440
|
const xAxis = l.xAxis === "top" ? chart.xAxisesTop[0] : chart.xAxisesBottom[0];
|
|
505
441
|
const yAxis = l.yAxis === "right" ? chart.yAxisesRight[0] : chart.yAxisesLeft[0];
|
|
506
442
|
const points = l.points.map((p) => Axis.transformPoint(p, xMin, xMax, yMin, yMax, xAxis, yAxis));
|
|
507
443
|
const segments = getLineSegmentsInsideChart(xMin, xMax, yMin, yMax, points);
|
|
508
444
|
const components = [];
|
|
509
|
-
const outlineColor =
|
|
445
|
+
const outlineColor = l.textOutlineColor ?? chart.textOutlineColor;
|
|
510
446
|
for (const segment of segments) {
|
|
511
447
|
components.push(AI.createPolyLine(segment.slice(), l.color, l.thickness));
|
|
512
448
|
if (l.id !== undefined) {
|
|
@@ -514,11 +450,11 @@ function generateLines(xMin, xMax, yMin, yMax, chart) {
|
|
|
514
450
|
}
|
|
515
451
|
}
|
|
516
452
|
const lastSeg = segments.at(-1);
|
|
517
|
-
const last = lastSeg
|
|
453
|
+
const last = lastSeg?.at(-1);
|
|
518
454
|
if (last) {
|
|
519
|
-
components.push(AI.createText(last, l.label, chart.font,
|
|
455
|
+
components.push(AI.createText(last, l.label, chart.font, l.fontSize ?? chart.fontSize, l.textColor ?? chart.textColor, "normal", 0, "center", textHorizontalGrowth(last.x, xMin, xMax), textVerticalGrowth(last.y, yMin, yMax), outlineColor !== AI.transparent ? 3 : 0, outlineColor, false));
|
|
520
456
|
}
|
|
521
|
-
return AI.createGroup(
|
|
457
|
+
return AI.createGroup(l.label.split("<")[0] ?? "UNKNOWN", components);
|
|
522
458
|
});
|
|
523
459
|
return AI.createGroup("Lines", lines);
|
|
524
460
|
}
|
|
@@ -561,12 +497,15 @@ function isInside(xMin, xMax, yMin, yMax, p) {
|
|
|
561
497
|
return p.x >= xMin && p.x <= xMax && p.y <= yMin && p.y >= yMax;
|
|
562
498
|
}
|
|
563
499
|
function moveInside(xMin, xMax, yMin, yMax, inside, outside) {
|
|
564
|
-
var _a, _b, _c, _d;
|
|
565
500
|
const xMinYMin = AI.createPoint(xMin, yMin);
|
|
566
501
|
const xMinYMax = AI.createPoint(xMin, yMax);
|
|
567
502
|
const xMaxYMin = AI.createPoint(xMax, yMin);
|
|
568
503
|
const xMaxYMax = AI.createPoint(xMax, yMax);
|
|
569
|
-
return (
|
|
504
|
+
return (lineLine(inside, outside, xMinYMin, xMaxYMin) ??
|
|
505
|
+
lineLine(inside, outside, xMinYMax, xMaxYMax) ??
|
|
506
|
+
lineLine(inside, outside, xMinYMin, xMinYMax) ??
|
|
507
|
+
lineLine(inside, outside, xMaxYMin, xMaxYMax) ??
|
|
508
|
+
inside);
|
|
570
509
|
}
|
|
571
510
|
function lineLine(a0, a1, b0, b1) {
|
|
572
511
|
const da = AI.createPoint(a1.x - a0.x, a1.y - a0.y);
|
|
@@ -580,55 +519,59 @@ function lineLine(a0, a1, b0, b1) {
|
|
|
580
519
|
}
|
|
581
520
|
return undefined;
|
|
582
521
|
}
|
|
583
|
-
function generatePoints(xMin, xMax, yMin, yMax, chart) {
|
|
522
|
+
export function generatePoints(xMin, xMax, yMin, yMax, chart) {
|
|
584
523
|
const points = chart.chartPoints.map((p) => {
|
|
585
|
-
var _a, _b, _c, _d;
|
|
586
524
|
const xAxis = p.xAxis === "top" ? chart.xAxisesTop[0] : chart.xAxisesBottom[0];
|
|
587
525
|
const yAxis = p.yAxis === "right" ? chart.yAxisesRight[0] : chart.yAxisesLeft[0];
|
|
588
526
|
const position = Axis.transformPoint(p.position, xMin, xMax, yMin, yMax, xAxis, yAxis);
|
|
589
|
-
const outlineColor =
|
|
527
|
+
const outlineColor = p.textOutlineColor ?? chart.textOutlineColor;
|
|
590
528
|
const components = [
|
|
591
529
|
generatePointShape(p, position, undefined),
|
|
592
|
-
AI.createText(position, p.label, chart.font,
|
|
530
|
+
AI.createText(position, p.label, chart.font, p.fontSize ?? chart.fontSize, p.textColor ?? chart.textColor, "normal", 0, "center", textHorizontalGrowth(position.x, xMin, xMax), textVerticalGrowth(position.y, yMin, yMax), outlineColor !== AI.transparent ? 3 : 0, outlineColor, false),
|
|
593
531
|
];
|
|
594
532
|
if (p.id !== undefined) {
|
|
595
|
-
components.push(generatePointShape(
|
|
533
|
+
components.push(generatePointShape({
|
|
534
|
+
...p,
|
|
535
|
+
color: AI.transparent,
|
|
536
|
+
strokeColor: AI.transparent,
|
|
537
|
+
strokeThickness: 0,
|
|
538
|
+
size: { width: p.size.width + 10, height: p.size.height + 10 },
|
|
539
|
+
}, position, p.id));
|
|
596
540
|
}
|
|
597
|
-
return AI.createGroup(
|
|
541
|
+
return AI.createGroup(p.label.split("<")[0] ?? "UNKNOWN", components);
|
|
598
542
|
});
|
|
599
543
|
return AI.createGroup("Points", points);
|
|
600
544
|
}
|
|
601
|
-
function generateBars(xMin, xMax, yMin, yMax, chart) {
|
|
602
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
545
|
+
export function generateBars(xMin, xMax, yMin, yMax, chart) {
|
|
603
546
|
const components = Array();
|
|
604
547
|
for (const bars of chart.chartBars) {
|
|
605
548
|
const xAxis = bars.xAxis === "top" ? chart.xAxisesTop[0] : chart.xAxisesBottom[0];
|
|
606
549
|
const yAxis = bars.yAxis === "right" ? chart.yAxisesRight[0] : chart.yAxisesLeft[0];
|
|
607
|
-
const yMinValue =
|
|
608
|
-
const xMinValue =
|
|
609
|
-
const halfStep = bars.width / 2 + (
|
|
550
|
+
const yMinValue = yAxis?.type === "linear" || yAxis?.type === "logarithmic" ? yAxis.min : yAxis?.points[0]?.value ?? 0;
|
|
551
|
+
const xMinValue = xAxis?.type === "linear" || xAxis?.type === "logarithmic" ? xAxis.min : xAxis?.points[0]?.value ?? 0;
|
|
552
|
+
const halfStep = bars.width / 2 + (bars.spacing ?? bars.width / 3) / 2;
|
|
610
553
|
const textRot = bars.direction === "x" ? 0 : -Math.PI / 2;
|
|
611
554
|
for (let i = 0; i < bars.bars.length; i++) {
|
|
612
555
|
const b = bars.bars[i];
|
|
613
556
|
const barPos = bars.position + (-bars.bars.length + 1 + 2 * i) * halfStep;
|
|
614
|
-
const outlineColor =
|
|
557
|
+
const outlineColor = b.textOutlineColor ?? chart.textOutlineColor;
|
|
615
558
|
const [tl, middle, br] = bars.direction === "x"
|
|
616
559
|
? [
|
|
617
|
-
AI.createPoint(
|
|
618
|
-
AI.createPoint((b.max + (
|
|
560
|
+
AI.createPoint(b.min ?? xMinValue, barPos + bars.width / 2),
|
|
561
|
+
AI.createPoint((b.max + (b.min ?? xMinValue)) / 2, barPos),
|
|
619
562
|
AI.createPoint(b.max, barPos - bars.width / 2),
|
|
620
563
|
]
|
|
621
564
|
: [
|
|
622
565
|
AI.createPoint(barPos - bars.width / 2, b.max),
|
|
623
|
-
AI.createPoint(barPos, (b.max + (
|
|
624
|
-
AI.createPoint(barPos + bars.width / 2,
|
|
566
|
+
AI.createPoint(barPos, (b.max + (b.min ?? yMinValue)) / 2),
|
|
567
|
+
AI.createPoint(barPos + bars.width / 2, b.min ?? yMinValue),
|
|
625
568
|
];
|
|
626
569
|
const pos = Axis.transformPoint(middle, xMin, xMax, yMin, yMax, xAxis, yAxis);
|
|
627
570
|
const topLeft = Axis.transformPoint(tl, xMin, xMax, yMin, yMax, xAxis, yAxis);
|
|
628
571
|
const bottomRight = Axis.transformPoint(br, xMin, xMax, yMin, yMax, xAxis, yAxis);
|
|
629
|
-
components.push(AI.createRectangle(topLeft, bottomRight,
|
|
572
|
+
components.push(AI.createRectangle(topLeft, bottomRight, b.strokeColor ?? AI.transparent, b.strokeThickness ?? 0, b.color, b.id, AI.solidLine, bars.radius));
|
|
630
573
|
if (b.label) {
|
|
631
|
-
components.push(AI.createText(pos, b.label, chart.font,
|
|
574
|
+
components.push(AI.createText(pos, b.label, chart.font, b.fontSize ?? chart.fontSize, b.textColor ?? chart.textColor, "normal", textRot, "center", "uniform", "uniform", outlineColor !== AI.transparent ? 3 : 0, outlineColor, false));
|
|
632
575
|
}
|
|
633
576
|
}
|
|
634
577
|
}
|
|
@@ -662,7 +605,7 @@ function generatePointShape(p, position, id) {
|
|
|
662
605
|
return AI.createEllipse(topLeft, bottomRight, p.strokeColor, p.strokeThickness, p.color, id);
|
|
663
606
|
}
|
|
664
607
|
}
|
|
665
|
-
function generateXAxisGridLines(xMin, xMax, yMin, yMax, xTicks, xAxis, xGrid) {
|
|
608
|
+
export function generateXAxisGridLines(xMin, xMax, yMin, yMax, xTicks, xAxis, xGrid) {
|
|
666
609
|
const xLines = xTicks.map((l) => {
|
|
667
610
|
const x = Axis.transformValue(l.value, xMin, xMax, xAxis);
|
|
668
611
|
const start = AI.createPoint(x, yMin);
|
|
@@ -671,9 +614,8 @@ function generateXAxisGridLines(xMin, xMax, yMin, yMax, xTicks, xAxis, xGrid) {
|
|
|
671
614
|
});
|
|
672
615
|
return AI.createGroup("Lines", xLines);
|
|
673
616
|
}
|
|
674
|
-
function generateXAxisLabels(xMin, xMax, y, growVertical, ticks, axis, chart) {
|
|
675
|
-
|
|
676
|
-
const rotation = (_a = axis.labelRotation) !== null && _a !== void 0 ? _a : 0;
|
|
617
|
+
export function generateXAxisLabels(xMin, xMax, y, growVertical, ticks, axis, chart) {
|
|
618
|
+
const rotation = axis.labelRotation ?? 0;
|
|
677
619
|
const horizontalGrowth = (() => {
|
|
678
620
|
if (rotation === 0) {
|
|
679
621
|
return "uniform";
|
|
@@ -686,18 +628,16 @@ function generateXAxisLabels(xMin, xMax, y, growVertical, ticks, axis, chart) {
|
|
|
686
628
|
}
|
|
687
629
|
})();
|
|
688
630
|
const xLabels = ticks.map((l) => {
|
|
689
|
-
var _a, _b, _c, _d;
|
|
690
631
|
const position = AI.createPoint(Axis.transformValue(l.value, xMin, xMax, axis), y);
|
|
691
|
-
return AI.createText(position,
|
|
632
|
+
return AI.createText(position, l.label ?? formatNumber(l.value), chart.font, axis.tickFontSize ?? chart.fontSize, axis.labelColor ?? AI.black, "normal", rotation, "center", horizontalGrowth, growVertical, 0, axis.labelColor ?? AI.black, false);
|
|
692
633
|
});
|
|
693
634
|
return AI.createGroup("Labels", xLabels);
|
|
694
635
|
}
|
|
695
|
-
function generateXAxisLabel(x, y, horizontalGrowthDirection, verticalGrowthDirection, axis, chart) {
|
|
696
|
-
var _a, _b, _c, _d;
|
|
636
|
+
export function generateXAxisLabel(x, y, horizontalGrowthDirection, verticalGrowthDirection, axis, chart) {
|
|
697
637
|
const position = AI.createPoint(x, y);
|
|
698
|
-
return AI.createText(position,
|
|
638
|
+
return AI.createText(position, axis.label ?? "", chart.font, axis.axisFontSize ?? chart.fontSize, axis.labelColor ?? AI.black, "normal", 0, "center", horizontalGrowthDirection, verticalGrowthDirection, 0, axis.labelColor ?? AI.black, false, axis.id);
|
|
699
639
|
}
|
|
700
|
-
function generateYAxisLines(xMin, xMax, yMin, yMax, yTicks, yAxis, yGrid, xGrid) {
|
|
640
|
+
export function generateYAxisLines(xMin, xMax, yMin, yMax, yTicks, yAxis, yGrid, xGrid) {
|
|
701
641
|
const yLines = yTicks.map((l) => {
|
|
702
642
|
const y = Axis.transformValue(l.value, yMin, yMax, yAxis);
|
|
703
643
|
const start = AI.createPoint(xMin - xGrid.thickness / 2, y);
|
|
@@ -706,9 +646,8 @@ function generateYAxisLines(xMin, xMax, yMin, yMax, yTicks, yAxis, yGrid, xGrid)
|
|
|
706
646
|
});
|
|
707
647
|
return AI.createGroup("Lines", yLines);
|
|
708
648
|
}
|
|
709
|
-
function generateYAxisLabels(x, yMin, yMax, growHorizontal, yTicks, yAxis, chart) {
|
|
710
|
-
|
|
711
|
-
const rotation = (_a = yAxis.labelRotation) !== null && _a !== void 0 ? _a : 0;
|
|
649
|
+
export function generateYAxisLabels(x, yMin, yMax, growHorizontal, yTicks, yAxis, chart) {
|
|
650
|
+
const rotation = yAxis.labelRotation ?? 0;
|
|
712
651
|
const growVertical = (() => {
|
|
713
652
|
if (rotation === 0) {
|
|
714
653
|
return "uniform";
|
|
@@ -721,16 +660,14 @@ function generateYAxisLabels(x, yMin, yMax, growHorizontal, yTicks, yAxis, chart
|
|
|
721
660
|
}
|
|
722
661
|
})();
|
|
723
662
|
const yLabels = yTicks.map((l) => {
|
|
724
|
-
var _a, _b, _c, _d;
|
|
725
663
|
const position = AI.createPoint(x, Axis.transformValue(l.value, yMin, yMax, yAxis));
|
|
726
|
-
return AI.createText(position,
|
|
664
|
+
return AI.createText(position, l.label ?? formatNumber(l.value), chart.font, yAxis.tickFontSize ?? chart.fontSize, yAxis.labelColor ?? AI.black, "normal", rotation, "center", growHorizontal, growVertical, 0, yAxis.labelColor ?? AI.black, false);
|
|
727
665
|
});
|
|
728
666
|
return AI.createGroup("Labels", yLabels);
|
|
729
667
|
}
|
|
730
|
-
function generateYAxisLabel(x, y, rotation, horizontalGrowthDirection, verticalGrowthDirection, axis, chart) {
|
|
731
|
-
var _a, _b, _c, _d;
|
|
668
|
+
export function generateYAxisLabel(x, y, rotation, horizontalGrowthDirection, verticalGrowthDirection, axis, chart) {
|
|
732
669
|
const position = AI.createPoint(x, y);
|
|
733
|
-
return AI.createText(position,
|
|
670
|
+
return AI.createText(position, axis.label ?? "", chart.font, axis.axisFontSize ?? chart.fontSize, axis.labelColor ?? AI.black, "normal", rotation, "center", horizontalGrowthDirection, verticalGrowthDirection, 0, axis.labelColor ?? AI.black, false, axis.id);
|
|
734
671
|
}
|
|
735
672
|
function formatNumber(n) {
|
|
736
673
|
if (n >= 10000000) {
|