@devexperts/dxcharts-lite 2.7.5 → 2.7.7

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 (35) hide show
  1. package/README.md +41 -43
  2. package/dist/chart/canvas/canvas-bounds-container.d.ts +1 -0
  3. package/dist/chart/canvas/canvas-bounds-container.js +8 -0
  4. package/dist/chart/chart.config.d.ts +5 -0
  5. package/dist/chart/chart.config.js +4 -0
  6. package/dist/chart/components/chart/candle.functions.js +1 -0
  7. package/dist/chart/components/highlights/highlights.drawer.js +4 -1
  8. package/dist/chart/components/pane/extent/y-extent-component.d.ts +3 -1
  9. package/dist/chart/components/pane/extent/y-extent-component.js +19 -3
  10. package/dist/chart/components/pane/pane-manager.component.js +7 -2
  11. package/dist/chart/components/pane/pane.component.d.ts +2 -2
  12. package/dist/chart/components/pane/pane.component.js +20 -1
  13. package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +4 -1
  14. package/dist/chart/components/y_axis/y-axis.component.d.ts +1 -1
  15. package/dist/chart/components/y_axis/y-axis.component.js +1 -1
  16. package/dist/chart/drawers/chart-type-drawers/area.drawer.js +9 -2
  17. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.d.ts +1 -0
  18. package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +12 -9
  19. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +5 -2
  20. package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +12 -11
  21. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +1 -1
  22. package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +14 -15
  23. package/dist/chart/drawers/data-series.drawer.js +3 -1
  24. package/dist/chart/drawers/ht-data-series.drawer.d.ts +1 -0
  25. package/dist/chart/drawers/ht-data-series.drawer.js +2 -1
  26. package/dist/chart/model/candle.model.d.ts +4 -0
  27. package/dist/chart/model/candle.model.js +2 -1
  28. package/dist/chart/model/data-series.config.d.ts +2 -1
  29. package/dist/chart/model/data-series.model.js +1 -1
  30. package/dist/chart/model/visual-candle.d.ts +1 -0
  31. package/dist/chart/model/visual-candle.js +1 -0
  32. package/dist/chart/utils/math.utils.d.ts +2 -1
  33. package/dist/chart/utils/math.utils.js +37 -6
  34. package/dist/dxchart.min.js +4 -4
  35. package/package.json +1 -1
@@ -4,6 +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 { clipToBounds } from '../utils/canvas/canvas-drawing-functions.utils';
7
+ import { isEmpty } from '../utils/object.utils';
7
8
  export const transformToTwoDimension = (points) => (Array.isArray(points[0]) ? points : [points]);
8
9
  /**
9
10
  * Basic data series drawer.
@@ -27,7 +28,8 @@ export class DataSeriesDrawer {
27
28
  }
28
29
  }
29
30
  drawSeries(ctx, series) {
30
- if (series.config.visible) {
31
+ const visibilityPredicates = series.config.additionalVisibilityPredicatesMap;
32
+ if (series.config.visible || (visibilityPredicates && !isEmpty(visibilityPredicates))) {
31
33
  const paintTool = series.config.type;
32
34
  const drawer = this.seriesDrawers[paintTool];
33
35
  if (drawer) {
@@ -8,6 +8,7 @@ import { DataSeriesModel } from '../model/data-series.model';
8
8
  import { HitTestCanvasModel } from '../model/hit-test-canvas.model';
9
9
  import { SeriesDrawer } from './data-series.drawer';
10
10
  import { Drawer } from './drawing-manager';
11
+ export declare const HIT_TEST_HOVER_WIDTH = 7;
11
12
  /***
12
13
  * HitTest Chart drawer. It's used to draw hit test for chart types on the hit-test canvas.
13
14
  */
@@ -4,6 +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 { clipToBounds } from '../utils/canvas/canvas-drawing-functions.utils';
7
+ export const HIT_TEST_HOVER_WIDTH = 7;
7
8
  /***
8
9
  * HitTest Chart drawer. It's used to draw hit test for chart types on the hit-test canvas.
9
10
  */
@@ -32,7 +33,7 @@ export class HTDataSeriesDrawer {
32
33
  if (drawer) {
33
34
  const drawConfig = {
34
35
  color: this.canvasModel.idToColor(series.htId),
35
- hoverWidth: 7,
36
+ hoverWidth: HIT_TEST_HOVER_WIDTH,
36
37
  };
37
38
  // +- 1 to correctly draw points which are partly inside bounds
38
39
  drawer.draw(ctx, series.getSeriesInViewport(series.scale.xStart - 1, series.scale.xEnd + 1), series, drawConfig);
@@ -21,7 +21,11 @@ export interface Candle {
21
21
  readonly expansion?: boolean;
22
22
  idx?: number;
23
23
  readonly impVolatility?: number;
24
+ /**
25
+ * @deprecated might be removed in next major version
26
+ */
24
27
  readonly vwap?: number;
28
+ readonly typicalPrice?: number;
25
29
  }
26
30
  export declare const defaultSortCandles: (candles: Candle[]) => Candle[];
27
31
  export declare const generateCandleId: (timestamp: number, hashValue: number | string) => string;
@@ -50,7 +50,7 @@ export function hollowDirection(open, close) {
50
50
  * @returns {Candle} A new Candle object with the same properties as the base object, with the option to modify the prices.
51
51
  */
52
52
  export function copyCandle(base, idx, pricesAsClose = false) {
53
- const { id, expansion, impVolatility, vwap, volume, timestamp } = base;
53
+ const { id, expansion, impVolatility, vwap, typicalPrice, volume, timestamp } = base;
54
54
  let hi = base.hi;
55
55
  let lo = base.lo;
56
56
  let open = base.open;
@@ -76,5 +76,6 @@ export function copyCandle(base, idx, pricesAsClose = false) {
76
76
  idx: _idx,
77
77
  impVolatility,
78
78
  vwap,
79
+ typicalPrice,
79
80
  };
80
81
  }
@@ -4,10 +4,11 @@
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 { BarTypes, YAxisLabelAppearanceType, YAxisLabelMode } from '../chart.config';
7
- export type DataSeriesType = 'POINTS' | 'LINEAR' | 'HISTOGRAM' | 'TREND_HISTOGRAM' | 'DIFFERENCE' | 'TEXT' | 'ABOVE_CANDLE_TEXT' | 'BELOW_CANDLE_TEXT' | 'ABOVE_CANDLE_TRIANGLE' | 'TRIANGLE' | 'COLOR_CANDLE' | 'RECTANGULAR' | keyof BarTypes | string;
7
+ export type DataSeriesType = 'POINTS' | 'LINEAR' | 'HISTOGRAM' | 'TREND_HISTOGRAM' | 'DIFFERENCE' | 'TEXT' | 'ABOVE_CANDLE_TEXT' | 'BELOW_CANDLE_TEXT' | 'ABOVE_CANDLE_TRIANGLE' | 'TRIANGLE' | 'COLOR_CANDLE' | 'RECTANGULAR' | 'EMA_CLOUD_LINE' | keyof BarTypes | string;
8
8
  export interface DataSeriesConfig {
9
9
  paintConfig: Array<DataSeriesPaintConfig>;
10
10
  visible: boolean;
11
+ additionalVisibilityPredicatesMap?: any;
11
12
  highLowActive: boolean;
12
13
  type: DataSeriesType;
13
14
  /**
@@ -250,7 +250,7 @@ export class DataSeriesModel extends ChartBaseElement {
250
250
  * @returns {string} The formatted value as a string.
251
251
  */
252
252
  valueFormatter(value) {
253
- return defaultValueFormatter(value);
253
+ return this.extentComponent.formatters.regular(value);
254
254
  }
255
255
  /**
256
256
  * Returns a two-dimensional array of the visual points in the viewport of the DataSeriesView.
@@ -30,6 +30,7 @@ export default class VisualCandle extends VisualSeriesPoint {
30
30
  name: PriceMovement;
31
31
  candle: Candle;
32
32
  startUnit: Unit;
33
+ endUnit: Unit;
33
34
  hasBorder: boolean;
34
35
  isActive: boolean;
35
36
  isHollow: boolean;
@@ -23,6 +23,7 @@ export default class VisualCandle extends VisualSeriesPoint {
23
23
  constructor(x, width, open, close, high, low, name, candle, hasBorder = false, isActive = false, isHollow = false) {
24
24
  super(x, close);
25
25
  this.startUnit = x - width / 2;
26
+ this.endUnit = x + width / 2;
26
27
  this.width = width;
27
28
  this.open = open;
28
29
  this.high = high;
@@ -8,7 +8,7 @@ export declare class MathUtils {
8
8
  static roundToNearest(value: number, precision: number): number;
9
9
  static roundUpToNearest(value: number, precision: number): number;
10
10
  static roundDecimal(x: number): number;
11
- static makeDecimal(value: number, precision: number, decimal?: string): string;
11
+ static makeDecimal(value: number, precision: number, decimal?: string, thousandsSeparator?: string): string;
12
12
  static compare(a: number, b: number, eps: number): number;
13
13
  static isZero(a: number): boolean;
14
14
  static cutNumber(value: number, amountToCut: NumberFormatLabels, zeros?: number): string;
@@ -38,3 +38,4 @@ export declare const floor: (value: number) => number;
38
38
  export declare const ceil: (value: number) => number;
39
39
  export declare const round: (value: number) => number;
40
40
  export declare const shiftRight: (value: number, shift: number) => number;
41
+ export declare function countDecimalPlaces(number: number): number;
@@ -45,14 +45,33 @@ export class MathUtils {
45
45
  // Mantissa >= 10^14 with fractions -- just round
46
46
  return Math.round(x);
47
47
  }
48
- static makeDecimal(value, precision, decimal) {
49
- if (isFinite(value)) {
50
- const stringValue = value.toFixed(precision);
51
- return decimal ? stringValue.replace('.', decimal) : stringValue;
52
- }
53
- else {
48
+ static makeDecimal(value, precision, decimal, thousandsSeparator) {
49
+ if (!isFinite(value)) {
54
50
  return '';
55
51
  }
52
+ if (isFinite(value)) {
53
+ let stringValue = value.toFixed(precision);
54
+ if (!thousandsSeparator) {
55
+ return decimal ? stringValue.replace('.', decimal) : stringValue;
56
+ }
57
+ if (decimal === thousandsSeparator) {
58
+ throw new Error('Grouping symbol cannot be the same as decimal separator.');
59
+ }
60
+ const splittedValue = stringValue.split('.');
61
+ let integerPart = splittedValue[0];
62
+ const fractionPart = splittedValue[1];
63
+ if (Math.abs(value) >= 1000) {
64
+ integerPart = integerPart.replace(RegExp('\\d(?=(\\d{3})+$)', 'g'), `$&${thousandsSeparator}`);
65
+ }
66
+ if (fractionPart) {
67
+ stringValue = [integerPart, fractionPart].join(decimal);
68
+ return stringValue;
69
+ }
70
+ else {
71
+ return integerPart;
72
+ }
73
+ }
74
+ return '';
56
75
  }
57
76
  static compare(a, b, eps) {
58
77
  if (a > b + eps) {
@@ -121,3 +140,15 @@ export const ceil = (value) => ~~(value + 1);
121
140
  export const round = (value) => ~~(value + 0.5);
122
141
  // eslint-disable-next-line no-bitwise
123
142
  export const shiftRight = (value, shift) => value >> shift;
143
+ export function countDecimalPlaces(number) {
144
+ if (!Number.isFinite(number)) {
145
+ throw new Error('Input must be a finite number.');
146
+ }
147
+ const numberString = number.toString();
148
+ if (numberString.includes('.')) {
149
+ return numberString.split('.')[1].length;
150
+ }
151
+ else {
152
+ return 0; // No decimal places
153
+ }
154
+ }