scichart-engine 0.4.1 → 0.4.3
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Scale } from '../scales';
|
|
2
2
|
import { ChartTheme } from '../theme';
|
|
3
3
|
import { Series } from './Series';
|
|
4
|
-
import { PlotArea, CursorState } from '../types';
|
|
4
|
+
import { PlotArea, CursorState, AxisOptions } from '../types';
|
|
5
5
|
|
|
6
6
|
export declare class OverlayRenderer {
|
|
7
7
|
private ctx;
|
|
@@ -22,11 +22,11 @@ export declare class OverlayRenderer {
|
|
|
22
22
|
/**
|
|
23
23
|
* Draw X axis with ticks and labels
|
|
24
24
|
*/
|
|
25
|
-
drawXAxis(plotArea: PlotArea, xScale: Scale,
|
|
25
|
+
drawXAxis(plotArea: PlotArea, xScale: Scale, options?: AxisOptions): void;
|
|
26
26
|
/**
|
|
27
27
|
* Draw Y axis with ticks and labels
|
|
28
28
|
*/
|
|
29
|
-
drawYAxis(plotArea: PlotArea, yScale: Scale,
|
|
29
|
+
drawYAxis(plotArea: PlotArea, yScale: Scale, options?: AxisOptions, position?: "left" | "right", offset?: number): void;
|
|
30
30
|
/**
|
|
31
31
|
* Draw plot area border
|
|
32
32
|
*/
|
|
@@ -1268,12 +1268,12 @@ class fi {
|
|
|
1268
1268
|
* Draw X axis with ticks and labels
|
|
1269
1269
|
*/
|
|
1270
1270
|
drawXAxis(e, t, i) {
|
|
1271
|
-
const { ctx: o } = this, r = this.theme.xAxis, s = t.ticks(8), a = e.y + e.height;
|
|
1272
|
-
o.strokeStyle = r.lineColor, o.lineWidth = r.lineWidth, o.beginPath(), o.moveTo(e.x, a), o.lineTo(e.x + e.width, a), o.stroke(), o.fillStyle = r.labelColor, o.font = `${r.labelSize}px ${r.fontFamily}`, o.textAlign = "center", o.textBaseline = "top", s.forEach((
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
}),
|
|
1276
|
-
|
|
1271
|
+
const { ctx: o } = this, r = this.theme.xAxis, s = t.ticks(8), a = e.y + e.height, l = i == null ? void 0 : i.label;
|
|
1272
|
+
o.strokeStyle = r.lineColor, o.lineWidth = r.lineWidth, o.beginPath(), o.moveTo(e.x, a), o.lineTo(e.x + e.width, a), o.stroke(), o.fillStyle = r.labelColor, o.font = `${r.labelSize}px ${r.fontFamily}`, o.textAlign = "center", o.textBaseline = "top", s.forEach((c) => {
|
|
1273
|
+
const h = t.transform(c);
|
|
1274
|
+
h >= e.x && h <= e.x + e.width && (o.strokeStyle = r.tickColor, o.beginPath(), o.moveTo(h, a), o.lineTo(h, a + r.tickLength), o.stroke(), o.fillText(this.formatXTick(c, i), h, a + r.tickLength + 3));
|
|
1275
|
+
}), l && (o.fillStyle = r.titleColor, o.font = `${r.titleSize}px ${r.fontFamily}`, o.textAlign = "center", o.textBaseline = "bottom", o.fillText(
|
|
1276
|
+
l,
|
|
1277
1277
|
e.x + e.width / 2,
|
|
1278
1278
|
e.y + e.height + 45
|
|
1279
1279
|
));
|
|
@@ -1282,18 +1282,18 @@ class fi {
|
|
|
1282
1282
|
* Draw Y axis with ticks and labels
|
|
1283
1283
|
*/
|
|
1284
1284
|
drawYAxis(e, t, i, o = "left", r = 0) {
|
|
1285
|
-
const { ctx: s } = this, a = this.theme.yAxis, l = t.ticks(6), c = o === "left" ? e.x - r : e.x + e.width + r,
|
|
1286
|
-
if (s.strokeStyle = a.lineColor, s.lineWidth = a.lineWidth, s.beginPath(), s.moveTo(
|
|
1287
|
-
const
|
|
1288
|
-
if (
|
|
1289
|
-
s.strokeStyle = a.tickColor, s.beginPath(), s.moveTo(
|
|
1290
|
-
const
|
|
1291
|
-
s.fillText(this.formatYTick(
|
|
1285
|
+
const { ctx: s } = this, a = this.theme.yAxis, l = t.ticks(6), c = i == null ? void 0 : i.label, h = o === "left" ? e.x - r : e.x + e.width + r, u = o === "left" ? -1 : 1;
|
|
1286
|
+
if (s.strokeStyle = a.lineColor, s.lineWidth = a.lineWidth, s.beginPath(), s.moveTo(h, e.y), s.lineTo(h, e.y + e.height), s.stroke(), s.fillStyle = a.labelColor, s.font = `${a.labelSize}px ${a.fontFamily}`, s.textAlign = o === "left" ? "right" : "left", s.textBaseline = "middle", l.forEach((d) => {
|
|
1287
|
+
const f = t.transform(d);
|
|
1288
|
+
if (f >= e.y && f <= e.y + e.height) {
|
|
1289
|
+
s.strokeStyle = a.tickColor, s.beginPath(), s.moveTo(h, f), s.lineTo(h + a.tickLength * u, f), s.stroke();
|
|
1290
|
+
const g = h + (a.tickLength + 3) * u;
|
|
1291
|
+
s.fillText(this.formatYTick(d, i), g, f);
|
|
1292
1292
|
}
|
|
1293
|
-
}),
|
|
1293
|
+
}), c) {
|
|
1294
1294
|
s.save(), s.fillStyle = a.titleColor, s.font = `${a.titleSize}px ${a.fontFamily}`, s.textAlign = "center", s.textBaseline = "top";
|
|
1295
|
-
const
|
|
1296
|
-
s.translate(
|
|
1295
|
+
const d = o === "left" ? h - 40 : h + 40, f = e.y + e.height / 2;
|
|
1296
|
+
s.translate(d, f), s.rotate(o === "left" ? -Math.PI / 2 : Math.PI / 2), s.fillText(c, 0, 0), s.restore();
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
1299
|
/**
|
|
@@ -1468,13 +1468,13 @@ class fi {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
return i;
|
|
1470
1470
|
}
|
|
1471
|
-
formatXTick(e) {
|
|
1472
|
-
return Math.abs(e) < 1e-3 && e !== 0 ? this.toScientificUnicode(e, 1) : e.toFixed(3).replace(/\.?0+$/, "");
|
|
1471
|
+
formatXTick(e, t) {
|
|
1472
|
+
return t != null && t.scientific || Math.abs(e) < 1e-3 && e !== 0 ? this.toScientificUnicode(e, 1) : e.toFixed(3).replace(/\.?0+$/, "");
|
|
1473
1473
|
}
|
|
1474
|
-
formatYTick(e) {
|
|
1474
|
+
formatYTick(e, t) {
|
|
1475
1475
|
if (e === 0) return "0";
|
|
1476
|
-
const
|
|
1477
|
-
return t < 1e-4 ||
|
|
1476
|
+
const i = Math.abs(e);
|
|
1477
|
+
return t != null && t.scientific || i < 1e-4 || i >= 1e4 ? this.toScientificUnicode(e, 1) : e.toPrecision(3);
|
|
1478
1478
|
}
|
|
1479
1479
|
toScientificUnicode(e, t) {
|
|
1480
1480
|
const i = e.toExponential(t), [o, r] = i.split("e"), s = {
|
|
@@ -1490,11 +1490,11 @@ class fi {
|
|
|
1490
1490
|
9: "⁹",
|
|
1491
1491
|
"-": "⁻",
|
|
1492
1492
|
"+": "⁺"
|
|
1493
|
-
}, a = r.replace(
|
|
1494
|
-
/[0-9
|
|
1493
|
+
}, a = r.replace("+", "").replace(
|
|
1494
|
+
/[0-9\-]/g,
|
|
1495
1495
|
(l) => s[l] || l
|
|
1496
1496
|
);
|
|
1497
|
-
return `${o}
|
|
1497
|
+
return `${o}e${a}`;
|
|
1498
1498
|
}
|
|
1499
1499
|
}
|
|
1500
1500
|
class pi {
|
|
@@ -3866,7 +3866,7 @@ function Ve(n, e, t) {
|
|
|
3866
3866
|
console.warn("[SciChart] Container has zero size in render, skipping overlay");
|
|
3867
3867
|
return;
|
|
3868
3868
|
}
|
|
3869
|
-
n.overlay.clear(i.width, i.height), n.overlay.drawGrid(e, n.xScale, t), n.overlay.drawXAxis(e, n.xScale, n.xAxisOptions
|
|
3869
|
+
n.overlay.clear(i.width, i.height), n.overlay.drawGrid(e, n.xScale, t), n.overlay.drawXAxis(e, n.xScale, n.xAxisOptions);
|
|
3870
3870
|
const o = [], r = [];
|
|
3871
3871
|
if (n.yAxisOptionsMap.forEach((c, h) => {
|
|
3872
3872
|
c.position === "right" ? r.push(h) : o.push(h);
|
|
@@ -3874,13 +3874,13 @@ function Ve(n, e, t) {
|
|
|
3874
3874
|
const u = n.yScales.get(c), d = n.yAxisOptionsMap.get(c);
|
|
3875
3875
|
if (u && d) {
|
|
3876
3876
|
const f = h * 65;
|
|
3877
|
-
n.overlay.drawYAxis(e, u, d
|
|
3877
|
+
n.overlay.drawYAxis(e, u, d, "left", f);
|
|
3878
3878
|
}
|
|
3879
3879
|
}), r.forEach((c, h) => {
|
|
3880
3880
|
const u = n.yScales.get(c), d = n.yAxisOptionsMap.get(c);
|
|
3881
3881
|
if (u && d) {
|
|
3882
3882
|
const f = h * 65;
|
|
3883
|
-
n.overlay.drawYAxis(e, u, d
|
|
3883
|
+
n.overlay.drawYAxis(e, u, d, "right", f);
|
|
3884
3884
|
}
|
|
3885
3885
|
}), n.overlay.drawPlotBorder(e), n.series.forEach((c) => {
|
|
3886
3886
|
if (c.isVisible() && c.hasErrorData()) {
|