@devexperts/dxcharts-lite 2.7.1 → 2.7.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/dist/chart/animation/canvas-animation.d.ts +19 -21
- package/dist/chart/animation/canvas-animation.js +19 -19
- package/dist/chart/animation/types/animation.d.ts +5 -17
- package/dist/chart/animation/types/animation.js +12 -17
- package/dist/chart/animation/types/color-alpha-animation.js +11 -21
- package/dist/chart/animation/types/viewport-movement-animation.d.ts +1 -1
- package/dist/chart/animation/viewport-model-animation.js +2 -2
- package/dist/chart/chart.config.d.ts +7 -0
- package/dist/chart/chart.config.js +4 -0
- package/dist/chart/components/chart/chart.component.d.ts +11 -0
- package/dist/chart/components/chart/chart.component.js +11 -0
- package/dist/chart/components/pane/pane.component.js +5 -1
- package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +4 -1
- package/dist/chart/components/y_axis/y-axis.component.d.ts +5 -1
- package/dist/chart/components/y_axis/y-axis.component.js +11 -5
- package/dist/chart/components/y_axis/y-axis.drawer.js +5 -3
- package/dist/chart/components/y_axis/y-axis.model.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/area.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/area.drawer.js +5 -5
- package/dist/chart/drawers/chart-type-drawers/bar.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +6 -6
- package/dist/chart/drawers/chart-type-drawers/baseline.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +8 -8
- package/dist/chart/drawers/chart-type-drawers/candle.drawer.d.ts +3 -3
- package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +20 -16
- package/dist/chart/drawers/chart-type-drawers/histogram.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +5 -5
- package/dist/chart/drawers/chart-type-drawers/line.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/line.drawer.js +5 -5
- package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.d.ts +2 -2
- package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +4 -3
- package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +2 -2
- package/dist/chart/drawers/data-series-drawers/color-candle.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +4 -4
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +9 -9
- package/dist/chart/drawers/data-series-drawers/histogram.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +3 -3
- package/dist/chart/drawers/data-series-drawers/linear.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/linear.drawer.js +3 -3
- package/dist/chart/drawers/data-series-drawers/points.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/points.drawer.js +3 -3
- package/dist/chart/drawers/data-series-drawers/text.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/text.drawer.js +2 -2
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +16 -13
- package/dist/chart/drawers/data-series-drawers/triangle.drawer.d.ts +2 -2
- package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +2 -2
- package/dist/chart/drawers/data-series.drawer.d.ts +5 -5
- package/dist/chart/drawers/data-series.drawer.js +3 -3
- package/dist/chart/drawers/ht-data-series.drawer.js +2 -2
- package/dist/chart/model/scale.model.js +4 -0
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -12,9 +12,9 @@ export class BarDrawer {
|
|
|
12
12
|
constructor(config) {
|
|
13
13
|
this.config = config;
|
|
14
14
|
}
|
|
15
|
-
setFillStyle(ctx,
|
|
16
|
-
if (
|
|
17
|
-
ctx.strokeStyle =
|
|
15
|
+
setFillStyle(ctx, hitTestDrawerConfig, candleSeries, visualCandle) {
|
|
16
|
+
if (hitTestDrawerConfig.color) {
|
|
17
|
+
ctx.strokeStyle = hitTestDrawerConfig.color;
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
const barTheme = candleSeries.colors.barTheme;
|
|
@@ -23,14 +23,14 @@ export class BarDrawer {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
draw(ctx, points, candleSeries,
|
|
26
|
+
draw(ctx, points, candleSeries, hitTestDrawerConfig) {
|
|
27
27
|
if (candleSeries instanceof CandleSeriesModel) {
|
|
28
28
|
// @ts-ignore
|
|
29
29
|
const visualCandles = flat(points);
|
|
30
|
-
setLineWidth(ctx, this.config.barLineWidth, candleSeries,
|
|
30
|
+
setLineWidth(ctx, this.config.barLineWidth, candleSeries, hitTestDrawerConfig);
|
|
31
31
|
avoidAntialiasing(ctx, () => {
|
|
32
32
|
for (const visualCandle of visualCandles) {
|
|
33
|
-
this.setFillStyle(ctx,
|
|
33
|
+
this.setFillStyle(ctx, hitTestDrawerConfig, candleSeries, visualCandle);
|
|
34
34
|
ctx.beginPath();
|
|
35
35
|
const bodyLineX = candleSeries.view.toX(visualCandle.centerUnit);
|
|
36
36
|
const openLineStartX = candleSeries.view.toX(visualCandle.startUnit);
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
import { CanvasBoundsContainer } from '../../canvas/canvas-bounds-container';
|
|
7
7
|
import { BaselineModel } from '../../model/baseline.model';
|
|
8
8
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
9
|
-
import {
|
|
9
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
10
10
|
export declare class BaselineDrawer implements SeriesDrawer {
|
|
11
11
|
private baseLineModel;
|
|
12
12
|
private canvasBoundContainer;
|
|
13
13
|
constructor(baseLineModel: BaselineModel, canvasBoundContainer: CanvasBoundsContainer);
|
|
14
|
-
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
14
|
+
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig?: HTSeriesDrawerConfig): void;
|
|
15
15
|
}
|
|
@@ -11,8 +11,8 @@ export class BaselineDrawer {
|
|
|
11
11
|
this.baseLineModel = baseLineModel;
|
|
12
12
|
this.canvasBoundContainer = canvasBoundContainer;
|
|
13
13
|
}
|
|
14
|
-
draw(ctx, points, model,
|
|
15
|
-
if (
|
|
14
|
+
draw(ctx, points, model, hitTestDrawerConfig) {
|
|
15
|
+
if (hitTestDrawerConfig !== undefined && model instanceof CandleSeriesModel) {
|
|
16
16
|
const visualCandles = flat(points);
|
|
17
17
|
// calculate baseline
|
|
18
18
|
const baselineYPercents = this.baseLineModel.baselineYPercents;
|
|
@@ -29,7 +29,7 @@ export class BaselineDrawer {
|
|
|
29
29
|
const prevHigherThanBL = prev ? model.view.toY(prev.close) < baseLine : false;
|
|
30
30
|
const curHigherThanBL = currentCloseYPx < baseLine;
|
|
31
31
|
if (prev !== void 0 && prevHigherThanBL !== curHigherThanBL) {
|
|
32
|
-
setBaselineFillStyle(ctx, model,
|
|
32
|
+
setBaselineFillStyle(ctx, model, hitTestDrawerConfig, prevHigherThanBL);
|
|
33
33
|
const prevLineXPx = model.view.toX(prev.centerUnit);
|
|
34
34
|
const prevCloseYPx = model.view.toY(prev.close);
|
|
35
35
|
// our goal here is to find the crossing point X between chart line and baseline
|
|
@@ -53,7 +53,7 @@ export class BaselineDrawer {
|
|
|
53
53
|
ctx.moveTo(currentLineXPx, currentCloseYPx);
|
|
54
54
|
}
|
|
55
55
|
else if (next === void 0) {
|
|
56
|
-
setBaselineFillStyle(ctx, model,
|
|
56
|
+
setBaselineFillStyle(ctx, model, hitTestDrawerConfig, curHigherThanBL);
|
|
57
57
|
ctx.lineTo(currentLineXPx, currentCloseYPx);
|
|
58
58
|
ctx.stroke();
|
|
59
59
|
ctx.lineTo(currentLineXPx, baseLine);
|
|
@@ -73,10 +73,10 @@ export class BaselineDrawer {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
const setBaselineFillStyle = (ctx, candleSeries,
|
|
77
|
-
if (
|
|
78
|
-
ctx.fillStyle =
|
|
79
|
-
ctx.strokeStyle =
|
|
76
|
+
const setBaselineFillStyle = (ctx, candleSeries, hitTestDrawerConfig, upper) => {
|
|
77
|
+
if (hitTestDrawerConfig.color) {
|
|
78
|
+
ctx.fillStyle = hitTestDrawerConfig.color;
|
|
79
|
+
ctx.strokeStyle = hitTestDrawerConfig.color;
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
82
|
ctx.fillStyle = upper
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { CandleSeriesModel } from '../../model/candle-series.model';
|
|
7
7
|
import { ChartConfigComponentsChart } from '../../chart.config';
|
|
8
8
|
import VisualCandle from '../../model/visual-candle';
|
|
9
|
-
import {
|
|
9
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
10
10
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
11
11
|
export declare class CandleDrawer implements SeriesDrawer {
|
|
12
12
|
private config;
|
|
@@ -18,8 +18,8 @@ export declare class CandleDrawer implements SeriesDrawer {
|
|
|
18
18
|
/**
|
|
19
19
|
* You can pass two-dimension array to divide series into multiple parts
|
|
20
20
|
*/
|
|
21
|
-
points: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
22
|
-
drawCandle(ctx: CanvasRenderingContext2D,
|
|
21
|
+
points: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
22
|
+
drawCandle(ctx: CanvasRenderingContext2D, hitTestDrawerConfig: HTSeriesDrawerConfig, candleSeries: CandleSeriesModel, visualCandle: VisualCandle): void;
|
|
23
23
|
private drawCandlesWicks;
|
|
24
24
|
private drawCandleBorder;
|
|
25
25
|
}
|
|
@@ -34,12 +34,12 @@ export class CandleDrawer {
|
|
|
34
34
|
/**
|
|
35
35
|
* You can pass two-dimension array to divide series into multiple parts
|
|
36
36
|
*/
|
|
37
|
-
points, model,
|
|
37
|
+
points, model, hitTestDrawerConfig) {
|
|
38
38
|
if (model instanceof CandleSeriesModel) {
|
|
39
39
|
// @ts-ignore
|
|
40
40
|
const visualCandles = flat(points);
|
|
41
41
|
// TODO FIXME draw called 3-4 times on single candle update even if multichart is off
|
|
42
|
-
setLineWidth(ctx, this.config.candleLineWidth, model,
|
|
42
|
+
setLineWidth(ctx, this.config.candleLineWidth, model, hitTestDrawerConfig, this.config.candleLineWidth);
|
|
43
43
|
avoidAntialiasing(ctx, () => {
|
|
44
44
|
this.pixelLength = 1 / dpr;
|
|
45
45
|
this.halfLineWidthCU = ctx.lineWidth / 2;
|
|
@@ -47,20 +47,20 @@ export class CandleDrawer {
|
|
|
47
47
|
for (const visualCandle of visualCandles) {
|
|
48
48
|
const { candleTheme, activeCandleTheme } = model.colors;
|
|
49
49
|
if (candleTheme && activeCandleTheme) {
|
|
50
|
-
this.drawCandle(ctx,
|
|
50
|
+
this.drawCandle(ctx, hitTestDrawerConfig, model, visualCandle);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
drawCandle(ctx,
|
|
56
|
+
drawCandle(ctx, hitTestDrawerConfig, candleSeries, visualCandle) {
|
|
57
57
|
const { candleTheme, activeCandleTheme } = candleSeries.colors;
|
|
58
58
|
const direction = visualCandle.name;
|
|
59
59
|
const currentCandleTheme = visualCandle.isActive ? activeCandleTheme : candleTheme;
|
|
60
60
|
const isHollow = visualCandle.isHollow;
|
|
61
61
|
// choose candle filling color
|
|
62
|
-
if (
|
|
63
|
-
ctx.fillStyle =
|
|
62
|
+
if (hitTestDrawerConfig.color) {
|
|
63
|
+
ctx.fillStyle = hitTestDrawerConfig.color;
|
|
64
64
|
}
|
|
65
65
|
else if (isHollow) {
|
|
66
66
|
ctx.fillStyle = currentCandleTheme[`${direction}WickColor`];
|
|
@@ -78,8 +78,8 @@ export class CandleDrawer {
|
|
|
78
78
|
const wickColor = direction === 'none' ? candleColor : currentCandleTheme[`${direction}WickColor`];
|
|
79
79
|
ctx.fillStyle = candleColor;
|
|
80
80
|
// wick style, borders are drawn after the wicks, so style for borders will be changed in drawBorder method
|
|
81
|
-
if (
|
|
82
|
-
ctx.strokeStyle =
|
|
81
|
+
if (hitTestDrawerConfig.color) {
|
|
82
|
+
ctx.strokeStyle = hitTestDrawerConfig.color;
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
85
|
ctx.strokeStyle = wickColor;
|
|
@@ -116,7 +116,7 @@ export class CandleDrawer {
|
|
|
116
116
|
ctx.lineTo(baseX + offset, bodyEnd);
|
|
117
117
|
ctx.stroke();
|
|
118
118
|
}
|
|
119
|
-
this.drawCandleBorder(ctx,
|
|
119
|
+
this.drawCandleBorder(ctx, hitTestDrawerConfig, currentCandleTheme, visualCandle, baseX + this.halfLineWidthCU, bodyStart + this.halfLineWidthCU, width - this.lineWidthCU, bodyH - this.lineWidthCU);
|
|
120
120
|
}
|
|
121
121
|
else {
|
|
122
122
|
// add paddings if exist
|
|
@@ -129,14 +129,18 @@ export class CandleDrawer {
|
|
|
129
129
|
const paddingBaseX = baseX + paddingWidthOffset;
|
|
130
130
|
const paddingWidth = width - paddingWidthOffset * 2;
|
|
131
131
|
if (!isHollow) {
|
|
132
|
-
if (
|
|
133
|
-
ctx.fillStyle =
|
|
132
|
+
if (hitTestDrawerConfig.color) {
|
|
133
|
+
ctx.fillStyle = hitTestDrawerConfig.color;
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
const bodyWidth = hitTestDrawerConfig.hoverWidth ? width + paddingWidthOffset : paddingWidth;
|
|
136
|
+
const bodyHeight = hitTestDrawerConfig.hoverWidth
|
|
137
|
+
? bodyH + hitTestDrawerConfig.hoverWidth + paddingWidthOffset
|
|
138
|
+
: bodyH;
|
|
139
|
+
ctx.fillRect(paddingBaseX, bodyStart, bodyWidth, bodyHeight);
|
|
136
140
|
}
|
|
137
141
|
// choose border color around candle and draw candle
|
|
138
142
|
if (showCandleBorder) {
|
|
139
|
-
this.drawCandleBorder(ctx,
|
|
143
|
+
this.drawCandleBorder(ctx, hitTestDrawerConfig, currentCandleTheme, visualCandle, paddingBaseX + this.halfLineWidthCU, bodyStart + this.halfLineWidthCU, paddingWidth - this.lineWidthCU, bodyH - this.lineWidthCU);
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
146
|
}
|
|
@@ -153,9 +157,9 @@ export class CandleDrawer {
|
|
|
153
157
|
ctx.stroke();
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
|
-
drawCandleBorder(ctx,
|
|
157
|
-
if (
|
|
158
|
-
ctx.strokeStyle =
|
|
160
|
+
drawCandleBorder(ctx, hitTestDrawerConfig, candleTheme, visualCandle, x, y, w, h) {
|
|
161
|
+
if (hitTestDrawerConfig.color) {
|
|
162
|
+
ctx.strokeStyle = hitTestDrawerConfig.color;
|
|
159
163
|
}
|
|
160
164
|
else {
|
|
161
165
|
const direction = visualCandle.name;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ChartConfigComponentsHistogram } from '../../chart.config';
|
|
7
7
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
8
|
-
import {
|
|
8
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
9
9
|
export declare class HistogramDrawer implements SeriesDrawer {
|
|
10
10
|
private config;
|
|
11
11
|
constructor(config: ChartConfigComponentsHistogram);
|
|
12
|
-
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
12
|
+
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
13
13
|
}
|
|
@@ -9,7 +9,7 @@ export class HistogramDrawer {
|
|
|
9
9
|
constructor(config) {
|
|
10
10
|
this.config = config;
|
|
11
11
|
}
|
|
12
|
-
draw(ctx, points, model,
|
|
12
|
+
draw(ctx, points, model, hitTestDrawerConfig) {
|
|
13
13
|
if (model instanceof CandleSeriesModel) {
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
const visualCandles = points.flat();
|
|
@@ -23,8 +23,8 @@ export class HistogramDrawer {
|
|
|
23
23
|
if (histogramColors === undefined) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
27
|
-
ctx.fillStyle =
|
|
26
|
+
if (hitTestDrawerConfig.color) {
|
|
27
|
+
ctx.fillStyle = hitTestDrawerConfig.color;
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
30
|
ctx.fillStyle = histogramColors[`${direction}Bright`];
|
|
@@ -36,8 +36,8 @@ export class HistogramDrawer {
|
|
|
36
36
|
ctx.fillRect(baseX, closeY, width, capHeight);
|
|
37
37
|
// the bar itself
|
|
38
38
|
const gradient = ctx.createLinearGradient(0, closeY + capHeight, 0, bottomY);
|
|
39
|
-
if (
|
|
40
|
-
ctx.fillStyle =
|
|
39
|
+
if (hitTestDrawerConfig.color) {
|
|
40
|
+
ctx.fillStyle = hitTestDrawerConfig.color;
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
gradient.addColorStop(0, histogramColors[`${direction}Cap`]);
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
6
|
import { ChartConfigComponentsChart } from '../../chart.config';
|
|
7
|
-
import {
|
|
7
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
8
8
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
9
9
|
export declare class LineDrawer implements SeriesDrawer {
|
|
10
10
|
private config;
|
|
11
11
|
constructor(config: ChartConfigComponentsChart);
|
|
12
|
-
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], candleSeries: DataSeriesModel,
|
|
12
|
+
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], candleSeries: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
13
13
|
}
|
|
@@ -10,23 +10,23 @@ export class LineDrawer {
|
|
|
10
10
|
constructor(config) {
|
|
11
11
|
this.config = config;
|
|
12
12
|
}
|
|
13
|
-
draw(ctx, points, candleSeries,
|
|
13
|
+
draw(ctx, points, candleSeries, hitTestDrawerConfig) {
|
|
14
14
|
if (candleSeries instanceof CandleSeriesModel) {
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
const visualCandles = flat(points);
|
|
17
17
|
// TODO rework, make sure drawing is precise
|
|
18
|
-
setLineWidth(ctx, this.config.lineWidth, candleSeries,
|
|
18
|
+
setLineWidth(ctx, this.config.lineWidth, candleSeries, hitTestDrawerConfig, this.config.selectedWidth);
|
|
19
19
|
const lineTheme = candleSeries.colors.lineTheme;
|
|
20
20
|
// make style changes outside loop to improve performance
|
|
21
21
|
ctx.lineCap = 'round';
|
|
22
|
-
if (
|
|
23
|
-
ctx.strokeStyle =
|
|
22
|
+
if (hitTestDrawerConfig.color) {
|
|
23
|
+
ctx.strokeStyle = hitTestDrawerConfig.color;
|
|
24
24
|
}
|
|
25
25
|
for (let i = 1; i < visualCandles.length; i++) {
|
|
26
26
|
const prev = visualCandles[i - 1];
|
|
27
27
|
const vc = visualCandles[i];
|
|
28
28
|
const direction = vc.name;
|
|
29
|
-
if (!
|
|
29
|
+
if (!hitTestDrawerConfig.color) {
|
|
30
30
|
ctx.strokeStyle = lineTheme[`${direction}Color`];
|
|
31
31
|
}
|
|
32
32
|
const prevX = candleSeries.view.toX(prev.centerUnit);
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ScatterPlotStyle } from '../../chart.config';
|
|
7
7
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
8
|
-
import {
|
|
8
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
9
9
|
export declare class ScatterPlotDrawer implements SeriesDrawer {
|
|
10
10
|
private config;
|
|
11
11
|
constructor(config: ScatterPlotStyle);
|
|
12
|
-
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
12
|
+
draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
13
13
|
}
|
|
@@ -9,14 +9,15 @@ export class ScatterPlotDrawer {
|
|
|
9
9
|
constructor(config) {
|
|
10
10
|
this.config = config;
|
|
11
11
|
}
|
|
12
|
-
draw(ctx, points, model,
|
|
12
|
+
draw(ctx, points, model, hitTestDrawerConfig) {
|
|
13
13
|
var _a;
|
|
14
|
-
|
|
14
|
+
const radius = hitTestDrawerConfig.hoverWidth ? hitTestDrawerConfig.hoverWidth / 2 : SCATTER_PLOT_RADIUS;
|
|
15
|
+
ctx.fillStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : this.config.mainColor;
|
|
15
16
|
for (const visualCandle of flat(points)) {
|
|
16
17
|
ctx.beginPath();
|
|
17
18
|
const lineX = model.view.toX(visualCandle.centerUnit);
|
|
18
19
|
const closeY = model.view.toY(visualCandle.close);
|
|
19
|
-
ctx.arc(lineX, closeY,
|
|
20
|
+
ctx.arc(lineX, closeY, radius, 0, Math.PI * 2, true);
|
|
20
21
|
ctx.fill();
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { BarType, FullChartConfig } from '../../chart.config';
|
|
7
7
|
import { BoundsProvider } from '../../model/bounds.model';
|
|
8
8
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
9
|
-
import {
|
|
9
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
10
10
|
export declare const candleTypesList: BarType[];
|
|
11
11
|
/**
|
|
12
12
|
* A decorator for drawers, that draw something depending on visual candles
|
|
@@ -16,7 +16,7 @@ export declare class CandleSeriesWrapper implements SeriesDrawer {
|
|
|
16
16
|
private config;
|
|
17
17
|
private chartBounds;
|
|
18
18
|
constructor(drawer: SeriesDrawer, config: FullChartConfig, chartBounds: BoundsProvider);
|
|
19
|
-
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
19
|
+
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
20
20
|
private beforeDraw;
|
|
21
21
|
private isChartTypeAllowed;
|
|
22
22
|
private afterDraw;
|
|
@@ -24,10 +24,10 @@ export class CandleSeriesWrapper {
|
|
|
24
24
|
this.config = config;
|
|
25
25
|
this.chartBounds = chartBounds;
|
|
26
26
|
}
|
|
27
|
-
draw(ctx, allPoints, model,
|
|
27
|
+
draw(ctx, allPoints, model, hitTestDrawerConfig) {
|
|
28
28
|
if (this.isChartTypeAllowed()) {
|
|
29
29
|
this.beforeDraw(ctx);
|
|
30
|
-
this.drawer.draw(ctx, allPoints, model,
|
|
30
|
+
this.drawer.draw(ctx, allPoints, model, hitTestDrawerConfig);
|
|
31
31
|
this.afterDraw(ctx, model);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ChartModel } from '../../components/chart/chart.model';
|
|
7
7
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
8
|
-
import {
|
|
8
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
9
9
|
/**
|
|
10
10
|
* Some series have candles which are highlighted.
|
|
11
11
|
* This drawer draws the candle box on top of original candles.
|
|
@@ -13,5 +13,5 @@ import { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
|
13
13
|
export declare class ColorCandleDrawer implements SeriesDrawer {
|
|
14
14
|
private chartModel;
|
|
15
15
|
constructor(chartModel: ChartModel);
|
|
16
|
-
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
16
|
+
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
17
17
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { unitToPixels } from '../../model/scaling/viewport.model';
|
|
7
7
|
import { floorToDPR } from '../../utils/device/device-pixel-ratio.utils';
|
|
8
|
-
import {
|
|
8
|
+
import { floor } from '../../utils/math.utils';
|
|
9
9
|
/**
|
|
10
10
|
* Some series have candles which are highlighted.
|
|
11
11
|
* This drawer draws the candle box on top of original candles.
|
|
@@ -14,13 +14,13 @@ export class ColorCandleDrawer {
|
|
|
14
14
|
constructor(chartModel) {
|
|
15
15
|
this.chartModel = chartModel;
|
|
16
16
|
}
|
|
17
|
-
draw(ctx, allPoints, model,
|
|
17
|
+
draw(ctx, allPoints, model, hitTestDrawerConfig) {
|
|
18
18
|
allPoints.forEach((points, idx) => {
|
|
19
19
|
var _a;
|
|
20
20
|
const config = model.getPaintConfig(idx);
|
|
21
|
-
ctx.fillStyle = (_a =
|
|
21
|
+
ctx.fillStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color;
|
|
22
22
|
points.forEach(p => {
|
|
23
|
-
const visualCandle = this.chartModel.getVisualCandle(
|
|
23
|
+
const visualCandle = this.chartModel.getVisualCandle(floor(p.centerUnit));
|
|
24
24
|
const value = p.close;
|
|
25
25
|
if (visualCandle && value === 1) {
|
|
26
26
|
const zoomX = this.chartModel.scale.zoomX;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
6
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
7
|
-
import {
|
|
7
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
8
8
|
/**
|
|
9
9
|
* Point used to draw difference type indicator (clouds) (e.g. Ichimoku indicator)
|
|
10
10
|
*/
|
|
@@ -13,7 +13,7 @@ export interface DifferencePoint {
|
|
|
13
13
|
}
|
|
14
14
|
export declare class DifferenceCloudDrawer implements SeriesDrawer {
|
|
15
15
|
constructor();
|
|
16
|
-
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
16
|
+
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
17
17
|
private drawLine;
|
|
18
18
|
private drawDifference;
|
|
19
19
|
private fillCloud;
|
|
@@ -9,14 +9,14 @@ import { firstOf, lastOf } from '../../utils/array.utils';
|
|
|
9
9
|
import { toRGBA } from '../../utils/color.utils';
|
|
10
10
|
export class DifferenceCloudDrawer {
|
|
11
11
|
constructor() { }
|
|
12
|
-
draw(ctx, allPoints, model,
|
|
12
|
+
draw(ctx, allPoints, model, hitTestDrawerConfig) {
|
|
13
13
|
if (model.config.visible) {
|
|
14
14
|
// draw main line
|
|
15
15
|
allPoints.forEach((points, idx) => {
|
|
16
16
|
var _a;
|
|
17
17
|
const config = model.getPaintConfig(idx);
|
|
18
|
-
setLineWidth(ctx, config.lineWidth, model,
|
|
19
|
-
const lineColor = (_a =
|
|
18
|
+
setLineWidth(ctx, config.lineWidth, model, hitTestDrawerConfig, config.hoveredLineWidth);
|
|
19
|
+
const lineColor = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color;
|
|
20
20
|
ctx.strokeStyle = lineColor;
|
|
21
21
|
this.drawLine(ctx, points, model.view);
|
|
22
22
|
});
|
|
@@ -42,7 +42,7 @@ export class DifferenceCloudDrawer {
|
|
|
42
42
|
}
|
|
43
43
|
const curSeriesColor = mainSeries.getPaintConfig(idx).color;
|
|
44
44
|
const nextSeriesColor = linkedSeries.getPaintConfig(linkedSeriesIdx).color;
|
|
45
|
-
this.drawDifference(ctx, curSeriesColor, nextSeriesColor, differencePoints, mainSeries, linkedSeries,
|
|
45
|
+
this.drawDifference(ctx, curSeriesColor, nextSeriesColor, differencePoints, mainSeries, linkedSeries, hitTestDrawerConfig);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -53,7 +53,7 @@ export class DifferenceCloudDrawer {
|
|
|
53
53
|
buildLinePath(points, ctx, view);
|
|
54
54
|
ctx.stroke();
|
|
55
55
|
}
|
|
56
|
-
drawDifference(ctx, lineColor, nextLineColor, diffPoints, curSeries, nextSeries,
|
|
56
|
+
drawDifference(ctx, lineColor, nextLineColor, diffPoints, curSeries, nextSeries, hitTestDrawerConfig) {
|
|
57
57
|
const [linePoints, nextLinePoints] = [[], []];
|
|
58
58
|
diffPoints.forEach(points => {
|
|
59
59
|
const [point, nextPoint] = points.diffPoints;
|
|
@@ -62,10 +62,10 @@ export class DifferenceCloudDrawer {
|
|
|
62
62
|
});
|
|
63
63
|
const curSeriesPoints = mapDataSeriesDiffPointsIntoPoints(linePoints, curSeries.view);
|
|
64
64
|
const nextSeriesPoints = mapDataSeriesDiffPointsIntoPoints(nextLinePoints, nextSeries.view);
|
|
65
|
-
this.fillCloud(ctx, nextLineColor, curSeriesPoints, nextSeriesPoints,
|
|
66
|
-
this.fillCloud(ctx, lineColor, nextSeriesPoints, curSeriesPoints,
|
|
65
|
+
this.fillCloud(ctx, nextLineColor, curSeriesPoints, nextSeriesPoints, hitTestDrawerConfig);
|
|
66
|
+
this.fillCloud(ctx, lineColor, nextSeriesPoints, curSeriesPoints, hitTestDrawerConfig);
|
|
67
67
|
}
|
|
68
|
-
fillCloud(ctx, color, linePoints, nextLinePoints,
|
|
68
|
+
fillCloud(ctx, color, linePoints, nextLinePoints, hitTestDrawerConfig) {
|
|
69
69
|
var _a, _b, _c, _d;
|
|
70
70
|
ctx.save();
|
|
71
71
|
// clip above lowerLine
|
|
@@ -95,7 +95,7 @@ export class DifferenceCloudDrawer {
|
|
|
95
95
|
ctx.lineTo(p.x, p.y);
|
|
96
96
|
});
|
|
97
97
|
ctx.closePath();
|
|
98
|
-
ctx.fillStyle =
|
|
98
|
+
ctx.fillStyle = hitTestDrawerConfig.color ? hitTestDrawerConfig.color : toRGBA(color ? color : '#383838', 0.3);
|
|
99
99
|
ctx.fill();
|
|
100
100
|
ctx.restore();
|
|
101
101
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
6
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
7
|
-
import {
|
|
7
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
8
8
|
export declare class HistogramDrawer implements SeriesDrawer {
|
|
9
9
|
constructor();
|
|
10
|
-
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
10
|
+
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
11
11
|
}
|
|
@@ -7,14 +7,14 @@ import { floor } from '../../utils/math.utils';
|
|
|
7
7
|
import { setLineWidth } from '../data-series.drawer';
|
|
8
8
|
export class HistogramDrawer {
|
|
9
9
|
constructor() { }
|
|
10
|
-
draw(ctx, allPoints, model,
|
|
10
|
+
draw(ctx, allPoints, model, hitTestDrawerConfig) {
|
|
11
11
|
const zero = model.view.toY(0);
|
|
12
12
|
allPoints.forEach((points, idx) => {
|
|
13
13
|
var _a;
|
|
14
14
|
// odd width is crucial to draw histogram without antialiasing
|
|
15
15
|
const config = model.getPaintConfig(idx);
|
|
16
|
-
setLineWidth(ctx, config.lineWidth, model,
|
|
17
|
-
ctx.strokeStyle = (_a =
|
|
16
|
+
setLineWidth(ctx, config.lineWidth, model, hitTestDrawerConfig, config.hoveredLineWidth);
|
|
17
|
+
ctx.strokeStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color;
|
|
18
18
|
ctx.beginPath();
|
|
19
19
|
points.forEach(p => {
|
|
20
20
|
const x = model.view.toX(p.centerUnit);
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
6
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
7
|
-
import {
|
|
7
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
8
8
|
export declare class LinearDrawer implements SeriesDrawer {
|
|
9
9
|
constructor();
|
|
10
|
-
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
10
|
+
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
11
11
|
private drawLinePath;
|
|
12
12
|
}
|
|
@@ -7,12 +7,12 @@ import { setLineWidth } from '../data-series.drawer';
|
|
|
7
7
|
import { buildLinePath } from './data-series-drawers.utils';
|
|
8
8
|
export class LinearDrawer {
|
|
9
9
|
constructor() { }
|
|
10
|
-
draw(ctx, allPoints, model,
|
|
10
|
+
draw(ctx, allPoints, model, hitTestDrawerConfig) {
|
|
11
11
|
allPoints.forEach((points, idx) => {
|
|
12
12
|
var _a;
|
|
13
13
|
const config = model.getPaintConfig(idx);
|
|
14
|
-
setLineWidth(ctx, config.lineWidth, model,
|
|
15
|
-
ctx.strokeStyle = (_a =
|
|
14
|
+
setLineWidth(ctx, config.lineWidth, model, hitTestDrawerConfig, config.hoveredLineWidth);
|
|
15
|
+
ctx.strokeStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color;
|
|
16
16
|
this.drawLinePath(ctx, points, model.view);
|
|
17
17
|
});
|
|
18
18
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
6
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
7
|
-
import {
|
|
7
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
8
8
|
export declare class PointsDrawer implements SeriesDrawer {
|
|
9
9
|
constructor();
|
|
10
|
-
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
10
|
+
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
11
11
|
}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export class PointsDrawer {
|
|
7
7
|
constructor() { }
|
|
8
|
-
draw(ctx, allPoints, model,
|
|
8
|
+
draw(ctx, allPoints, model, hitTestDrawerConfig) {
|
|
9
9
|
allPoints.forEach((points, idx) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const config = model.getPaintConfig(idx);
|
|
12
|
-
const radius = config.lineWidth;
|
|
13
|
-
ctx.fillStyle = (_a =
|
|
12
|
+
const radius = hitTestDrawerConfig.hoverWidth ? hitTestDrawerConfig.hoverWidth / 2 : config.lineWidth;
|
|
13
|
+
ctx.fillStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color;
|
|
14
14
|
ctx.lineWidth = 1;
|
|
15
15
|
points.forEach(p => {
|
|
16
16
|
ctx.beginPath();
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { FullChartConfig } from '../../chart.config';
|
|
7
7
|
import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
|
|
8
|
-
import {
|
|
8
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
9
9
|
export declare class TextDrawer implements SeriesDrawer {
|
|
10
10
|
private config;
|
|
11
11
|
constructor(config: FullChartConfig);
|
|
12
|
-
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel,
|
|
12
|
+
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
13
13
|
}
|
|
@@ -8,12 +8,12 @@ export class TextDrawer {
|
|
|
8
8
|
constructor(config) {
|
|
9
9
|
this.config = config;
|
|
10
10
|
}
|
|
11
|
-
draw(ctx, allPoints, model,
|
|
11
|
+
draw(ctx, allPoints, model, hitTestDrawerConfig) {
|
|
12
12
|
ctx.save();
|
|
13
13
|
allPoints.forEach((points, idx) => {
|
|
14
14
|
var _a;
|
|
15
15
|
const config = model.getPaintConfig(idx);
|
|
16
|
-
ctx.fillStyle = (_a =
|
|
16
|
+
ctx.fillStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color;
|
|
17
17
|
const font = config.lineWidth + 'px ' + this.config.components.yAxis.fontFamily;
|
|
18
18
|
ctx.font = font;
|
|
19
19
|
points.forEach(p => {
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
6
|
import { VisualSeriesPoint, DataSeriesModel } from '../../model/data-series.model';
|
|
7
|
-
import { SeriesDrawer } from '../data-series.drawer';
|
|
7
|
+
import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
|
|
8
8
|
export declare class TrendHistogramDrawer implements SeriesDrawer {
|
|
9
9
|
constructor();
|
|
10
|
-
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel): void;
|
|
10
|
+
draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
|
|
11
11
|
private previousValue;
|
|
12
12
|
}
|