@perses-dev/components 0.30.0 → 0.31.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/dist/Legend/CompactLegend.d.ts +6 -4
- package/dist/Legend/CompactLegend.d.ts.map +1 -1
- package/dist/Legend/CompactLegend.js +4 -1
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.d.ts +11 -9
- package/dist/Legend/Legend.d.ts.map +1 -1
- package/dist/Legend/Legend.js +45 -11
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/ListLegend.d.ts +5 -8
- package/dist/Legend/ListLegend.d.ts.map +1 -1
- package/dist/Legend/ListLegend.js +34 -99
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.d.ts +8 -8
- package/dist/Legend/ListLegendItem.d.ts.map +1 -1
- package/dist/Legend/ListLegendItem.js +9 -12
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/LineChart/LineChart.d.ts +2 -1
- package/dist/LineChart/LineChart.d.ts.map +1 -1
- package/dist/LineChart/LineChart.js +31 -22
- package/dist/LineChart/LineChart.js.map +1 -1
- package/dist/Table/InnerTable.d.ts +9 -0
- package/dist/Table/InnerTable.d.ts.map +1 -0
- package/dist/Table/InnerTable.js +38 -0
- package/dist/Table/InnerTable.js.map +1 -0
- package/dist/Table/Table.d.ts +10 -0
- package/dist/Table/Table.d.ts.map +1 -0
- package/dist/Table/Table.js +101 -0
- package/dist/Table/Table.js.map +1 -0
- package/dist/Table/TableBody.d.ts +6 -0
- package/dist/Table/TableBody.d.ts.map +1 -0
- package/dist/Table/TableBody.js +23 -0
- package/dist/Table/TableBody.js.map +1 -0
- package/dist/Table/TableCell.d.ts +18 -0
- package/dist/Table/TableCell.d.ts.map +1 -0
- package/dist/Table/TableCell.js +91 -0
- package/dist/Table/TableCell.js.map +1 -0
- package/dist/Table/TableCheckbox.d.ts +9 -0
- package/dist/Table/TableCheckbox.d.ts.map +1 -0
- package/dist/Table/TableCheckbox.js +49 -0
- package/dist/Table/TableCheckbox.js.map +1 -0
- package/dist/Table/TableHead.d.ts +6 -0
- package/dist/Table/TableHead.d.ts.map +1 -0
- package/dist/Table/TableHead.js +23 -0
- package/dist/Table/TableHead.js.map +1 -0
- package/dist/Table/TableRow.d.ts +9 -0
- package/dist/Table/TableRow.d.ts.map +1 -0
- package/dist/Table/TableRow.js +29 -0
- package/dist/Table/TableRow.js.map +1 -0
- package/dist/Table/VirtualizedTable.d.ts +11 -0
- package/dist/Table/VirtualizedTable.d.ts.map +1 -0
- package/dist/Table/VirtualizedTable.js +152 -0
- package/dist/Table/VirtualizedTable.js.map +1 -0
- package/dist/Table/VirtualizedTableContainer.d.ts +6 -0
- package/dist/Table/VirtualizedTableContainer.d.ts.map +1 -0
- package/dist/Table/VirtualizedTableContainer.js +24 -0
- package/dist/Table/VirtualizedTableContainer.js.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts +32 -0
- package/dist/Table/hooks/useTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useTableKeyboardNav.js +98 -0
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +29 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +89 -0
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -0
- package/dist/Table/index.d.ts +4 -0
- package/dist/Table/index.d.ts.map +1 -0
- package/dist/Table/index.js +16 -0
- package/dist/Table/index.js.map +1 -0
- package/dist/Table/model/table-model.d.ts +83 -0
- package/dist/Table/model/table-model.d.ts.map +1 -0
- package/dist/Table/model/table-model.js +73 -0
- package/dist/Table/model/table-model.js.map +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts +1 -0
- package/dist/TimeSeriesTooltip/SeriesInfo.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +11 -9
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts +2 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js +60 -15
- package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts +5 -3
- package/dist/TimeSeriesTooltip/TooltipContent.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +79 -42
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts +1 -1
- package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/index.js +1 -1
- package/dist/TimeSeriesTooltip/index.js.map +1 -1
- package/dist/TimeSeriesTooltip/nearby-series.d.ts +46 -0
- package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -0
- package/dist/TimeSeriesTooltip/nearby-series.js +200 -0
- package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -0
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts +8 -4
- package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +6 -2
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
- package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
- package/dist/TimeSeriesTooltip/utils.js +4 -3
- package/dist/TimeSeriesTooltip/utils.js.map +1 -1
- package/dist/cjs/Legend/CompactLegend.js +4 -1
- package/dist/cjs/Legend/Legend.js +45 -11
- package/dist/cjs/Legend/ListLegend.js +33 -98
- package/dist/cjs/Legend/ListLegendItem.js +8 -11
- package/dist/cjs/LineChart/LineChart.js +31 -22
- package/dist/cjs/Table/InnerTable.js +44 -0
- package/dist/cjs/Table/Table.js +102 -0
- package/dist/cjs/Table/TableBody.js +29 -0
- package/dist/cjs/Table/TableCell.js +97 -0
- package/dist/cjs/Table/TableCheckbox.js +55 -0
- package/dist/cjs/Table/TableHead.js +29 -0
- package/dist/cjs/Table/TableRow.js +35 -0
- package/dist/cjs/Table/VirtualizedTable.js +155 -0
- package/dist/cjs/Table/VirtualizedTableContainer.js +30 -0
- package/dist/cjs/Table/hooks/useTableKeyboardNav.js +99 -0
- package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +93 -0
- package/dist/cjs/Table/index.js +33 -0
- package/dist/cjs/Table/model/table-model.js +80 -0
- package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +10 -8
- package/dist/cjs/TimeSeriesTooltip/TimeSeriesTooltip.js +57 -12
- package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +83 -41
- package/dist/cjs/TimeSeriesTooltip/index.js +1 -1
- package/dist/cjs/TimeSeriesTooltip/nearby-series.js +206 -0
- package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +11 -3
- package/dist/cjs/TimeSeriesTooltip/utils.js +3 -2
- package/dist/cjs/context/SnackbarProvider.js +66 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/model/legend.js +7 -1
- package/dist/cjs/theme/palette/grey.js +6 -2
- package/dist/context/SnackbarProvider.d.ts +23 -0
- package/dist/context/SnackbarProvider.d.ts.map +1 -0
- package/dist/context/SnackbarProvider.js +59 -0
- package/dist/context/SnackbarProvider.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/legend.d.ts +10 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +5 -0
- package/dist/model/legend.js.map +1 -1
- package/dist/theme/palette/grey.d.ts.map +1 -1
- package/dist/theme/palette/grey.js +6 -2
- package/dist/theme/palette/grey.js.map +1 -1
- package/package.json +6 -6
- package/dist/TimeSeriesTooltip/focused-series.d.ts +0 -25
- package/dist/TimeSeriesTooltip/focused-series.d.ts.map +0 -1
- package/dist/TimeSeriesTooltip/focused-series.js +0 -110
- package/dist/TimeSeriesTooltip/focused-series.js.map +0 -1
- package/dist/cjs/TimeSeriesTooltip/focused-series.js +0 -116
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { grey } from './colors/grey';
|
|
14
14
|
export const greyOption = (mode)=>{
|
|
15
15
|
return mode === 'light' ? {
|
|
16
|
+
50: grey[50],
|
|
16
17
|
100: grey[100],
|
|
17
18
|
200: grey[200],
|
|
18
19
|
300: grey[300],
|
|
@@ -21,8 +22,10 @@ export const greyOption = (mode)=>{
|
|
|
21
22
|
600: grey[600],
|
|
22
23
|
700: grey[700],
|
|
23
24
|
800: grey[800],
|
|
24
|
-
900: grey[900]
|
|
25
|
+
900: grey[900],
|
|
26
|
+
950: grey[950]
|
|
25
27
|
} : {
|
|
28
|
+
50: grey[950],
|
|
26
29
|
100: grey[900],
|
|
27
30
|
200: grey[800],
|
|
28
31
|
300: grey[700],
|
|
@@ -31,7 +34,8 @@ export const greyOption = (mode)=>{
|
|
|
31
34
|
600: grey[400],
|
|
32
35
|
700: grey[300],
|
|
33
36
|
800: grey[200],
|
|
34
|
-
900: grey[100]
|
|
37
|
+
900: grey[100],
|
|
38
|
+
950: grey[50]
|
|
35
39
|
};
|
|
36
40
|
};
|
|
37
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/theme/palette/grey.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PaletteOptions, PaletteMode } from '@mui/material';\nimport { grey } from './colors/grey';\n\nexport const greyOption = (mode: PaletteMode): PaletteOptions['grey'] => {\n return mode === 'light'\n ? {\n 100: grey[100],\n 200: grey[200],\n 300: grey[300],\n 400: grey[400],\n 500: grey[500],\n 600: grey[600],\n 700: grey[700],\n 800: grey[800],\n 900: grey[900],\n }\n : // Reverse greys from darkest to lightest for Dark mode\n {\n 100: grey[900],\n 200: grey[800],\n 300: grey[700],\n 400: grey[600],\n 500: grey[500],\n 600: grey[400],\n 700: grey[300],\n 800: grey[200],\n 900: grey[100],\n };\n};\n"],"names":["grey","greyOption","mode"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,IAAI,QAAQ,eAAe,CAAC;AAErC,OAAO,MAAMC,UAAU,GAAG,CAACC,IAAiB,GAA6B;IACvE,OAAOA,IAAI,KAAK,OAAO,GACnB;AACE,QAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/theme/palette/grey.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PaletteOptions, PaletteMode } from '@mui/material';\nimport { grey } from './colors/grey';\n\nexport const greyOption = (mode: PaletteMode): PaletteOptions['grey'] => {\n return mode === 'light'\n ? {\n 50: grey[50],\n 100: grey[100],\n 200: grey[200],\n 300: grey[300],\n 400: grey[400],\n 500: grey[500],\n 600: grey[600],\n 700: grey[700],\n 800: grey[800],\n 900: grey[900],\n 950: grey[950],\n }\n : // Reverse greys from darkest to lightest for Dark mode\n {\n 50: grey[950],\n 100: grey[900],\n 200: grey[800],\n 300: grey[700],\n 400: grey[600],\n 500: grey[500],\n 600: grey[400],\n 700: grey[300],\n 800: grey[200],\n 900: grey[100],\n 950: grey[50],\n };\n};\n"],"names":["grey","greyOption","mode"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,IAAI,QAAQ,eAAe,CAAC;AAErC,OAAO,MAAMC,UAAU,GAAG,CAACC,IAAiB,GAA6B;IACvE,OAAOA,IAAI,KAAK,OAAO,GACnB;AACE,QAAA,EAAE,EAAEF,IAAI,CAAC,EAAE,CAAC;AACZ,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;KACf,GAED;AACE,QAAA,EAAE,EAAEA,IAAI,CAAC,GAAG,CAAC;AACb,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,GAAG,CAAC;AACd,QAAA,GAAG,EAAEA,IAAI,CAAC,EAAE,CAAC;KACd,CAAC;AACR,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Common UI components used across Perses features",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"@codemirror/lang-json": "^6.0.1",
|
|
37
37
|
"@fontsource/lato": "^4.5.10",
|
|
38
38
|
"@mui/x-date-pickers": "^5.0.0-beta.1",
|
|
39
|
-
"@perses-dev/core": "0.
|
|
39
|
+
"@perses-dev/core": "0.31.0",
|
|
40
|
+
"@tanstack/react-table": "^8.9.1",
|
|
40
41
|
"@uiw/react-codemirror": "^4.19.1",
|
|
41
42
|
"date-fns": "^2.28.0",
|
|
42
43
|
"date-fns-tz": "^1.3.7",
|
|
43
|
-
"echarts": "
|
|
44
|
+
"echarts": "npm:echarts-nightly@5.5.0-dev.20230517",
|
|
44
45
|
"lodash-es": "^4.17.21",
|
|
45
46
|
"mathjs": "^10.6.4",
|
|
46
47
|
"mdi-material-ui": "^7.4.0",
|
|
47
48
|
"numbro": "^2.3.6",
|
|
48
49
|
"react-colorful": "^5.6.1",
|
|
49
50
|
"react-error-boundary": "^3.1.4",
|
|
50
|
-
"react-
|
|
51
|
+
"react-virtuoso": "^4.3.6"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@perses-dev/storybook": "0.
|
|
54
|
-
"@types/react-window": "^1.8.5"
|
|
54
|
+
"@perses-dev/storybook": "0.31.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@mui/material": "^5.10.0",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ECharts as EChartsInstance } from 'echarts/core';
|
|
2
|
-
import { UnitOptions, EChartsDataFormat } from '../model';
|
|
3
|
-
import { CursorData } from './tooltip-model';
|
|
4
|
-
export interface FocusedSeriesInfo {
|
|
5
|
-
seriesIdx: number | null;
|
|
6
|
-
datumIdx: number | null;
|
|
7
|
-
seriesName: string;
|
|
8
|
-
date: number;
|
|
9
|
-
markerColor: string;
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
formattedY: string;
|
|
13
|
-
}
|
|
14
|
-
export declare type FocusedSeriesArray = FocusedSeriesInfo[];
|
|
15
|
-
/**
|
|
16
|
-
* Returns formatted series data for the points that are close to the user's cursor
|
|
17
|
-
* Adjust yBuffer to increase or decrease number of series shown
|
|
18
|
-
*/
|
|
19
|
-
export declare function getNearbySeries(data: EChartsDataFormat, pointInGrid: number[], yBuffer: number, unit?: UnitOptions): FocusedSeriesArray;
|
|
20
|
-
/**
|
|
21
|
-
* Uses mouse position to determine whether user is hovering over a chart canvas
|
|
22
|
-
* If yes, convert from pixel values to logical cartesian coordinates and return all focused series
|
|
23
|
-
*/
|
|
24
|
-
export declare function getFocusedSeriesData(mousePos: CursorData['coords'], chartData: EChartsDataFormat, pinnedPos: CursorData['coords'], chart?: EChartsInstance, unit?: UnitOptions): FocusedSeriesArray;
|
|
25
|
-
//# sourceMappingURL=focused-series.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"focused-series.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/focused-series.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAe,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,UAAU,EAAqB,MAAM,iBAAiB,CAAC;AAEhE,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,oBAAY,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;AAErD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,WAAW,GACjB,kBAAkB,CA4CpB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC9B,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC/B,KAAK,CAAC,EAAE,eAAe,EACvB,IAAI,CAAC,EAAE,WAAW,sBA2CnB"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { formatValue } from '../model';
|
|
14
|
-
import { TOOLTIP_MAX_ITEMS } from './tooltip-model';
|
|
15
|
-
/**
|
|
16
|
-
* Returns formatted series data for the points that are close to the user's cursor
|
|
17
|
-
* Adjust yBuffer to increase or decrease number of series shown
|
|
18
|
-
*/ export function getNearbySeries(data, pointInGrid, yBuffer, unit) {
|
|
19
|
-
const currentFocusedData = [];
|
|
20
|
-
var ref;
|
|
21
|
-
const focusedX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
|
|
22
|
-
var ref1;
|
|
23
|
-
const focusedY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
24
|
-
if (focusedX === null || focusedY === null) {
|
|
25
|
-
return currentFocusedData;
|
|
26
|
-
}
|
|
27
|
-
if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
|
|
28
|
-
for(let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++){
|
|
29
|
-
const currentSeries = data.timeSeries[seriesIdx];
|
|
30
|
-
if (currentFocusedData.length >= TOOLTIP_MAX_ITEMS) break;
|
|
31
|
-
if (currentSeries !== undefined) {
|
|
32
|
-
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
33
|
-
var _color;
|
|
34
|
-
const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
|
|
35
|
-
if (Array.isArray(currentSeries.data)) {
|
|
36
|
-
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
37
|
-
var _datumIdx;
|
|
38
|
-
const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
|
|
39
|
-
const yValue = currentSeries.data[datumIdx];
|
|
40
|
-
// ensure null values not displayed in tooltip
|
|
41
|
-
if (yValue !== undefined && yValue !== null && focusedX === datumIdx) {
|
|
42
|
-
if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {
|
|
43
|
-
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
44
|
-
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
45
|
-
const formattedY = formatValue(yValue, unit);
|
|
46
|
-
currentFocusedData.push({
|
|
47
|
-
seriesIdx: seriesIdx,
|
|
48
|
-
datumIdx: datumIdx,
|
|
49
|
-
seriesName: currentSeriesName,
|
|
50
|
-
date: xValueMilliSeconds,
|
|
51
|
-
x: xValue,
|
|
52
|
-
y: yValue,
|
|
53
|
-
formattedY: formattedY,
|
|
54
|
-
markerColor: markerColor.toString()
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return currentFocusedData;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Uses mouse position to determine whether user is hovering over a chart canvas
|
|
67
|
-
* If yes, convert from pixel values to logical cartesian coordinates and return all focused series
|
|
68
|
-
*/ export function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit) {
|
|
69
|
-
if (chart === undefined || mousePos === null) return [];
|
|
70
|
-
// prevents multiple tooltips showing from adjacent charts
|
|
71
|
-
let cursorTargetMatchesChart = false;
|
|
72
|
-
if (mousePos.target !== null) {
|
|
73
|
-
const currentParent = mousePos.target.parentElement;
|
|
74
|
-
if (currentParent !== null) {
|
|
75
|
-
const currentGrandparent = currentParent.parentElement;
|
|
76
|
-
if (currentGrandparent !== null) {
|
|
77
|
-
const chartDom = chart.getDom();
|
|
78
|
-
if (chartDom === currentGrandparent) {
|
|
79
|
-
cursorTargetMatchesChart = true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// allows moving cursor inside tooltip
|
|
85
|
-
if (pinnedPos !== null) {
|
|
86
|
-
mousePos = pinnedPos;
|
|
87
|
-
cursorTargetMatchesChart = true;
|
|
88
|
-
}
|
|
89
|
-
if (cursorTargetMatchesChart === false) return [];
|
|
90
|
-
if (chart['_model'] === undefined) return [];
|
|
91
|
-
const chartModel = chart['_model'];
|
|
92
|
-
const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
93
|
-
// tooltip trigger area gets smaller with more series, increase yAxisInterval multiplier to expand nearby series range
|
|
94
|
-
const seriesNum = chartData.timeSeries.length;
|
|
95
|
-
const yBuffer = seriesNum > TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 5;
|
|
96
|
-
var _x, _y;
|
|
97
|
-
const pointInPixel = [
|
|
98
|
-
(_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
|
|
99
|
-
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
100
|
-
];
|
|
101
|
-
if (chart.containPixel('grid', pointInPixel)) {
|
|
102
|
-
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
103
|
-
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
104
|
-
return getNearbySeries(chartData, pointInGrid, yBuffer, unit);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
//# sourceMappingURL=focused-series.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesTooltip/focused-series.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { formatValue, UnitOptions, EChartsDataFormat } from '../model';\nimport { CursorData, TOOLTIP_MAX_ITEMS } from './tooltip-model';\n\nexport interface FocusedSeriesInfo {\n seriesIdx: number | null;\n datumIdx: number | null;\n seriesName: string;\n date: number;\n markerColor: string;\n x: number;\n y: number;\n formattedY: string;\n}\n\nexport type FocusedSeriesArray = FocusedSeriesInfo[];\n\n/**\n * Returns formatted series data for the points that are close to the user's cursor\n * Adjust yBuffer to increase or decrease number of series shown\n */\nexport function getNearbySeries(\n data: EChartsDataFormat,\n pointInGrid: number[],\n yBuffer: number,\n unit?: UnitOptions\n): FocusedSeriesArray {\n const currentFocusedData: FocusedSeriesArray = [];\n const focusedX: number | null = pointInGrid[0] ?? null;\n const focusedY: number | null = pointInGrid[1] ?? null;\n\n if (focusedX === null || focusedY === null) {\n return currentFocusedData;\n }\n\n if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {\n for (let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++) {\n const currentSeries = data.timeSeries[seriesIdx];\n if (currentFocusedData.length >= TOOLTIP_MAX_ITEMS) break;\n if (currentSeries !== undefined) {\n const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';\n const markerColor = currentSeries.color ?? '#000';\n if (Array.isArray(currentSeries.data)) {\n for (let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++) {\n const xValue = data.xAxis[datumIdx] ?? 0;\n const yValue = currentSeries.data[datumIdx];\n // ensure null values not displayed in tooltip\n if (yValue !== undefined && yValue !== null && focusedX === datumIdx) {\n if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {\n // determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201\n const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;\n const formattedY = formatValue(yValue, unit);\n currentFocusedData.push({\n seriesIdx: seriesIdx,\n datumIdx: datumIdx,\n seriesName: currentSeriesName,\n date: xValueMilliSeconds,\n x: xValue,\n y: yValue,\n formattedY: formattedY,\n markerColor: markerColor.toString(),\n });\n }\n }\n }\n }\n }\n }\n }\n return currentFocusedData;\n}\n\n/**\n * Uses mouse position to determine whether user is hovering over a chart canvas\n * If yes, convert from pixel values to logical cartesian coordinates and return all focused series\n */\nexport function getFocusedSeriesData(\n mousePos: CursorData['coords'],\n chartData: EChartsDataFormat,\n pinnedPos: CursorData['coords'],\n chart?: EChartsInstance,\n unit?: UnitOptions\n) {\n if (chart === undefined || mousePos === null) return [];\n\n // prevents multiple tooltips showing from adjacent charts\n let cursorTargetMatchesChart = false;\n if (mousePos.target !== null) {\n const currentParent = (<HTMLElement>mousePos.target).parentElement;\n if (currentParent !== null) {\n const currentGrandparent = currentParent.parentElement;\n if (currentGrandparent !== null) {\n const chartDom = chart.getDom();\n if (chartDom === currentGrandparent) {\n cursorTargetMatchesChart = true;\n }\n }\n }\n }\n\n // allows moving cursor inside tooltip\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n cursorTargetMatchesChart = true;\n }\n\n if (cursorTargetMatchesChart === false) return [];\n\n if (chart['_model'] === undefined) return [];\n const chartModel = chart['_model'];\n const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;\n\n // tooltip trigger area gets smaller with more series, increase yAxisInterval multiplier to expand nearby series range\n const seriesNum = chartData.timeSeries.length;\n const yBuffer = seriesNum > TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 5;\n\n const pointInPixel = [mousePos.plotCanvas.x ?? 0, mousePos.plotCanvas.y ?? 0];\n if (chart.containPixel('grid', pointInPixel)) {\n const pointInGrid = chart.convertFromPixel('grid', pointInPixel);\n if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {\n return getNearbySeries(chartData, pointInGrid, yBuffer, unit);\n }\n }\n return [];\n}\n"],"names":["formatValue","TOOLTIP_MAX_ITEMS","getNearbySeries","data","pointInGrid","yBuffer","unit","currentFocusedData","focusedX","focusedY","Array","isArray","xAxis","timeSeries","seriesIdx","length","currentSeries","undefined","currentSeriesName","name","toString","markerColor","color","datumIdx","xValue","yValue","xValueMilliSeconds","formattedY","push","seriesName","date","x","y","getFocusedSeriesData","mousePos","chartData","pinnedPos","chart","cursorTargetMatchesChart","target","currentParent","parentElement","currentGrandparent","chartDom","getDom","chartModel","yAxisInterval","getComponent","axis","scale","_interval","seriesNum","pointInPixel","plotCanvas","containPixel","convertFromPixel"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,WAAW,QAAwC,UAAU,CAAC;AACvE,SAAqBC,iBAAiB,QAAQ,iBAAiB,CAAC;AAehE;;;CAGC,GACD,OAAO,SAASC,eAAe,CAC7BC,IAAuB,EACvBC,WAAqB,EACrBC,OAAe,EACfC,IAAkB,EACE;IACpB,MAAMC,kBAAkB,GAAuB,EAAE,AAAC;QAClBH,GAAc;IAA9C,MAAMI,QAAQ,GAAkBJ,CAAAA,GAAc,GAAdA,WAAW,CAAC,CAAC,CAAC,cAAdA,GAAc,cAAdA,GAAc,GAAI,IAAI,AAAC;QACvBA,IAAc;IAA9C,MAAMK,QAAQ,GAAkBL,CAAAA,IAAc,GAAdA,WAAW,CAAC,CAAC,CAAC,cAAdA,IAAc,cAAdA,IAAc,GAAI,IAAI,AAAC;IAEvD,IAAII,QAAQ,KAAK,IAAI,IAAIC,QAAQ,KAAK,IAAI,EAAE;QAC1C,OAAOF,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAA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,CAAC,KAAKa,SAAS,IAAIb,WAAW,CAAC,CAAC,CAAC,KAAKa,SAAS,EAAE;YAChE,OAAOf,eAAe,CAACiC,SAAS,EAAE/B,WAAW,EAAEC,OAAO,EAAEC,IAAI,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
getNearbySeries: ()=>getNearbySeries,
|
|
25
|
-
getFocusedSeriesData: ()=>getFocusedSeriesData
|
|
26
|
-
});
|
|
27
|
-
const _model = require("../model");
|
|
28
|
-
const _tooltipModel = require("./tooltip-model");
|
|
29
|
-
function getNearbySeries(data, pointInGrid, yBuffer, unit) {
|
|
30
|
-
const currentFocusedData = [];
|
|
31
|
-
var ref;
|
|
32
|
-
const focusedX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
|
|
33
|
-
var ref1;
|
|
34
|
-
const focusedY = (ref1 = pointInGrid[1]) !== null && ref1 !== void 0 ? ref1 : null;
|
|
35
|
-
if (focusedX === null || focusedY === null) {
|
|
36
|
-
return currentFocusedData;
|
|
37
|
-
}
|
|
38
|
-
if (Array.isArray(data.xAxis) && Array.isArray(data.timeSeries)) {
|
|
39
|
-
for(let seriesIdx = 0; seriesIdx < data.timeSeries.length; seriesIdx++){
|
|
40
|
-
const currentSeries = data.timeSeries[seriesIdx];
|
|
41
|
-
if (currentFocusedData.length >= _tooltipModel.TOOLTIP_MAX_ITEMS) break;
|
|
42
|
-
if (currentSeries !== undefined) {
|
|
43
|
-
const currentSeriesName = currentSeries.name ? currentSeries.name.toString() : '';
|
|
44
|
-
var _color;
|
|
45
|
-
const markerColor = (_color = currentSeries.color) !== null && _color !== void 0 ? _color : '#000';
|
|
46
|
-
if (Array.isArray(currentSeries.data)) {
|
|
47
|
-
for(let datumIdx = 0; datumIdx < currentSeries.data.length; datumIdx++){
|
|
48
|
-
var _datumIdx;
|
|
49
|
-
const xValue = (_datumIdx = data.xAxis[datumIdx]) !== null && _datumIdx !== void 0 ? _datumIdx : 0;
|
|
50
|
-
const yValue = currentSeries.data[datumIdx];
|
|
51
|
-
// ensure null values not displayed in tooltip
|
|
52
|
-
if (yValue !== undefined && yValue !== null && focusedX === datumIdx) {
|
|
53
|
-
if (yValue !== '-' && focusedY <= yValue + yBuffer && focusedY >= yValue - yBuffer) {
|
|
54
|
-
// determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
|
|
55
|
-
const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
|
|
56
|
-
const formattedY = (0, _model.formatValue)(yValue, unit);
|
|
57
|
-
currentFocusedData.push({
|
|
58
|
-
seriesIdx: seriesIdx,
|
|
59
|
-
datumIdx: datumIdx,
|
|
60
|
-
seriesName: currentSeriesName,
|
|
61
|
-
date: xValueMilliSeconds,
|
|
62
|
-
x: xValue,
|
|
63
|
-
y: yValue,
|
|
64
|
-
formattedY: formattedY,
|
|
65
|
-
markerColor: markerColor.toString()
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return currentFocusedData;
|
|
75
|
-
}
|
|
76
|
-
function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit) {
|
|
77
|
-
if (chart === undefined || mousePos === null) return [];
|
|
78
|
-
// prevents multiple tooltips showing from adjacent charts
|
|
79
|
-
let cursorTargetMatchesChart = false;
|
|
80
|
-
if (mousePos.target !== null) {
|
|
81
|
-
const currentParent = mousePos.target.parentElement;
|
|
82
|
-
if (currentParent !== null) {
|
|
83
|
-
const currentGrandparent = currentParent.parentElement;
|
|
84
|
-
if (currentGrandparent !== null) {
|
|
85
|
-
const chartDom = chart.getDom();
|
|
86
|
-
if (chartDom === currentGrandparent) {
|
|
87
|
-
cursorTargetMatchesChart = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// allows moving cursor inside tooltip
|
|
93
|
-
if (pinnedPos !== null) {
|
|
94
|
-
mousePos = pinnedPos;
|
|
95
|
-
cursorTargetMatchesChart = true;
|
|
96
|
-
}
|
|
97
|
-
if (cursorTargetMatchesChart === false) return [];
|
|
98
|
-
if (chart['_model'] === undefined) return [];
|
|
99
|
-
const chartModel = chart['_model'];
|
|
100
|
-
const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
101
|
-
// tooltip trigger area gets smaller with more series, increase yAxisInterval multiplier to expand nearby series range
|
|
102
|
-
const seriesNum = chartData.timeSeries.length;
|
|
103
|
-
const yBuffer = seriesNum > _tooltipModel.TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 5;
|
|
104
|
-
var _x, _y;
|
|
105
|
-
const pointInPixel = [
|
|
106
|
-
(_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
|
|
107
|
-
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
108
|
-
];
|
|
109
|
-
if (chart.containPixel('grid', pointInPixel)) {
|
|
110
|
-
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
111
|
-
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
112
|
-
return getNearbySeries(chartData, pointInGrid, yBuffer, unit);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return [];
|
|
116
|
-
}
|