@gravity-ui/chartkit 0.9.1 → 0.10.0
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/CHANGELOG.md +13 -0
- package/build/components/ChartKit.css +23 -0
- package/build/components/ChartKit.d.ts +0 -1
- package/build/components/ChartKit.js +4 -5
- package/build/i18n/keysets/en.json +60 -0
- package/build/i18n/keysets/ru.json +62 -0
- package/build/libs/chartkit-error/chartkit-error.d.ts +1 -0
- package/build/libs/chartkit-error/chartkit-error.js +1 -0
- package/build/libs/settings/__tests__/settings.test.js +1 -1
- package/build/libs/settings/settings.d.ts +6 -3
- package/build/libs/settings/settings.js +4 -2
- package/build/plugins/highcharts/__stories__/AreaRange.stories.d.ts +4 -0
- package/build/plugins/highcharts/__stories__/AreaRange.stories.js +22 -0
- package/build/plugins/highcharts/__stories__/Line.stories.d.ts +4 -0
- package/build/plugins/highcharts/__stories__/Line.stories.js +21 -0
- package/build/plugins/highcharts/__stories__/mocks/area-range.d.ts +2 -0
- package/build/plugins/highcharts/__stories__/mocks/area-range.js +61 -0
- package/build/plugins/highcharts/__stories__/mocks/holidays.d.ts +7070 -0
- package/build/plugins/highcharts/__stories__/mocks/holidays.js +7065 -0
- package/build/plugins/highcharts/__stories__/mocks/line.d.ts +2 -0
- package/build/plugins/highcharts/__stories__/mocks/line.js +129 -0
- package/build/plugins/highcharts/index.d.ts +2 -0
- package/build/plugins/highcharts/index.js +5 -0
- package/build/plugins/highcharts/renderer/HighchartsWidget.d.ts +23 -0
- package/build/plugins/highcharts/renderer/HighchartsWidget.js +6 -0
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.css +4 -0
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +575 -0
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.js +115 -0
- package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.css +50 -0
- package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.d.ts +10 -0
- package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.js +32 -0
- package/build/plugins/highcharts/renderer/components/withSplitPane/WithSplitPane.css +4 -0
- package/build/plugins/highcharts/renderer/components/withSplitPane/withSplitPane.d.ts +10 -0
- package/build/plugins/highcharts/renderer/components/withSplitPane/withSplitPane.js +207 -0
- package/build/plugins/highcharts/renderer/helpers/add-holidays.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/add-holidays.js +43 -0
- package/build/plugins/highcharts/renderer/helpers/comments/drawing.d.ts +11 -0
- package/build/plugins/highcharts/renderer/helpers/comments/drawing.js +571 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +575 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.js +1483 -0
- package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/handleLegendItemClick.js +57 -0
- package/build/plugins/highcharts/renderer/helpers/config/options.d.ts +465 -0
- package/build/plugins/highcharts/renderer/helpers/config/options.js +350 -0
- package/build/plugins/highcharts/renderer/helpers/config/types.d.ts +6 -0
- package/build/plugins/highcharts/renderer/helpers/config/types.js +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.d.ts +10 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.js +42 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/addShowInNavigatorToSeries.test.js +99 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.js +17 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/buildNavigatorFallback.test.js +28 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.d.ts +5 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.js +20 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/calculatePrecision.test.js +27 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/concatStrings.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/concatStrings.js +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getChartKitFormattedValue.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getChartKitFormattedValue.js +15 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.d.ts +3 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.js +15 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.test.js +11 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.js +9 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.test.js +20 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/index.d.ts +13 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/index.js +13 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/isNavigatorSeries.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/isNavigatorSeries.js +3 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/isSafari.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/isSafari.js +12 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/isTooltipShared.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/isTooltipShared.js +8 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/isTooltipShared.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/isTooltipShared.test.js +31 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/localStorage.d.ts +5 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/localStorage.js +23 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/mergeArrayWithObject.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/mergeArrayWithObject.js +10 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.js +19 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/numberFormat.test.js +20 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.d.ts +13 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.js +27 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.test.js +45 -0
- package/build/plugins/highcharts/renderer/helpers/constants.d.ts +28 -0
- package/build/plugins/highcharts/renderer/helpers/constants.js +30 -0
- package/build/plugins/highcharts/renderer/helpers/graph.css +89 -0
- package/build/plugins/highcharts/renderer/helpers/graph.d.ts +552 -0
- package/build/plugins/highcharts/renderer/helpers/graph.js +85 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/colors.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/colors.js +17 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.d.ts +4 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/highcharts.js +346 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calcucalteClosestPointManually.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calcucalteClosestPointManually.js +19 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calculateClosestPointManually.test.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/utils/calculateClosestPointManually.test.js +42 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/utils/index.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/highcharts/utils/index.js +1 -0
- package/build/plugins/highcharts/renderer/helpers/init-highcharts-modules.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/init-highcharts-modules.js +49 -0
- package/build/plugins/highcharts/renderer/helpers/prepare-data.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/prepare-data.js +175 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/constants.d.ts +13 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/constants.js +14 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.d.ts +1 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/helpers.js +5 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/index.d.ts +13 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +253 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/index.d.ts +6 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/index.js +22 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DashDotLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DashDotLineIcon.js +20 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DashLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DashLineIcon.js +25 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DotLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/DotLineIcon.js +20 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashDotDotLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashDotDotLineIcon.js +18 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashDotLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashDotLineIcon.js +18 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/LongDashLineIcon.js +15 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashDotDotLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashDotDotLineIcon.js +18 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashDotLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashDotLineIcon.js +18 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDashLineIcon.js +18 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDotLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/ShortDotLineIcon.js +20 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/SolidLineIcon.d.ts +2 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/SolidLineIcon.js +13 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/index.d.ts +11 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/template-icons/index.js +11 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/types.d.ts +4 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/types.js +1 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/utils.d.ts +7 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/render-shape-icon/utils.js +5 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/tooltip.css +367 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/types.d.ts +85 -0
- package/build/plugins/highcharts/renderer/helpers/tooltip/types.js +1 -0
- package/build/plugins/highcharts/renderer/helpers/types.d.ts +22 -0
- package/build/plugins/highcharts/renderer/helpers/types.js +1 -0
- package/build/plugins/highcharts/types/comments.d.ts +51 -0
- package/build/plugins/highcharts/types/comments.js +1 -0
- package/build/plugins/highcharts/types/highcharts-extends.d.ts +38 -0
- package/build/plugins/highcharts/types/index.d.ts +4 -0
- package/build/plugins/highcharts/types/index.js +1 -0
- package/build/plugins/highcharts/types/lib.d.ts +1 -0
- package/build/plugins/highcharts/types/lib.js +1 -0
- package/build/plugins/highcharts/types/misc.d.ts +19 -0
- package/build/plugins/highcharts/types/misc.js +1 -0
- package/build/plugins/highcharts/types/widget.d.ts +47 -0
- package/build/plugins/highcharts/types/widget.js +1 -0
- package/build/plugins/index.d.ts +4 -2
- package/build/plugins/index.js +1 -0
- package/build/plugins/indicator/renderer/IndicatorItem.d.ts +3 -2
- package/build/plugins/indicator/renderer/IndicatorWidget.d.ts +10 -2
- package/build/plugins/indicator/renderer/IndicatorWidget.js +1 -1
- package/build/plugins/indicator/types.d.ts +0 -6
- package/build/plugins/shared/format-number/format-number.d.ts +4 -0
- package/build/plugins/shared/format-number/format-number.js +88 -0
- package/build/plugins/shared/format-number/format-number.test.d.ts +1 -0
- package/build/plugins/shared/format-number/format-number.test.js +14 -0
- package/build/plugins/shared/format-number/i18n/en.json +17 -0
- package/build/plugins/shared/format-number/i18n/i18n.d.ts +5 -0
- package/build/plugins/shared/format-number/i18n/i18n.js +8 -0
- package/build/plugins/shared/format-number/i18n/ru.json +17 -0
- package/build/plugins/shared/format-number/types.d.ts +14 -0
- package/build/plugins/shared/format-number/types.js +1 -0
- package/build/plugins/shared/index.d.ts +2 -0
- package/build/plugins/shared/index.js +1 -0
- package/build/plugins/yagr/renderer/YagrWidget.d.ts +11 -3
- package/build/plugins/yagr/renderer/YagrWidget.js +2 -1
- package/build/plugins/yagr/types.d.ts +0 -7
- package/build/types/index.d.ts +1 -2
- package/build/types/misc.d.ts +4 -0
- package/build/types/misc.js +1 -0
- package/build/types/widget.d.ts +17 -0
- package/package.json +4 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getFormatOptionsFromLine = (line) => {
|
|
2
|
+
if (!line) {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
const options = {
|
|
6
|
+
format: line.chartKitFormat,
|
|
7
|
+
postfix: line.chartKitPostfix,
|
|
8
|
+
precision: line.chartKitPrecision,
|
|
9
|
+
prefix: line.chartKitPrefix,
|
|
10
|
+
showRankDelimiter: line.chartKitShowRankDelimiter,
|
|
11
|
+
unit: line.chartKitUnit,
|
|
12
|
+
};
|
|
13
|
+
const hasValues = Object.values(options).some((value) => typeof value !== 'undefined');
|
|
14
|
+
return hasValues ? options : undefined;
|
|
15
|
+
};
|
package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/plugins/highcharts/renderer/helpers/config/utils/getFormatOptionsFromLine.test.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getFormatOptionsFromLine } from './getFormatOptionsFromLine';
|
|
2
|
+
describe('plugins/highcharts/config', () => {
|
|
3
|
+
test.each([
|
|
4
|
+
[{ chartKitFormat: 'percent' }, { format: 'percent' }],
|
|
5
|
+
[{}, undefined],
|
|
6
|
+
[undefined, undefined],
|
|
7
|
+
])('getFormatOptionsFromLine (line: %j)', (line, expected) => {
|
|
8
|
+
const result = getFormatOptionsFromLine(line);
|
|
9
|
+
expect(result).toEqual(expected);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getXAxisThresholdValue: (graphs: Record<string, any>[], operation: 'min' | 'max') => number | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const getXAxisThresholdValue = (graphs, operation) => {
|
|
2
|
+
const xAxisValues = graphs.reduce((acc, series) => {
|
|
3
|
+
const data = series.data || [];
|
|
4
|
+
return [...acc, ...data.map((point) => point.x)];
|
|
5
|
+
}, []);
|
|
6
|
+
const fn = operation === 'min' ? Math.min : Math.max;
|
|
7
|
+
const xAxisValue = fn(...xAxisValues);
|
|
8
|
+
return isFinite(xAxisValue) ? xAxisValue : null;
|
|
9
|
+
};
|
package/build/plugins/highcharts/renderer/helpers/config/utils/getXAxisThresholdValue.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getXAxisThresholdValue } from './getXAxisThresholdValue';
|
|
2
|
+
const MOCKED_SERIES = [
|
|
3
|
+
{ data: [{ x: 1 }, { x: 2 }, { x: -11 }, { x: 0 }, { x: 1 }] },
|
|
4
|
+
{ data: [{ x: 100 }, { x: -1232 }] },
|
|
5
|
+
{ data: [] },
|
|
6
|
+
];
|
|
7
|
+
describe('plugins/highcharts/config/getXAxisThresholdValue', () => {
|
|
8
|
+
it("should return maximun value from x axis in case of 'max' operation", () => {
|
|
9
|
+
const result = getXAxisThresholdValue(MOCKED_SERIES, 'max');
|
|
10
|
+
expect(result).toEqual(100);
|
|
11
|
+
});
|
|
12
|
+
it("should return minimum value from x axis in case of 'min' operation", () => {
|
|
13
|
+
const result = getXAxisThresholdValue(MOCKED_SERIES, 'min');
|
|
14
|
+
expect(result).toEqual(-1232);
|
|
15
|
+
});
|
|
16
|
+
it.each([['min'], ['max']])('should return null in case of empty series array', (operation) => {
|
|
17
|
+
const result = getXAxisThresholdValue([], operation);
|
|
18
|
+
expect(result).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { addShowInNavigatorToSeries } from './addShowInNavigatorToSeries';
|
|
2
|
+
export { buildNavigatorFallback } from './buildNavigatorFallback';
|
|
3
|
+
export { calculatePrecision } from './calculatePrecision';
|
|
4
|
+
export { concatStrings } from './concatStrings';
|
|
5
|
+
export { getChartKitFormattedValue } from './getChartKitFormattedValue';
|
|
6
|
+
export { getFormatOptionsFromLine } from './getFormatOptionsFromLine';
|
|
7
|
+
export { getXAxisThresholdValue } from './getXAxisThresholdValue';
|
|
8
|
+
export { isTooltipShared } from './isTooltipShared';
|
|
9
|
+
export { isNavigatorSeries } from './isNavigatorSeries';
|
|
10
|
+
export { isSafari } from './isSafari';
|
|
11
|
+
export { mergeArrayWithObject } from './mergeArrayWithObject';
|
|
12
|
+
export { numberFormat } from './numberFormat';
|
|
13
|
+
export { setNavigatorDefaultPeriod } from './setNavigatorDefaultPeriod';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { addShowInNavigatorToSeries } from './addShowInNavigatorToSeries';
|
|
2
|
+
export { buildNavigatorFallback } from './buildNavigatorFallback';
|
|
3
|
+
export { calculatePrecision } from './calculatePrecision';
|
|
4
|
+
export { concatStrings } from './concatStrings';
|
|
5
|
+
export { getChartKitFormattedValue } from './getChartKitFormattedValue';
|
|
6
|
+
export { getFormatOptionsFromLine } from './getFormatOptionsFromLine';
|
|
7
|
+
export { getXAxisThresholdValue } from './getXAxisThresholdValue';
|
|
8
|
+
export { isTooltipShared } from './isTooltipShared';
|
|
9
|
+
export { isNavigatorSeries } from './isNavigatorSeries';
|
|
10
|
+
export { isSafari } from './isSafari';
|
|
11
|
+
export { mergeArrayWithObject } from './mergeArrayWithObject';
|
|
12
|
+
export { numberFormat } from './numberFormat';
|
|
13
|
+
export { setNavigatorDefaultPeriod } from './setNavigatorDefaultPeriod';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isSafari: boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// https://stackoverflow.com/a/9851769/5806646
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
export const isSafari =
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
/constructor/i.test(window.HTMLElement) ||
|
|
6
|
+
(function (p) {
|
|
7
|
+
return p.toString() === '[object SafariRemoteNotification]';
|
|
8
|
+
})(
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
!window['safari'] ||
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
(typeof safari !== 'undefined' && safari.pushNotification));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isTooltipShared: (chartType: string) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// In case of using 'sankey' or 'xrange', the shared property must be set to false, otherwise the tooltip behaves incorrectly:
|
|
2
|
+
// Point.onMouseOver -> Highcharts.Pointer.runPointActions -> H.Tooltip.refresh -> Cannot read property 'series' of undefined
|
|
3
|
+
export const isTooltipShared = (chartType) => {
|
|
4
|
+
if (['sankey', 'xrange'].includes(chartType)) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return true;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HighchartsType } from '../../constants';
|
|
2
|
+
import { isTooltipShared } from './isTooltipShared';
|
|
3
|
+
const chartTypes = [
|
|
4
|
+
[HighchartsType.Sankey, false],
|
|
5
|
+
[HighchartsType.Xrange, false],
|
|
6
|
+
[HighchartsType.Line, true],
|
|
7
|
+
[HighchartsType.Area, true],
|
|
8
|
+
[HighchartsType.Arearange, true],
|
|
9
|
+
[HighchartsType.Bar, true],
|
|
10
|
+
[HighchartsType.Column, true],
|
|
11
|
+
[HighchartsType.Columnrange, true],
|
|
12
|
+
[HighchartsType.Funnel, true],
|
|
13
|
+
[HighchartsType.Pie, true],
|
|
14
|
+
[HighchartsType.Map, true],
|
|
15
|
+
[HighchartsType.Scatter, true],
|
|
16
|
+
[HighchartsType.Bubble, true],
|
|
17
|
+
[HighchartsType.Heatmap, true],
|
|
18
|
+
[HighchartsType.Treemap, true],
|
|
19
|
+
[HighchartsType.Networkgraph, true],
|
|
20
|
+
[HighchartsType.Variwide, true],
|
|
21
|
+
[HighchartsType.Waterfall, true],
|
|
22
|
+
[HighchartsType.Streamgraph, true],
|
|
23
|
+
[HighchartsType.Wordcloud, true],
|
|
24
|
+
[HighchartsType.Boxplot, true],
|
|
25
|
+
[HighchartsType.Timeline, true],
|
|
26
|
+
];
|
|
27
|
+
describe('plugins/highcharts/config/calculatePrecision', () => {
|
|
28
|
+
test.each(chartTypes)(`for %s return %s`, (chartType, assert) => {
|
|
29
|
+
expect(isTooltipShared(chartType)).toBe(assert);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class LocalStorage {
|
|
2
|
+
static restore(key) {
|
|
3
|
+
try {
|
|
4
|
+
const data = window.localStorage.getItem(key);
|
|
5
|
+
if (data === null) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
return JSON.parse(data);
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
static store(key, data) {
|
|
15
|
+
try {
|
|
16
|
+
window.localStorage.setItem(key, JSON.stringify(data));
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
console.error(`data not saved in localeStorage: ${err}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default LocalStorage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mergeArrayWithObject: (a: unknown[] | unknown, b: unknown[] | unknown) => any[] | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import merge from 'lodash/merge';
|
|
2
|
+
export const mergeArrayWithObject = (a, b) => {
|
|
3
|
+
if (Array.isArray(a) && b && typeof b === 'object' && !Array.isArray(b)) {
|
|
4
|
+
return a.map((value) => merge(value, b));
|
|
5
|
+
}
|
|
6
|
+
if (Array.isArray(b) && a && typeof a === 'object' && !Array.isArray(a)) {
|
|
7
|
+
return b.map((value) => merge({}, a, value));
|
|
8
|
+
}
|
|
9
|
+
return undefined;
|
|
10
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { formatNumber } from '../../../../../shared';
|
|
2
|
+
export const numberFormat = (val, round, options = {}) => {
|
|
3
|
+
if (parseInt(val, 10) === val) {
|
|
4
|
+
if (typeof round === 'number') {
|
|
5
|
+
return formatNumber(val, Object.assign({ precision: Math.min(round, 20) }, options));
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
return formatNumber(val, Object.assign({ precision: 0 }, options));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
else if (val) {
|
|
12
|
+
let resultRound = round;
|
|
13
|
+
if (typeof resultRound !== 'number') {
|
|
14
|
+
resultRound = val.toString().split('.')[1].length;
|
|
15
|
+
}
|
|
16
|
+
return formatNumber(val, Object.assign({ precision: Math.min(resultRound, 20) }, options));
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { i18nInstance } from '../../../../../shared/format-number/i18n/i18n';
|
|
2
|
+
import { numberFormat } from './numberFormat';
|
|
3
|
+
i18nInstance.setLang('en');
|
|
4
|
+
describe('plugins/highcharts/config', () => {
|
|
5
|
+
test.each([
|
|
6
|
+
[100, undefined, undefined, '100'],
|
|
7
|
+
[100, 0, undefined, '100'],
|
|
8
|
+
[100, 2, undefined, '100.00'],
|
|
9
|
+
[100, 21, undefined, '100.00000000000000000000'],
|
|
10
|
+
[NaN, 0, undefined, null],
|
|
11
|
+
[100, undefined, undefined, '100'],
|
|
12
|
+
[100, 2, { precision: 3 }, '100.000'],
|
|
13
|
+
[100.234, 2, { precision: 3 }, '100.234'],
|
|
14
|
+
[100000, undefined, { unit: 'k' }, '100K'],
|
|
15
|
+
[100000, 2, { unit: 'k' }, '100.00K'],
|
|
16
|
+
])('numberFormat (args: {value: %p, round: %p})', (value, round, options, expected) => {
|
|
17
|
+
const result = numberFormat(value, round, options);
|
|
18
|
+
expect(result).toEqual(expected);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Highcharts } from '../../../../types';
|
|
2
|
+
import type { NavigatorPeriod } from '../types';
|
|
3
|
+
declare type SetNavigatorDefaultPeriod = {
|
|
4
|
+
params: Record<string, any>;
|
|
5
|
+
periodSettings: NavigatorPeriod;
|
|
6
|
+
};
|
|
7
|
+
declare type NavigatorPeriodInMS = {
|
|
8
|
+
minRange: number;
|
|
9
|
+
range: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const setNavigatorDefaultPeriod: ({ params, periodSettings }: SetNavigatorDefaultPeriod) => void;
|
|
12
|
+
export declare const getDefaultPeriodInMS: (periodSettings: NavigatorPeriod, series: Highcharts.Series[]) => NavigatorPeriodInMS | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { getXAxisThresholdValue } from './getXAxisThresholdValue';
|
|
3
|
+
const HOUR_IN_MS = 1000 * 60 * 60;
|
|
4
|
+
const DAY_IN_MS = HOUR_IN_MS * 24;
|
|
5
|
+
export const setNavigatorDefaultPeriod = ({ params, periodSettings }) => {
|
|
6
|
+
const periodInMS = getDefaultPeriodInMS(periodSettings, params.series);
|
|
7
|
+
if (!periodInMS) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const { range, minRange } = periodInMS;
|
|
11
|
+
params.xAxis.range = range;
|
|
12
|
+
params.xAxis.minRange = minRange;
|
|
13
|
+
};
|
|
14
|
+
export const getDefaultPeriodInMS = (periodSettings, series) => {
|
|
15
|
+
const { type, value, period } = periodSettings;
|
|
16
|
+
const minRange = type === 'date' ? DAY_IN_MS : HOUR_IN_MS;
|
|
17
|
+
const maxXValue = getXAxisThresholdValue(series, 'max');
|
|
18
|
+
if (maxXValue === null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const minXValue = moment(maxXValue).subtract(value, period);
|
|
22
|
+
const range = maxXValue - minXValue.valueOf();
|
|
23
|
+
return {
|
|
24
|
+
minRange,
|
|
25
|
+
range,
|
|
26
|
+
};
|
|
27
|
+
};
|
package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/plugins/highcharts/renderer/helpers/config/utils/setNavigatorDefaultPeriod.test.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getDefaultPeriodInMS } from './setNavigatorDefaultPeriod';
|
|
2
|
+
const date1 = new Date('2021-01-01');
|
|
3
|
+
const date2 = new Date('2021-01-02');
|
|
4
|
+
const date3 = new Date('2021-01-03');
|
|
5
|
+
const MOCKED_SERIES = [
|
|
6
|
+
{
|
|
7
|
+
data: [{ x: date1.valueOf() }, { x: date3.valueOf() }],
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
data: [{ x: date2.valueOf() }],
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
const DAY_MIN_RANGE = 60 * 60 * 1000 * 24;
|
|
14
|
+
const HOUR_MIN_RANGE = 60 * 60 * 1000;
|
|
15
|
+
describe('plugins/highcharts/config/getDefaultPeriodInMS', () => {
|
|
16
|
+
let settings;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
settings = {
|
|
19
|
+
type: 'date',
|
|
20
|
+
value: '2',
|
|
21
|
+
period: 'day',
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
it('should return range & minRange for date in ms', () => {
|
|
25
|
+
const result = getDefaultPeriodInMS(settings, MOCKED_SERIES);
|
|
26
|
+
const expectedResult = {
|
|
27
|
+
minRange: DAY_MIN_RANGE,
|
|
28
|
+
range: date3.valueOf() - date1.valueOf(),
|
|
29
|
+
};
|
|
30
|
+
expect(result).toEqual(expectedResult);
|
|
31
|
+
});
|
|
32
|
+
it(`should set {minRange: ${HOUR_MIN_RANGE}} in case of settings.type !== 'date'`, () => {
|
|
33
|
+
settings.type = 'datetime';
|
|
34
|
+
const result = getDefaultPeriodInMS(settings, MOCKED_SERIES);
|
|
35
|
+
const expectedResult = {
|
|
36
|
+
minRange: HOUR_MIN_RANGE,
|
|
37
|
+
range: date3.valueOf() - date1.valueOf(),
|
|
38
|
+
};
|
|
39
|
+
expect(result).toEqual(expectedResult);
|
|
40
|
+
});
|
|
41
|
+
it('should return null in case of empty series', () => {
|
|
42
|
+
const result = getDefaultPeriodInMS(settings, []);
|
|
43
|
+
expect(result).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum HighchartsType {
|
|
2
|
+
Area = "area",
|
|
3
|
+
Arearange = "arearange",
|
|
4
|
+
Bar = "bar",
|
|
5
|
+
Boxplot = "boxplot",
|
|
6
|
+
Bubble = "bubble",
|
|
7
|
+
Column = "column",
|
|
8
|
+
Columnrange = "columnrange",
|
|
9
|
+
Funnel = "funnel",
|
|
10
|
+
Heatmap = "heatmap",
|
|
11
|
+
Line = "line",
|
|
12
|
+
Map = "map",
|
|
13
|
+
Networkgraph = "networkgraph",
|
|
14
|
+
Pie = "pie",
|
|
15
|
+
Sankey = "sankey",
|
|
16
|
+
Scatter = "scatter",
|
|
17
|
+
Streamgraph = "streamgraph",
|
|
18
|
+
Timeline = "timeline",
|
|
19
|
+
Treemap = "treemap",
|
|
20
|
+
Variwide = "variwide",
|
|
21
|
+
Waterfall = "waterfall",
|
|
22
|
+
Wordcloud = "wordcloud",
|
|
23
|
+
Xrange = "xrange"
|
|
24
|
+
}
|
|
25
|
+
export declare enum NavigatorLinesMode {
|
|
26
|
+
All = "all",
|
|
27
|
+
Selected = "selected"
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export var HighchartsType;
|
|
2
|
+
(function (HighchartsType) {
|
|
3
|
+
HighchartsType["Area"] = "area";
|
|
4
|
+
HighchartsType["Arearange"] = "arearange";
|
|
5
|
+
HighchartsType["Bar"] = "bar";
|
|
6
|
+
HighchartsType["Boxplot"] = "boxplot";
|
|
7
|
+
HighchartsType["Bubble"] = "bubble";
|
|
8
|
+
HighchartsType["Column"] = "column";
|
|
9
|
+
HighchartsType["Columnrange"] = "columnrange";
|
|
10
|
+
HighchartsType["Funnel"] = "funnel";
|
|
11
|
+
HighchartsType["Heatmap"] = "heatmap";
|
|
12
|
+
HighchartsType["Line"] = "line";
|
|
13
|
+
HighchartsType["Map"] = "map";
|
|
14
|
+
HighchartsType["Networkgraph"] = "networkgraph";
|
|
15
|
+
HighchartsType["Pie"] = "pie";
|
|
16
|
+
HighchartsType["Sankey"] = "sankey";
|
|
17
|
+
HighchartsType["Scatter"] = "scatter";
|
|
18
|
+
HighchartsType["Streamgraph"] = "streamgraph";
|
|
19
|
+
HighchartsType["Timeline"] = "timeline";
|
|
20
|
+
HighchartsType["Treemap"] = "treemap";
|
|
21
|
+
HighchartsType["Variwide"] = "variwide";
|
|
22
|
+
HighchartsType["Waterfall"] = "waterfall";
|
|
23
|
+
HighchartsType["Wordcloud"] = "wordcloud";
|
|
24
|
+
HighchartsType["Xrange"] = "xrange";
|
|
25
|
+
})(HighchartsType || (HighchartsType = {}));
|
|
26
|
+
export var NavigatorLinesMode;
|
|
27
|
+
(function (NavigatorLinesMode) {
|
|
28
|
+
NavigatorLinesMode["All"] = "all";
|
|
29
|
+
NavigatorLinesMode["Selected"] = "selected";
|
|
30
|
+
})(NavigatorLinesMode || (NavigatorLinesMode = {}));
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.chartkit-graph .highcharts-plot-line-label,
|
|
2
|
+
.chartkit-graph .highcharts-plot-band-label {
|
|
3
|
+
fill: var(--highcharts-plot-line-label);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.chartkit-graph .highcharts-plot-band_comment {
|
|
7
|
+
opacity: 0.5;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.chartkit-tooltip {
|
|
11
|
+
border: 1px solid var(--highcharts-grid-line);
|
|
12
|
+
border-radius: 3px;
|
|
13
|
+
background: var(--highcharts-tooltip-bg);
|
|
14
|
+
padding: 10px 14px;
|
|
15
|
+
color: var(--highcharts-tooltip-text);
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.chartkit-tooltip_split-tooltip {
|
|
22
|
+
border: none;
|
|
23
|
+
border-radius: 0;
|
|
24
|
+
box-shadow: none;
|
|
25
|
+
border-bottom: 1px solid var(--yc-color-line-generic);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.chartkit-tooltip_yandex-map {
|
|
29
|
+
position: absolute;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.chartkit-tooltip__header {
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
font-size: 13px;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.chartkit-tooltip__header + .chartkit-tooltip__row .chartkit-tooltip__cell {
|
|
39
|
+
padding-top: 10px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.chartkit-tooltip__footer {
|
|
43
|
+
color: #aaaaaa;
|
|
44
|
+
font-size: 10px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.chartkit-tooltip__footer:not(:only-child) {
|
|
48
|
+
margin-top: 8px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.chartkit-tooltip__row {
|
|
52
|
+
display: table-row;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.chartkit-tooltip__cell {
|
|
56
|
+
display: table-cell;
|
|
57
|
+
padding: 2px 7px 2px 0;
|
|
58
|
+
max-width: 370px;
|
|
59
|
+
text-overflow: ellipsis;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.chartkit-tooltip__cell_yandex-map {
|
|
64
|
+
white-space: nowrap;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.chartkit-tooltip__color {
|
|
68
|
+
position: relative;
|
|
69
|
+
top: -1px;
|
|
70
|
+
width: 12px;
|
|
71
|
+
height: 6px;
|
|
72
|
+
margin-right: 3px;
|
|
73
|
+
border-radius: 1px;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.chartkit-tooltip__series-name {
|
|
78
|
+
padding-right: 45px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.chartkit-tooltip h3 {
|
|
82
|
+
margin: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.chartkit-tooltip__point-container_type_timeline {
|
|
86
|
+
max-width: 350px;
|
|
87
|
+
white-space: normal;
|
|
88
|
+
padding-top: 5px;
|
|
89
|
+
}
|