@devexperts/dxcharts-lite 2.7.9 → 2.7.11

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 (30) hide show
  1. package/dist/chart/canvas/canvas-bounds-container.js +0 -5
  2. package/dist/chart/chart.config.d.ts +7 -0
  3. package/dist/chart/chart.config.js +3 -0
  4. package/dist/chart/chart.d.ts +5 -1
  5. package/dist/chart/chart.js +12 -0
  6. package/dist/chart/components/chart/chart-area-pan.handler.js +0 -5
  7. package/dist/chart/components/chart/chart-base.model.d.ts +4 -1
  8. package/dist/chart/components/chart/chart-base.model.js +2 -2
  9. package/dist/chart/components/chart/chart.model.d.ts +4 -1
  10. package/dist/chart/components/chart/chart.model.js +6 -6
  11. package/dist/chart/components/chart/{price.formatter.d.ts → price-formatters/price.formatter.d.ts} +7 -6
  12. package/dist/chart/components/chart/{price.formatter.js → price-formatters/price.formatter.js} +10 -5
  13. package/dist/chart/components/chart/price-formatters/treasury-price.formatter.d.ts +17 -0
  14. package/dist/chart/components/chart/price-formatters/treasury-price.formatter.js +27 -0
  15. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +4 -1
  16. package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +8 -2
  17. package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +8 -7
  18. package/dist/chart/components/pane/extent/y-extent-component.d.ts +2 -1
  19. package/dist/chart/components/pane/extent/y-extent-component.js +4 -8
  20. package/dist/chart/components/pane/pane.component.d.ts +1 -1
  21. package/dist/chart/components/pane/pane.component.js +2 -7
  22. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +3 -1
  23. package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +9 -4
  24. package/dist/chart/components/y_axis/y-axis.model.js +1 -1
  25. package/dist/chart/model/data-series.model.d.ts +4 -4
  26. package/dist/chart/model/data-series.model.js +3 -2
  27. package/dist/chart/utils/candles.utils.d.ts +5 -1
  28. package/dist/chart/utils/candles.utils.js +14 -4
  29. package/dist/dxchart.min.js +4 -4
  30. package/package.json +1 -1
@@ -5,4 +5,8 @@
5
5
  */
6
6
  import { DataSeriesPoint } from '../model/data-series.model';
7
7
  import { BinarySearchResult } from './array.utils';
8
- export declare const searchCandleIndex: (timestamp: number, shouldExtrapolate: boolean, candles: DataSeriesPoint[], periodMs?: number) => BinarySearchResult;
8
+ export declare const getDaysOnlyTimestampFn: (isDaysPeriod: boolean) => (timestamp: number) => number;
9
+ export declare const searchCandleIndex: (rawTimestamp: number, options: {
10
+ extrapolate?: boolean | undefined;
11
+ isDaysPeriod?: boolean | undefined;
12
+ } | undefined, candles: DataSeriesPoint[], periodMs?: number) => BinarySearchResult;
@@ -5,10 +5,20 @@
5
5
  */
6
6
  import { binarySearch, firstOf, lastOf } from './array.utils';
7
7
  import { floor } from './math.utils';
8
- export const searchCandleIndex = (timestamp, shouldExtrapolate, candles, periodMs = 1000) => {
8
+ export const getDaysOnlyTimestampFn = (isDaysPeriod) => (timestamp) => {
9
+ if (isDaysPeriod) {
10
+ return new Date(timestamp).setHours(0, 0, 0, 0);
11
+ }
12
+ return timestamp;
13
+ };
14
+ export const searchCandleIndex = (rawTimestamp, options = {}, candles, periodMs = 1000) => {
9
15
  var _a, _b, _c, _d;
10
- const firstTimestamp = (_b = (_a = firstOf(candles)) === null || _a === void 0 ? void 0 : _a.timestamp) !== null && _b !== void 0 ? _b : 0;
11
- const lastTimestamp = (_d = (_c = lastOf(candles)) === null || _c === void 0 ? void 0 : _c.timestamp) !== null && _d !== void 0 ? _d : 0;
16
+ const { extrapolate, isDaysPeriod } = options;
17
+ const shouldExtrapolate = Boolean(extrapolate);
18
+ const getDaysOnlyTimestamp = getDaysOnlyTimestampFn(Boolean(isDaysPeriod));
19
+ const timestamp = getDaysOnlyTimestamp(rawTimestamp);
20
+ const firstTimestamp = getDaysOnlyTimestamp((_b = (_a = firstOf(candles)) === null || _a === void 0 ? void 0 : _a.timestamp) !== null && _b !== void 0 ? _b : 0);
21
+ const lastTimestamp = getDaysOnlyTimestamp((_d = (_c = lastOf(candles)) === null || _c === void 0 ? void 0 : _c.timestamp) !== null && _d !== void 0 ? _d : 0);
12
22
  if (timestamp > lastTimestamp) {
13
23
  // TODO rework the code below, it looks very very sus ( ≖.≖)
14
24
  if (shouldExtrapolate) {
@@ -42,6 +52,6 @@ export const searchCandleIndex = (timestamp, shouldExtrapolate, candles, periodM
42
52
  }
43
53
  }
44
54
  else {
45
- return binarySearch(candles, timestamp, candle => candle.timestamp);
55
+ return binarySearch(candles, timestamp, candle => getDaysOnlyTimestamp(candle.timestamp));
46
56
  }
47
57
  };