@devexperts/dxcharts-lite 2.7.1 → 2.7.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.
Files changed (68) 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/bootstrap.js +7 -4
  9. package/dist/chart/canvas/canvas-chart-html.js +1 -0
  10. package/dist/chart/canvas/chart-elements.d.ts +1 -0
  11. package/dist/chart/chart.config.d.ts +7 -0
  12. package/dist/chart/chart.config.js +4 -0
  13. package/dist/chart/components/chart/chart.component.d.ts +19 -6
  14. package/dist/chart/components/chart/chart.component.js +27 -8
  15. package/dist/chart/components/pane/pane.component.js +5 -1
  16. package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +4 -1
  17. package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +1 -1
  18. package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +3 -2
  19. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +2 -1
  20. package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +5 -3
  21. package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +5 -0
  22. package/dist/chart/components/y_axis/y-axis-base-labels.model.js +9 -0
  23. package/dist/chart/components/y_axis/y-axis.component.d.ts +6 -1
  24. package/dist/chart/components/y_axis/y-axis.component.js +14 -5
  25. package/dist/chart/components/y_axis/y-axis.drawer.js +5 -3
  26. package/dist/chart/components/y_axis/y-axis.model.d.ts +1 -1
  27. package/dist/chart/drawers/chart-background.drawer.d.ts +1 -0
  28. package/dist/chart/drawers/chart-background.drawer.js +2 -1
  29. package/dist/chart/drawers/chart-type-drawers/area.drawer.d.ts +2 -2
  30. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +5 -5
  31. package/dist/chart/drawers/chart-type-drawers/bar.drawer.d.ts +2 -2
  32. package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +6 -6
  33. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.d.ts +2 -2
  34. package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +8 -8
  35. package/dist/chart/drawers/chart-type-drawers/candle.drawer.d.ts +3 -3
  36. package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +20 -16
  37. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.d.ts +2 -2
  38. package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +5 -5
  39. package/dist/chart/drawers/chart-type-drawers/line.drawer.d.ts +2 -2
  40. package/dist/chart/drawers/chart-type-drawers/line.drawer.js +5 -5
  41. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.d.ts +2 -2
  42. package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +4 -3
  43. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.d.ts +2 -2
  44. package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +2 -2
  45. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.d.ts +2 -2
  46. package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +4 -4
  47. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +2 -2
  48. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +9 -9
  49. package/dist/chart/drawers/data-series-drawers/histogram.drawer.d.ts +2 -2
  50. package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +3 -3
  51. package/dist/chart/drawers/data-series-drawers/linear.drawer.d.ts +2 -2
  52. package/dist/chart/drawers/data-series-drawers/linear.drawer.js +3 -3
  53. package/dist/chart/drawers/data-series-drawers/points.drawer.d.ts +2 -2
  54. package/dist/chart/drawers/data-series-drawers/points.drawer.js +3 -3
  55. package/dist/chart/drawers/data-series-drawers/text.drawer.d.ts +2 -2
  56. package/dist/chart/drawers/data-series-drawers/text.drawer.js +2 -2
  57. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +2 -2
  58. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +16 -13
  59. package/dist/chart/drawers/data-series-drawers/triangle.drawer.d.ts +2 -2
  60. package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +2 -2
  61. package/dist/chart/drawers/data-series.drawer.d.ts +5 -5
  62. package/dist/chart/drawers/data-series.drawer.js +3 -3
  63. package/dist/chart/drawers/ht-data-series.drawer.js +2 -2
  64. package/dist/chart/model/scale.model.js +4 -0
  65. package/dist/chart/utils/numeric-constants.utils.d.ts +6 -0
  66. package/dist/chart/utils/numeric-constants.utils.js +6 -0
  67. package/dist/dxchart.min.js +5 -4
  68. package/package.json +1 -1
@@ -151,7 +151,11 @@ export class PaneComponent extends ChartBaseElement {
151
151
  extentComponents.forEach(extentComponent => extentComponent.disable());
152
152
  this.yExtentComponents = this.yExtentComponents.filter(current => !extentComponents.map(excluded => excluded.idx).includes(current.idx));
153
153
  // re-index extents
154
- this.yExtentComponents.forEach((c, idx) => (c.idx = idx));
154
+ this.yExtentComponents.forEach((c, idx) => {
155
+ c.yAxis.setExtentIdx(idx);
156
+ c.idx = idx;
157
+ c.yAxis.updateCursor();
158
+ });
155
159
  this.canvasBoundsContainer.updateYAxisWidths();
156
160
  this.yExtentComponentsChangedSubject.next();
157
161
  }
@@ -35,7 +35,10 @@ export class XAxisTimeLabelsDrawer {
35
35
  ctx.font = font;
36
36
  ctx.fillStyle = xAxisColors.backgroundColor;
37
37
  const bounds = this.canvasBoundsContainer.getBounds(CanvasElement.X_AXIS);
38
- ctx.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
38
+ // draw axis background rect if the background color is not used
39
+ if (!this.config.components.chart.applyBackgroundToAxes.x) {
40
+ ctx.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
41
+ }
39
42
  const color = this.config.colors.xAxis.labelTextColor;
40
43
  const labels = this.labelsProvider();
41
44
  this.drawLabels(ctx, labels, bounds, color, fontHeight, fontFamily, offsetTop + X_AXIS_MOBILE_PADDING / 2);
@@ -19,5 +19,5 @@ export declare const priceLabelDrawersMap: Record<YAxisVisualLabelType, LabelDra
19
19
  * @param canvasBoundsContainer
20
20
  * @param config
21
21
  */
22
- export declare function drawLabel(ctx: CanvasRenderingContext2D, backgroundCtx: CanvasRenderingContext2D, bounds: Bounds, paneBounds: Bounds, visualLabel: VisualYAxisLabel, canvasBoundsContainer: CanvasBoundsContainer, config: YAxisConfig, colors: FullChartColors): void;
22
+ export declare function drawLabel(ctx: CanvasRenderingContext2D, yAxisDescriptionsCtx: CanvasRenderingContext2D, backgroundCtx: CanvasRenderingContext2D, bounds: Bounds, paneBounds: Bounds, visualLabel: VisualYAxisLabel, canvasBoundsContainer: CanvasBoundsContainer, config: YAxisConfig, colors: FullChartColors): void;
23
23
  export {};
@@ -25,7 +25,7 @@ export const priceLabelDrawersMap = {
25
25
  * @param canvasBoundsContainer
26
26
  * @param config
27
27
  */
28
- export function drawLabel(ctx, backgroundCtx, bounds, paneBounds, visualLabel, canvasBoundsContainer, config, colors) {
28
+ export function drawLabel(ctx, yAxisDescriptionsCtx, backgroundCtx, bounds, paneBounds, visualLabel, canvasBoundsContainer, config, colors) {
29
29
  var _a, _b, _c, _d, _e;
30
30
  const centralY = visualLabel.y;
31
31
  const text = visualLabel.labelText;
@@ -48,7 +48,8 @@ export function drawLabel(ctx, backgroundCtx, bounds, paneBounds, visualLabel, c
48
48
  const drawLabel = priceLabelDrawersMap[appearanceType];
49
49
  const showDescription = config.labels.descriptions;
50
50
  const showLine = isLineVisible(bounds, labelY, labelBoxHeight);
51
- const _drawDescription = () => showDescription && drawDescription(backgroundCtx, ctx, bounds, paneBounds, visualLabel, config);
51
+ const _drawDescription = () => showDescription &&
52
+ drawDescription(backgroundCtx, yAxisDescriptionsCtx, bounds, paneBounds, visualLabel, config);
52
53
  let lineXStart;
53
54
  let lineXEnd;
54
55
  // line should touch the label
@@ -11,11 +11,12 @@ import { PaneManager } from '../../pane/pane-manager.component';
11
11
  import { LabelGroup } from './y-axis-labels.model';
12
12
  export declare class YAxisPriceLabelsDrawer implements Drawer {
13
13
  private yAxisLabelsCanvasModel;
14
+ private yAxisDescriptionsCanvasModel;
14
15
  private backgroundCanvasModel;
15
16
  private canvasBoundsContainer;
16
17
  private fullConfig;
17
18
  private paneManager;
18
- constructor(yAxisLabelsCanvasModel: CanvasModel, backgroundCanvasModel: CanvasModel, canvasBoundsContainer: CanvasBoundsContainer, fullConfig: FullChartConfig, paneManager: PaneManager);
19
+ constructor(yAxisLabelsCanvasModel: CanvasModel, yAxisDescriptionsCanvasModel: CanvasModel, backgroundCanvasModel: CanvasModel, canvasBoundsContainer: CanvasBoundsContainer, fullConfig: FullChartConfig, paneManager: PaneManager);
19
20
  draw(): void;
20
21
  drawHighlightedBackgroundBetweenLabels(orderedLabels: LabelGroup[]): void;
21
22
  getCanvasIds(): Array<string>;
@@ -7,8 +7,9 @@ import { CanvasElement, CHART_UUID, limitYToBounds, } from '../../../canvas/canv
7
7
  import { fillRect } from '../../../utils/canvas/canvas-drawing-functions.utils';
8
8
  import { drawLabel } from './price-label.drawer';
9
9
  export class YAxisPriceLabelsDrawer {
10
- constructor(yAxisLabelsCanvasModel, backgroundCanvasModel, canvasBoundsContainer, fullConfig, paneManager) {
10
+ constructor(yAxisLabelsCanvasModel, yAxisDescriptionsCanvasModel, backgroundCanvasModel, canvasBoundsContainer, fullConfig, paneManager) {
11
11
  this.yAxisLabelsCanvasModel = yAxisLabelsCanvasModel;
12
+ this.yAxisDescriptionsCanvasModel = yAxisDescriptionsCanvasModel;
12
13
  this.backgroundCanvasModel = backgroundCanvasModel;
13
14
  this.canvasBoundsContainer = canvasBoundsContainer;
14
15
  this.fullConfig = fullConfig;
@@ -17,6 +18,7 @@ export class YAxisPriceLabelsDrawer {
17
18
  draw() {
18
19
  const ctx = this.yAxisLabelsCanvasModel.ctx;
19
20
  const backgroundCtx = this.backgroundCanvasModel.ctx;
21
+ const descriptionsCtx = this.yAxisDescriptionsCanvasModel.ctx;
20
22
  this.paneManager.yExtents.forEach(extent => {
21
23
  if (extent.yAxis.state.visible) {
22
24
  const yAxisBounds = extent.getYAxisBounds();
@@ -26,10 +28,10 @@ export class YAxisPriceLabelsDrawer {
26
28
  orderedLabels.forEach(l => {
27
29
  var _a;
28
30
  const bounds = (_a = l.bounds) !== null && _a !== void 0 ? _a : yAxisBounds;
29
- l.labels.forEach(vl => drawLabel(ctx, backgroundCtx, bounds, paneBounds, vl, this.canvasBoundsContainer, extent.yAxis.state, this.fullConfig.colors));
31
+ l.labels.forEach(vl => drawLabel(ctx, descriptionsCtx, backgroundCtx, bounds, paneBounds, vl, this.canvasBoundsContainer, extent.yAxis.state, this.fullConfig.colors));
30
32
  });
31
33
  // TODO I added this as a simple mechanism to add custom labels, we need to review it
32
- Object.values(extent.yAxis.model.fancyLabelsModel.customLabels).forEach(l => drawLabel(ctx, backgroundCtx, yAxisBounds, paneBounds, l, this.canvasBoundsContainer, extent.yAxis.state, this.fullConfig.colors));
34
+ Object.values(extent.yAxis.model.fancyLabelsModel.customLabels).forEach(l => drawLabel(ctx, descriptionsCtx, backgroundCtx, yAxisBounds, paneBounds, l, this.canvasBoundsContainer, extent.yAxis.state, this.fullConfig.colors));
33
35
  }
34
36
  });
35
37
  }
@@ -25,6 +25,11 @@ export declare class YAxisBaseLabelsModel extends ChartBaseElement {
25
25
  * If the height of the canvas bounds changes by more than 1.5 times the previous height, the labels cache is invalidated and the previous y-axis height is updated.
26
26
  */
27
27
  protected doActivate(): void;
28
+ /**
29
+ * Generates new labels with labelsGenerator
30
+ * Then, it calls the updateYAxisWidth method to update the width of the y-axis.
31
+ */
32
+ recalculateLabels(): void;
28
33
  /**
29
34
  * Updates the labels of the chart's y-axis by generating new numeric labels using the yAxisLabelsGenerator object.
30
35
  * Then, it calls the updateYAxisWidth method to update the width of the y-axis.
@@ -41,6 +41,15 @@ export class YAxisBaseLabelsModel extends ChartBaseElement {
41
41
  this.prevYAxisHeight = height;
42
42
  }))).subscribe(() => this.updateLabels()));
43
43
  }
44
+ /**
45
+ * Generates new labels with labelsGenerator
46
+ * Then, it calls the updateYAxisWidth method to update the width of the y-axis.
47
+ */
48
+ recalculateLabels() {
49
+ const labels = this.labelsGenerator.doGenerateLabels();
50
+ this.labels = labels;
51
+ animationFrameThrottledPrior(this.animFrameId, () => this.canvasBoundsContainer.updateYAxisWidths());
52
+ }
44
53
  /**
45
54
  * Updates the labels of the chart's y-axis by generating new numeric labels using the yAxisLabelsGenerator object.
46
55
  * Then, it calls the updateYAxisWidth method to update the width of the y-axis.
@@ -32,18 +32,23 @@ 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;
42
45
  model: YAxisModel;
43
46
  axisTypeSetSubject: Subject<PriceAxisType>;
44
47
  axisAlignSetSubject: Subject<YAxisAlign>;
48
+ axisAlignMovedSubject: Subject<YAxisAlign>;
45
49
  readonly state: YAxisConfig;
46
50
  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);
51
+ setExtentIdx(extentIdx: number): void;
47
52
  /**
48
53
  * Registers default label color resolvers for different chart types.
49
54
  * @private
@@ -53,7 +58,7 @@ export declare class YAxisComponent extends ChartBaseElement {
53
58
  */
54
59
  private registerDefaultLabelColorResolvers;
55
60
  protected doActivate(): void;
56
- private updateCursor;
61
+ updateCursor(): void;
57
62
  /**
58
63
  * Updates labels visual appearance on canvas
59
64
  */
@@ -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,14 +23,18 @@ 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();
38
36
  this.axisAlignSetSubject = new Subject();
37
+ this.axisAlignMovedSubject = new Subject();
39
38
  /* This function assigns a callback to be executed when a double-click event is detected.
40
39
  * It accepts one parameter `cb`, which is a callback function.
41
40
  * When a double-click event occurs, the specified callback function `cb` will be invoked.
@@ -62,6 +61,14 @@ export class YAxisComponent extends ChartBaseElement {
62
61
  this.updateCursor();
63
62
  this.registerDefaultLabelColorResolvers();
64
63
  }
64
+ setExtentIdx(extentIdx) {
65
+ this.extentIdx = extentIdx;
66
+ this.model.extentIdx = extentIdx;
67
+ this.yAxisScaleHandler.deactivate();
68
+ this.removeChildEntity(this.yAxisScaleHandler);
69
+ 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);
70
+ this.addChildEntity(this.yAxisScaleHandler);
71
+ }
65
72
  /**
66
73
  * Registers default label color resolvers for different chart types.
67
74
  * @private
@@ -240,7 +247,9 @@ export class YAxisComponent extends ChartBaseElement {
240
247
  togglePriceScaleInverse(inverse) {
241
248
  this.scale.state.inverse = inverse;
242
249
  this.scale.inverseY = inverse;
250
+ this.model.fancyLabelsModel.updateLabels();
243
251
  this.scale.scaleInversedSubject.next(inverse);
252
+ this.canvasModel.fireDraw();
244
253
  }
245
254
  /**
246
255
  * Changes the visibility of the labels' descriptions.
@@ -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;
@@ -12,6 +12,7 @@ export declare class BackgroundDrawer implements Drawer {
12
12
  private drawPredicate;
13
13
  constructor(canvasModel: CanvasModel, config: FullChartConfig, drawPredicate?: () => boolean);
14
14
  private prevState;
15
+ isColorsChanged: () => boolean;
15
16
  draw(): void;
16
17
  getCanvasIds(): Array<string>;
17
18
  }
@@ -13,9 +13,10 @@ export class BackgroundDrawer {
13
13
  this.drawPredicate = drawPredicate;
14
14
  // we need to save previous state to avoid unnecessary redraws
15
15
  this.prevState = {};
16
+ this.isColorsChanged = () => !deepEqual(this.config.colors.chartAreaTheme, this.prevState);
16
17
  }
17
18
  draw() {
18
- if (this.drawPredicate() || !deepEqual(this.config.colors.chartAreaTheme, this.prevState)) {
19
+ if (this.drawPredicate() || this.isColorsChanged()) {
19
20
  this.canvasModel.clear();
20
21
  const ctx = this.canvasModel.ctx;
21
22
  if (this.config.colors.chartAreaTheme.backgroundMode === 'gradient') {
@@ -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);