@devexperts/dxcharts-lite 2.7.0 → 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.
Files changed (64) hide show
  1. package/dist/chart/animation/canvas-animation.d.ts +19 -21
  2. package/dist/chart/animation/canvas-animation.js +19 -19
  3. package/dist/chart/animation/types/animation.d.ts +5 -17
  4. package/dist/chart/animation/types/animation.js +12 -17
  5. package/dist/chart/animation/types/color-alpha-animation.js +11 -21
  6. package/dist/chart/animation/types/viewport-movement-animation.d.ts +1 -1
  7. package/dist/chart/animation/viewport-model-animation.js +2 -2
  8. package/dist/chart/chart.config.d.ts +7 -0
  9. package/dist/chart/chart.config.js +4 -0
  10. package/dist/chart/components/chart/chart.component.d.ts +11 -0
  11. package/dist/chart/components/chart/chart.component.js +11 -0
  12. package/dist/chart/components/chart/chart.model.js +1 -1
  13. package/dist/chart/components/pane/pane-manager.component.d.ts +3 -1
  14. package/dist/chart/components/pane/pane-manager.component.js +7 -5
  15. package/dist/chart/components/pane/pane.component.d.ts +1 -1
  16. package/dist/chart/components/pane/pane.component.js +12 -6
  17. package/dist/chart/components/resizer/bar-resizer.component.d.ts +2 -0
  18. package/dist/chart/components/resizer/bar-resizer.component.js +11 -9
  19. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +4 -1
  20. package/dist/chart/components/y_axis/y-axis-scale.handler.js +0 -5
  21. package/dist/chart/components/y_axis/y-axis.component.d.ts +5 -1
  22. package/dist/chart/components/y_axis/y-axis.component.js +11 -5
  23. package/dist/chart/components/y_axis/y-axis.drawer.js +5 -3
  24. package/dist/chart/components/y_axis/y-axis.model.d.ts +1 -1
  25. package/dist/chart/drawers/chart-type-drawers/area.drawer.d.ts +2 -2
  26. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +5 -5
  27. package/dist/chart/drawers/chart-type-drawers/bar.drawer.d.ts +2 -2
  28. package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +6 -6
  29. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.d.ts +2 -2
  30. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +8 -8
  31. package/dist/chart/drawers/chart-type-drawers/candle.drawer.d.ts +3 -3
  32. package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +20 -16
  33. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.d.ts +2 -2
  34. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +5 -5
  35. package/dist/chart/drawers/chart-type-drawers/line.drawer.d.ts +2 -2
  36. package/dist/chart/drawers/chart-type-drawers/line.drawer.js +5 -5
  37. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.d.ts +2 -2
  38. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +4 -3
  39. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.d.ts +2 -2
  40. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +2 -2
  41. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.d.ts +2 -2
  42. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +4 -4
  43. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +2 -2
  44. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +9 -9
  45. package/dist/chart/drawers/data-series-drawers/histogram.drawer.d.ts +2 -2
  46. package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +3 -3
  47. package/dist/chart/drawers/data-series-drawers/linear.drawer.d.ts +2 -2
  48. package/dist/chart/drawers/data-series-drawers/linear.drawer.js +3 -3
  49. package/dist/chart/drawers/data-series-drawers/points.drawer.d.ts +2 -2
  50. package/dist/chart/drawers/data-series-drawers/points.drawer.js +3 -3
  51. package/dist/chart/drawers/data-series-drawers/text.drawer.d.ts +2 -2
  52. package/dist/chart/drawers/data-series-drawers/text.drawer.js +2 -2
  53. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +2 -2
  54. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +16 -13
  55. package/dist/chart/drawers/data-series-drawers/triangle.drawer.d.ts +2 -2
  56. package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +2 -2
  57. package/dist/chart/drawers/data-series.drawer.d.ts +5 -5
  58. package/dist/chart/drawers/data-series.drawer.js +3 -3
  59. package/dist/chart/drawers/ht-data-series.drawer.js +2 -2
  60. package/dist/chart/model/data-series-view.js +3 -1
  61. package/dist/chart/model/data-series.model.js +1 -1
  62. package/dist/chart/model/scale.model.js +4 -0
  63. package/dist/dxchart.min.js +4 -4
  64. package/package.json +1 -1
@@ -32,10 +32,13 @@ export declare class YAxisComponent extends ChartBaseElement {
32
32
  private config;
33
33
  private canvasModel;
34
34
  scale: ScaleModel;
35
+ private canvasInputListeners;
35
36
  private canvasBoundsContainer;
37
+ private chartPanComponent;
36
38
  private cursors;
37
39
  paneUUID: string;
38
40
  extentIdx: number;
41
+ private hitTestCanvasModel;
39
42
  private chartResizeHandler;
40
43
  private labelsColorByChartTypeMap;
41
44
  yAxisScaleHandler: YAxisScaleHandler;
@@ -44,6 +47,7 @@ export declare class YAxisComponent extends ChartBaseElement {
44
47
  axisAlignSetSubject: Subject<YAxisAlign>;
45
48
  readonly state: YAxisConfig;
46
49
  constructor(eventBus: EventBus, config: FullChartConfig, canvasModel: CanvasModel, scale: ScaleModel, canvasInputListeners: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, chartPanComponent: ChartPanComponent, cursors: CursorHandler, valueFormatter: (value: number) => string, dataSeriesProvider: () => DataSeriesModel | undefined, paneUUID: string, extentIdx: number, hitTestCanvasModel: HitTestCanvasModel, chartResizeHandler: ChartResizeHandler, initialState?: YAxisConfig);
50
+ setExtentIdx(extentIdx: number): void;
47
51
  /**
48
52
  * Registers default label color resolvers for different chart types.
49
53
  * @private
@@ -53,7 +57,7 @@ export declare class YAxisComponent extends ChartBaseElement {
53
57
  */
54
58
  private registerDefaultLabelColorResolvers;
55
59
  protected doActivate(): void;
56
- private updateCursor;
60
+ updateCursor(): void;
57
61
  /**
58
62
  * Updates labels visual appearance on canvas
59
63
  */
@@ -3,11 +3,6 @@
3
3
  * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
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
- /*
7
- * Copyright (C) 2019 - 2024 Devexperts Solutions IE Limited
8
- * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
9
- * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
10
- */
11
6
  import { Subject } from 'rxjs';
12
7
  import { CanvasElement } from '../../canvas/canvas-bounds-container';
13
8
  import { ChartBaseElement } from '../../model/chart-base-element';
@@ -28,10 +23,13 @@ export class YAxisComponent extends ChartBaseElement {
28
23
  this.config = config;
29
24
  this.canvasModel = canvasModel;
30
25
  this.scale = scale;
26
+ this.canvasInputListeners = canvasInputListeners;
31
27
  this.canvasBoundsContainer = canvasBoundsContainer;
28
+ this.chartPanComponent = chartPanComponent;
32
29
  this.cursors = cursors;
33
30
  this.paneUUID = paneUUID;
34
31
  this.extentIdx = extentIdx;
32
+ this.hitTestCanvasModel = hitTestCanvasModel;
35
33
  this.chartResizeHandler = chartResizeHandler;
36
34
  this.labelsColorByChartTypeMap = {};
37
35
  this.axisTypeSetSubject = new Subject();
@@ -62,6 +60,14 @@ export class YAxisComponent extends ChartBaseElement {
62
60
  this.updateCursor();
63
61
  this.registerDefaultLabelColorResolvers();
64
62
  }
63
+ setExtentIdx(extentIdx) {
64
+ this.extentIdx = extentIdx;
65
+ this.model.extentIdx = extentIdx;
66
+ this.yAxisScaleHandler.deactivate();
67
+ this.removeChildEntity(this.yAxisScaleHandler);
68
+ this.yAxisScaleHandler = new YAxisScaleHandler(this.eventBus, this.state, this.chartPanComponent, this.scale, this.canvasInputListeners, this.canvasBoundsContainer, this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.PANE_UUID_Y_AXIS(this.paneUUID, extentIdx)), this.hitTestCanvasModel);
69
+ this.addChildEntity(this.yAxisScaleHandler);
70
+ }
65
71
  /**
66
72
  * Registers default label color resolvers for different chart types.
67
73
  * @private
@@ -30,9 +30,11 @@ export class YAxisDrawer {
30
30
  const labels = yAxisComponent.model.baseLabelsModel.labels;
31
31
  const bounds = yAxisComponent.getBounds();
32
32
  const ctx = this.canvasModel.ctx;
33
- // draw axis background rect animation
34
- ctx.fillStyle = this.getBackgroundColor();
35
- ctx.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
33
+ // draw axis background rect if the background color is not used
34
+ if (!this.fullConfig.components.chart.applyBackgroundToAxes.y) {
35
+ ctx.fillStyle = this.getBackgroundColor();
36
+ ctx.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
37
+ }
36
38
  const font = getFontFromConfig(yAxisComponent.state);
37
39
  const fontHeight = calculateSymbolHeight(font, ctx);
38
40
  const textColor = this.getLabelTextColor();
@@ -18,7 +18,7 @@ export declare class YAxisModel extends ChartBaseElement {
18
18
  private paneUUID;
19
19
  private state;
20
20
  private canvasBoundsContainer;
21
- private extentIdx;
21
+ extentIdx: number;
22
22
  labelsGenerator: NumericYAxisLabelsGenerator;
23
23
  baseLabelsModel: YAxisBaseLabelsModel;
24
24
  fancyLabelsModel: FancyYAxisLabelsModel;
@@ -5,9 +5,9 @@
5
5
  */
6
6
  import { ChartConfigComponentsChart } from '../../chart.config';
7
7
  import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
8
- import { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
8
+ import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
9
9
  export declare class AreaDrawer implements SeriesDrawer {
10
10
  private config;
11
11
  constructor(config: ChartConfigComponentsChart);
12
- draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel, drawerConfig: ChartDrawerConfig): void;
12
+ draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
13
13
  }
@@ -10,15 +10,15 @@ export class AreaDrawer {
10
10
  constructor(config) {
11
11
  this.config = config;
12
12
  }
13
- draw(ctx, points, model, drawerConfig) {
13
+ draw(ctx, points, model, hitTestDrawerConfig) {
14
14
  if (model instanceof CandleSeriesModel) {
15
15
  // @ts-ignore
16
16
  const visualCandles = flat(points);
17
17
  if (visualCandles.length === 0) {
18
18
  return;
19
19
  }
20
- if (drawerConfig.singleColor) {
21
- ctx.strokeStyle = drawerConfig.singleColor;
20
+ if (hitTestDrawerConfig.color) {
21
+ ctx.strokeStyle = hitTestDrawerConfig.color;
22
22
  }
23
23
  else {
24
24
  ctx.strokeStyle = model.colors.areaTheme.lineColor;
@@ -51,8 +51,8 @@ export class AreaDrawer {
51
51
  ctx.lineTo(floor(firstLineX), bottomY);
52
52
  ctx.closePath();
53
53
  let fillColor;
54
- if (drawerConfig.singleColor) {
55
- ctx.fillStyle = drawerConfig.singleColor;
54
+ if (hitTestDrawerConfig.color) {
55
+ ctx.fillStyle = hitTestDrawerConfig.color;
56
56
  }
57
57
  else {
58
58
  ctx.fillStyle =
@@ -5,10 +5,10 @@
5
5
  */
6
6
  import { ChartConfigComponentsChart } from '../../chart.config';
7
7
  import { DataSeriesModel, VisualSeriesPoint } from '../../model/data-series.model';
8
- import { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
8
+ import { HTSeriesDrawerConfig, SeriesDrawer } from '../data-series.drawer';
9
9
  export declare class BarDrawer implements SeriesDrawer {
10
10
  private config;
11
11
  constructor(config: ChartConfigComponentsChart);
12
12
  private setFillStyle;
13
- draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], candleSeries: DataSeriesModel, drawerConfig: ChartDrawerConfig): void;
13
+ draw(ctx: CanvasRenderingContext2D, points: VisualSeriesPoint[][], candleSeries: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
14
14
  }
@@ -12,9 +12,9 @@ export class BarDrawer {
12
12
  constructor(config) {
13
13
  this.config = config;
14
14
  }
15
- setFillStyle(ctx, drawerConfig, candleSeries, visualCandle) {
16
- if (drawerConfig.singleColor) {
17
- ctx.strokeStyle = drawerConfig.singleColor;
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, drawerConfig) {
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, drawerConfig);
30
+ setLineWidth(ctx, this.config.barLineWidth, candleSeries, hitTestDrawerConfig);
31
31
  avoidAntialiasing(ctx, () => {
32
32
  for (const visualCandle of visualCandles) {
33
- this.setFillStyle(ctx, drawerConfig, candleSeries, visualCandle);
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 { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
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, drawerConfig?: ChartDrawerConfig): void;
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, drawerConfig) {
15
- if (drawerConfig !== undefined && model instanceof CandleSeriesModel) {
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, drawerConfig, prevHigherThanBL);
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, drawerConfig, curHigherThanBL);
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, drawerConfig, upper) => {
77
- if (drawerConfig.singleColor) {
78
- ctx.fillStyle = drawerConfig.singleColor;
79
- ctx.strokeStyle = drawerConfig.singleColor;
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 { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
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, drawerConfig: ChartDrawerConfig): void;
22
- drawCandle(ctx: CanvasRenderingContext2D, drawerConfig: ChartDrawerConfig, candleSeries: CandleSeriesModel, visualCandle: VisualCandle): void;
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, drawerConfig) {
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, drawerConfig, this.config.candleLineWidth);
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, drawerConfig, model, visualCandle);
50
+ this.drawCandle(ctx, hitTestDrawerConfig, model, visualCandle);
51
51
  }
52
52
  }
53
53
  });
54
54
  }
55
55
  }
56
- drawCandle(ctx, drawerConfig, candleSeries, visualCandle) {
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 (drawerConfig.singleColor) {
63
- ctx.fillStyle = drawerConfig.singleColor;
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 (drawerConfig.singleColor) {
82
- ctx.strokeStyle = drawerConfig.singleColor;
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, drawerConfig, currentCandleTheme, visualCandle, baseX + this.halfLineWidthCU, bodyStart + this.halfLineWidthCU, width - this.lineWidthCU, bodyH - this.lineWidthCU);
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 (drawerConfig.singleColor) {
133
- ctx.fillStyle = drawerConfig.singleColor;
132
+ if (hitTestDrawerConfig.color) {
133
+ ctx.fillStyle = hitTestDrawerConfig.color;
134
134
  }
135
- ctx.fillRect(paddingBaseX, bodyStart, paddingWidth, bodyH);
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, drawerConfig, currentCandleTheme, visualCandle, paddingBaseX + this.halfLineWidthCU, bodyStart + this.halfLineWidthCU, paddingWidth - this.lineWidthCU, bodyH - this.lineWidthCU);
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, drawerConfig, candleTheme, visualCandle, x, y, w, h) {
157
- if (drawerConfig.singleColor) {
158
- ctx.strokeStyle = drawerConfig.singleColor;
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 { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
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, drawerConfig: ChartDrawerConfig): void;
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, drawerConfig) {
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 (drawerConfig.singleColor) {
27
- ctx.fillStyle = drawerConfig.singleColor;
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 (drawerConfig.singleColor) {
40
- ctx.fillStyle = drawerConfig.singleColor;
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 { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
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, drawerConfig: ChartDrawerConfig): void;
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, drawerConfig) {
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, drawerConfig, this.config.selectedWidth);
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 (drawerConfig.singleColor) {
23
- ctx.strokeStyle = drawerConfig.singleColor;
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 (!drawerConfig.singleColor) {
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 { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
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, drawerConfig: ChartDrawerConfig): void;
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, drawerConfig) {
12
+ draw(ctx, points, model, hitTestDrawerConfig) {
13
13
  var _a;
14
- ctx.fillStyle = (_a = drawerConfig.singleColor) !== null && _a !== void 0 ? _a : this.config.mainColor;
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, SCATTER_PLOT_RADIUS, 0, Math.PI * 2, true);
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 { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
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, config: ChartDrawerConfig): void;
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, config) {
27
+ draw(ctx, allPoints, model, hitTestDrawerConfig) {
28
28
  if (this.isChartTypeAllowed()) {
29
29
  this.beforeDraw(ctx);
30
- this.drawer.draw(ctx, allPoints, model, config);
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 { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
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, drawerConfig: ChartDrawerConfig): void;
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 { round } from '../../utils/math.utils';
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, drawerConfig) {
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 = drawerConfig.singleColor) !== null && _a !== void 0 ? _a : config.color;
21
+ ctx.fillStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color;
22
22
  points.forEach(p => {
23
- const visualCandle = this.chartModel.getVisualCandle(round(p.centerUnit));
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 { ChartDrawerConfig, SeriesDrawer } from '../data-series.drawer';
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, drawerConfig: ChartDrawerConfig): void;
16
+ draw(ctx: CanvasRenderingContext2D, allPoints: VisualSeriesPoint[][], model: DataSeriesModel, hitTestDrawerConfig: HTSeriesDrawerConfig): void;
17
17
  private drawLine;
18
18
  private drawDifference;
19
19
  private fillCloud;