@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-model.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/tooltip-model.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tooltip-model.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/tooltip-model.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,wBAAwB,QAA0B,CAAC;AAChE,eAAO,MAAM,+BAA+B,OAAO,CAAC;AAEpD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAC5E,eAAO,MAAM,6BAA6B,iDAAiD,CAAC;AAE5F,eAAO,MAAM,mBAAmB,qBAQ9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAa7B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;CAG5B,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE;QACJ,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,MAAM,EAAE;QACN,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,UAAU,EAAE;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,OAAO,EAAE;QACP,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACxC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,aAAK,iBAAiB,GAAG;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,oBAAY,eAAe,GAAG,UAAU,GAAG,iBAAiB,CAAC;AAE7D,eAAO,MAAM,gBAAgB,QAAO,UAAU,CAAC,QAAQ,CAoCtD,CAAC"}
|
|
@@ -11,10 +11,14 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { useEffect, useState } from 'react';
|
|
14
|
+
export const TOOLTIP_MIN_WIDTH = 375;
|
|
14
15
|
export const TOOLTIP_MAX_WIDTH = 650;
|
|
15
|
-
export const TOOLTIP_MAX_HEIGHT =
|
|
16
|
+
export const TOOLTIP_MAX_HEIGHT = 600;
|
|
16
17
|
export const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;
|
|
17
|
-
export const
|
|
18
|
+
export const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;
|
|
19
|
+
export const FALLBACK_CHART_WIDTH = 750;
|
|
20
|
+
export const NEARBY_SERIES_DESCRIPTION = 'nearby series showing in tooltip';
|
|
21
|
+
export const EMPHASIZED_SERIES_DESCRIPTION = 'emphasized series showing as bold in tooltip';
|
|
18
22
|
export const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {
|
|
19
23
|
year: 'numeric',
|
|
20
24
|
month: 'short',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesTooltip/tooltip-model.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 { useEffect, useState } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/TimeSeriesTooltip/tooltip-model.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 { useEffect, useState } from 'react';\nimport { NearbySeriesArray } from './nearby-series';\n\nexport const TOOLTIP_MIN_WIDTH = 375;\nexport const TOOLTIP_MAX_WIDTH = 650;\nexport const TOOLTIP_MAX_HEIGHT = 600;\nexport const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;\nexport const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;\n\nexport const FALLBACK_CHART_WIDTH = 750;\n\nexport const NEARBY_SERIES_DESCRIPTION = 'nearby series showing in tooltip';\nexport const EMPHASIZED_SERIES_DESCRIPTION = 'emphasized series showing as bold in tooltip';\n\nexport const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n hour12: true,\n});\n\nexport const defaultCursorData = {\n coords: {\n plotCanvas: {\n x: 0,\n y: 0,\n },\n zrender: {\n x: 0,\n y: 0,\n },\n target: null,\n },\n chartWidth: 0,\n};\n\nexport const emptyTooltipData = {\n cursor: defaultCursorData,\n focusedSeries: null,\n};\n\nexport interface CursorCoordinates {\n page: {\n x: number;\n y: number;\n };\n client: {\n x: number;\n y: number;\n };\n plotCanvas: {\n x: number;\n y: number;\n };\n zrender: {\n x?: number;\n y?: number;\n };\n target: EventTarget | null;\n}\n\nexport interface CursorData {\n coords: CursorCoordinates | null;\n chartWidth?: number;\n}\n\nexport interface TooltipData {\n focusedSeries: NearbySeriesArray | null;\n cursor: CursorData;\n}\n\ntype ZREventProperties = {\n zrX?: number;\n zrY?: number;\n zrDelta?: number;\n zrEventControl?: 'no_globalout' | 'only_globalout';\n zrByTouch?: boolean;\n};\n\nexport type ZRRawMouseEvent = MouseEvent & ZREventProperties;\n\nexport const useMousePosition = (): CursorData['coords'] => {\n const [coords, setCoords] = useState<CursorData['coords']>(null);\n\n useEffect(() => {\n const setFromEvent = (e: ZRRawMouseEvent) => {\n return setCoords({\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.offsetX,\n y: e.offsetY,\n },\n zrender: {\n // echarts canvas coordinates added automatically by zrender\n // zrX and zrY are similar to offsetX and offsetY but they return undefined when not hovering over a chart canvas\n x: e.zrX,\n y: e.zrY,\n },\n // necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)\n target: e.target,\n });\n };\n window.addEventListener('mousemove', setFromEvent);\n\n return () => {\n window.removeEventListener('mousemove', setFromEvent);\n };\n }, []);\n\n return coords;\n};\n"],"names":["useEffect","useState","TOOLTIP_MIN_WIDTH","TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_LABELS_MAX_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","FALLBACK_CHART_WIDTH","NEARBY_SERIES_DESCRIPTION","EMPHASIZED_SERIES_DESCRIPTION","TOOLTIP_DATE_FORMAT","Intl","DateTimeFormat","undefined","year","month","day","hour","minute","second","hour12","defaultCursorData","coords","plotCanvas","x","y","zrender","target","chartWidth","emptyTooltipData","cursor","focusedSeries","useMousePosition","setCoords","setFromEvent","e","page","pageX","pageY","client","clientX","clientY","offsetX","offsetY","zrX","zrY","window","addEventListener","removeEventListener"],"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;AAEjC,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAG5C,OAAO,MAAMC,iBAAiB,GAAG,GAAG,CAAC;AACrC,OAAO,MAAMC,iBAAiB,GAAG,GAAG,CAAC;AACrC,OAAO,MAAMC,kBAAkB,GAAG,GAAG,CAAC;AACtC,OAAO,MAAMC,wBAAwB,GAAGF,iBAAiB,GAAG,GAAG,CAAC;AAChE,OAAO,MAAMG,+BAA+B,GAAG,IAAI,CAAC;AAEpD,OAAO,MAAMC,oBAAoB,GAAG,GAAG,CAAC;AAExC,OAAO,MAAMC,yBAAyB,GAAG,kCAAkC,CAAC;AAC5E,OAAO,MAAMC,6BAA6B,GAAG,8CAA8C,CAAC;AAE5F,OAAO,MAAMC,mBAAmB,GAAG,IAAIC,IAAI,CAACC,cAAc,CAACC,SAAS,EAAE;IACpEC,IAAI,EAAE,SAAS;IACfC,KAAK,EAAE,OAAO;IACdC,GAAG,EAAE,SAAS;IACdC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,SAAS;IACjBC,MAAM,EAAE,SAAS;IACjBC,MAAM,EAAE,IAAI;CACb,CAAC,CAAC;AAEH,OAAO,MAAMC,iBAAiB,GAAG;IAC/BC,MAAM,EAAE;QACNC,UAAU,EAAE;YACVC,CAAC,EAAE,CAAC;YACJC,CAAC,EAAE,CAAC;SACL;QACDC,OAAO,EAAE;YACPF,CAAC,EAAE,CAAC;YACJC,CAAC,EAAE,CAAC;SACL;QACDE,MAAM,EAAE,IAAI;KACb;IACDC,UAAU,EAAE,CAAC;CACd,CAAC;AAEF,OAAO,MAAMC,gBAAgB,GAAG;IAC9BC,MAAM,EAAET,iBAAiB;IACzBU,aAAa,EAAE,IAAI;CACpB,CAAC;AA0CF,OAAO,MAAMC,gBAAgB,GAAG,IAA4B;IAC1D,MAAM,CAACV,MAAM,EAAEW,SAAS,CAAC,GAAGhC,QAAQ,CAAuB,IAAI,CAAC,AAAC;IAEjED,SAAS,CAAC,IAAM;QACd,MAAMkC,YAAY,GAAG,CAACC,CAAkB,GAAK;YAC3C,OAAOF,SAAS,CAAC;gBACfG,IAAI,EAAE;oBACJZ,CAAC,EAAEW,CAAC,CAACE,KAAK;oBACVZ,CAAC,EAAEU,CAAC,CAACG,KAAK;iBACX;gBACDC,MAAM,EAAE;oBACNf,CAAC,EAAEW,CAAC,CAACK,OAAO;oBACZf,CAAC,EAAEU,CAAC,CAACM,OAAO;iBACb;gBACDlB,UAAU,EAAE;oBACVC,CAAC,EAAEW,CAAC,CAACO,OAAO;oBACZjB,CAAC,EAAEU,CAAC,CAACQ,OAAO;iBACb;gBACDjB,OAAO,EAAE;oBACP,4DAA4D;oBAC5D,iHAAiH;oBACjHF,CAAC,EAAEW,CAAC,CAACS,GAAG;oBACRnB,CAAC,EAAEU,CAAC,CAACU,GAAG;iBACT;gBACD,0HAA0H;gBAC1HlB,MAAM,EAAEQ,CAAC,CAACR,MAAM;aACjB,CAAC,CAAC;QACL,CAAC,AAAC;QACFmB,MAAM,CAACC,gBAAgB,CAAC,WAAW,EAAEb,YAAY,CAAC,CAAC;QAEnD,OAAO,IAAM;YACXY,MAAM,CAACE,mBAAmB,CAAC,WAAW,EAAEd,YAAY,CAAC,CAAC;QACxD,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAOZ,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -2,5 +2,5 @@ import { CursorCoordinates, CursorData } from './tooltip-model';
|
|
|
2
2
|
/**
|
|
3
3
|
* Determine position of tooltip depending on chart dimensions and the number of focused series
|
|
4
4
|
*/
|
|
5
|
-
export declare function assembleTransform(mousePos: CursorData['coords'],
|
|
5
|
+
export declare function assembleTransform(mousePos: CursorData['coords'], chartWidth: number, pinnedPos: CursorCoordinates | null, tooltipHeight: number, tooltipWidth: number): string;
|
|
6
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAsD,MAAM,iBAAiB,CAAC;AAEpH;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC9B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,iBAAiB,GAAG,IAAI,EACnC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,UAgCrB"}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { TOOLTIP_MAX_WIDTH } from './tooltip-model';
|
|
13
|
+
import { TOOLTIP_MAX_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER } from './tooltip-model';
|
|
14
14
|
/**
|
|
15
15
|
* Determine position of tooltip depending on chart dimensions and the number of focused series
|
|
16
|
-
*/ export function assembleTransform(mousePos,
|
|
16
|
+
*/ export function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth) {
|
|
17
17
|
if (mousePos === null) {
|
|
18
18
|
return 'translate3d(0, 0)';
|
|
19
19
|
}
|
|
@@ -29,7 +29,8 @@ import { TOOLTIP_MAX_WIDTH } from './tooltip-model';
|
|
|
29
29
|
let y = mousePos.page.y + cursorPaddingY;
|
|
30
30
|
// adjust so tooltip does not get cut off at bottom of chart
|
|
31
31
|
if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {
|
|
32
|
-
|
|
32
|
+
// multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport
|
|
33
|
+
y = mousePos.page.y - tooltipHeight * TOOLTIP_ADJUST_Y_POS_MULTIPLIER;
|
|
33
34
|
}
|
|
34
35
|
// use tooltip width to determine when to repos from right to left
|
|
35
36
|
const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesTooltip/utils.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 { CursorCoordinates, CursorData, TOOLTIP_MAX_WIDTH } from './tooltip-model';\n\n/**\n * Determine position of tooltip depending on chart dimensions and the number of focused series\n */\nexport function assembleTransform(\n mousePos: CursorData['coords'],\n
|
|
1
|
+
{"version":3,"sources":["../../src/TimeSeriesTooltip/utils.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 { CursorCoordinates, CursorData, TOOLTIP_MAX_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER } from './tooltip-model';\n\n/**\n * Determine position of tooltip depending on chart dimensions and the number of focused series\n */\nexport function assembleTransform(\n mousePos: CursorData['coords'],\n chartWidth: number,\n pinnedPos: CursorCoordinates | null,\n tooltipHeight: number,\n tooltipWidth: number\n) {\n if (mousePos === null) {\n return 'translate3d(0, 0)';\n }\n\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n }\n\n const cursorPaddingX = 32;\n const cursorPaddingY = 16;\n\n // Tooltip is located in a Portal attached to the body.\n // Using page coordinates instead of viewport ensures the tooltip is\n // absolutely positioned correctly as the user scrolls\n const x = mousePos.page.x;\n let y = mousePos.page.y + cursorPaddingY;\n\n // adjust so tooltip does not get cut off at bottom of chart\n if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {\n // multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport\n y = mousePos.page.y - tooltipHeight * TOOLTIP_ADJUST_Y_POS_MULTIPLIER;\n }\n\n // use tooltip width to determine when to repos from right to left\n const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;\n\n // reposition so tooltip is never too close to right side of chart or left side of browser window\n return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH\n ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)`\n : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;\n}\n"],"names":["TOOLTIP_MAX_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","assembleTransform","mousePos","chartWidth","pinnedPos","tooltipHeight","tooltipWidth","cursorPaddingX","cursorPaddingY","x","page","y","client","window","innerHeight","xPosAdjustThreshold","plotCanvas"],"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;AAEjC,SAAwCA,iBAAiB,EAAEC,+BAA+B,QAAQ,iBAAiB,CAAC;AAEpH;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAC/BC,QAA8B,EAC9BC,UAAkB,EAClBC,SAAmC,EACnCC,aAAqB,EACrBC,YAAoB,EACpB;IACA,IAAIJ,QAAQ,KAAK,IAAI,EAAE;QACrB,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,IAAIE,SAAS,KAAK,IAAI,EAAE;QACtBF,QAAQ,GAAGE,SAAS,CAAC;IACvB,CAAC;IAED,MAAMG,cAAc,GAAG,EAAE,AAAC;IAC1B,MAAMC,cAAc,GAAG,EAAE,AAAC;IAE1B,uDAAuD;IACvD,oEAAoE;IACpE,sDAAsD;IACtD,MAAMC,CAAC,GAAGP,QAAQ,CAACQ,IAAI,CAACD,CAAC,AAAC;IAC1B,IAAIE,CAAC,GAAGT,QAAQ,CAACQ,IAAI,CAACC,CAAC,GAAGH,cAAc,AAAC;IAEzC,4DAA4D;IAC5D,IAAIN,QAAQ,CAACU,MAAM,CAACD,CAAC,GAAGN,aAAa,GAAGG,cAAc,GAAGK,MAAM,CAACC,WAAW,EAAE;QAC3E,+FAA+F;QAC/FH,CAAC,GAAGT,QAAQ,CAACQ,IAAI,CAACC,CAAC,GAAGN,aAAa,GAAGL,+BAA+B,CAAC;IACxE,CAAC;IAED,kEAAkE;IAClE,MAAMe,mBAAmB,GAAGZ,UAAU,GAAGG,YAAY,GAAG,GAAG,AAAC;IAE5D,iGAAiG;IACjG,OAAOJ,QAAQ,CAACc,UAAU,CAACP,CAAC,GAAGM,mBAAmB,IAAIN,CAAC,GAAGV,iBAAiB,GACvE,CAAC,YAAY,EAAEU,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,wBAAwB,CAAC,GACnE,CAAC,YAAY,EAAEF,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -20,8 +20,9 @@ Object.defineProperty(exports, "CompactLegend", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
|
+
const _model = require("../model");
|
|
23
24
|
const _listLegendItem = require("./ListLegendItem");
|
|
24
|
-
function CompactLegend({ height , items }) {
|
|
25
|
+
function CompactLegend({ height , items , selectedItems , onLegendItemClick }) {
|
|
25
26
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
26
27
|
component: "ul",
|
|
27
28
|
sx: {
|
|
@@ -38,6 +39,8 @@ function CompactLegend({ height , items }) {
|
|
|
38
39
|
},
|
|
39
40
|
children: items.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
40
41
|
item: item,
|
|
42
|
+
isVisuallySelected: (0, _model.isLegendItemVisuallySelected)(item, selectedItems),
|
|
43
|
+
onClick: onLegendItemClick,
|
|
41
44
|
sx: {
|
|
42
45
|
width: 'auto',
|
|
43
46
|
float: 'left',
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "Legend", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
|
+
const _immer = require("immer");
|
|
23
24
|
const _listLegend = require("./ListLegend");
|
|
24
25
|
const _compactLegend = require("./CompactLegend");
|
|
25
26
|
// When the number of items to display is above this number, it is likely to
|
|
@@ -28,7 +29,45 @@ const _compactLegend = require("./CompactLegend");
|
|
|
28
29
|
// Set this number based on testing, but it may need to be tuned a bit on the
|
|
29
30
|
// future as people test this out on different machines.
|
|
30
31
|
const NEED_VIRTUALIZATION_LIMIT = 500;
|
|
31
|
-
function Legend({ width , height , options , data ,
|
|
32
|
+
function Legend({ width , height , options , data , selectedItems , onSelectedItemsChange }) {
|
|
33
|
+
const onLegendItemClick = (e, seriesId)=>{
|
|
34
|
+
const isModifiedClick = e.metaKey || e.shiftKey;
|
|
35
|
+
const newSelected = (0, _immer.produce)(selectedItems, (draft)=>{
|
|
36
|
+
if (draft === 'ALL') {
|
|
37
|
+
return {
|
|
38
|
+
[seriesId]: true
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const isSelected = !!draft[seriesId];
|
|
42
|
+
// Clicks with modifier key can select multiple items.
|
|
43
|
+
if (isModifiedClick) {
|
|
44
|
+
if (isSelected) {
|
|
45
|
+
// Modified click on already selected item. Remove that item.
|
|
46
|
+
delete draft[seriesId];
|
|
47
|
+
} else {
|
|
48
|
+
// Modified click on not-selected item. Add it.
|
|
49
|
+
draft[seriesId] = true;
|
|
50
|
+
}
|
|
51
|
+
return draft;
|
|
52
|
+
}
|
|
53
|
+
if (isSelected) {
|
|
54
|
+
// Clicked item was already selected. Unselect it and return to
|
|
55
|
+
// ALL state.
|
|
56
|
+
return 'ALL';
|
|
57
|
+
}
|
|
58
|
+
// Select clicked item.
|
|
59
|
+
return {
|
|
60
|
+
[seriesId]: true
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
onSelectedItemsChange(newSelected);
|
|
64
|
+
};
|
|
65
|
+
const commonLegendProps = {
|
|
66
|
+
height,
|
|
67
|
+
items: data,
|
|
68
|
+
selectedItems,
|
|
69
|
+
onLegendItemClick
|
|
70
|
+
};
|
|
32
71
|
if (options.position === 'Right') {
|
|
33
72
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
34
73
|
sx: {
|
|
@@ -39,10 +78,8 @@ function Legend({ width , height , options , data , listProps }) {
|
|
|
39
78
|
right: 0
|
|
40
79
|
},
|
|
41
80
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegend.ListLegend, {
|
|
42
|
-
|
|
43
|
-
width: width
|
|
44
|
-
height: height,
|
|
45
|
-
...listProps
|
|
81
|
+
...commonLegendProps,
|
|
82
|
+
width: width
|
|
46
83
|
})
|
|
47
84
|
});
|
|
48
85
|
}
|
|
@@ -59,13 +96,10 @@ function Legend({ width , height , options , data , listProps }) {
|
|
|
59
96
|
bottom: 0
|
|
60
97
|
},
|
|
61
98
|
children: needsVirtualization ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegend.ListLegend, {
|
|
62
|
-
|
|
63
|
-
width: width
|
|
64
|
-
height: height,
|
|
65
|
-
...listProps
|
|
99
|
+
...commonLegendProps,
|
|
100
|
+
width: width
|
|
66
101
|
}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_compactLegend.CompactLegend, {
|
|
67
|
-
|
|
68
|
-
height: height
|
|
102
|
+
...commonLegendProps
|
|
69
103
|
})
|
|
70
104
|
});
|
|
71
105
|
}
|
|
@@ -20,85 +20,36 @@ Object.defineProperty(exports, "ListLegend", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const _reactVirtuoso = require("react-virtuoso");
|
|
24
|
+
const _model = require("../model");
|
|
25
25
|
const _listLegendItem = require("./ListLegendItem");
|
|
26
|
-
|
|
27
|
-
function ListLegend({ items , height , width , initialRowHeight =DEFAULT_INITIAL_ROW_HEIGHT }) {
|
|
28
|
-
// Storing a ref to the react-window `VariableSizeList`, so we can call
|
|
29
|
-
// `resetAfterIndex` to resize the list after mouseover/out events to account
|
|
30
|
-
// for the change in list items on hover.
|
|
31
|
-
const listRef = (0, _react.useRef)(null);
|
|
32
|
-
// Storing row heights, so we can use dynamic heights, which enables the
|
|
33
|
-
// user the hover to show the full label, while still having a virtualized
|
|
34
|
-
// list.
|
|
35
|
-
const rowHeights = (0, _react.useRef)({});
|
|
26
|
+
function ListLegend({ items , height , width , selectedItems , onLegendItemClick }) {
|
|
36
27
|
const theme = (0, _material.useTheme)();
|
|
37
|
-
// Padding value used
|
|
38
|
-
//
|
|
39
|
-
//
|
|
28
|
+
// Padding value used in the react virtuoso header/footer components to
|
|
29
|
+
// simulate top/bottom padding based on recommendation in this
|
|
30
|
+
// issue.
|
|
31
|
+
// https://github.com/petyosi/react-virtuoso/issues/238
|
|
40
32
|
const LIST_PADDING = parseInt(theme.spacing(1), 10);
|
|
33
|
+
const mockPadding = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
34
|
+
sx: {
|
|
35
|
+
width: '100%',
|
|
36
|
+
height: `${LIST_PADDING}px`
|
|
37
|
+
}
|
|
38
|
+
});
|
|
41
39
|
// show full labels on hover when there are many total series
|
|
42
40
|
const truncateLabels = items.length > 5;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function setRowHeight(index, size) {
|
|
52
|
-
var // Tell the virtualized list that items changed size and need to be
|
|
53
|
-
// re-evaluated.
|
|
54
|
-
ref;
|
|
55
|
-
(ref = listRef.current) === null || ref === void 0 ? void 0 : ref.resetAfterIndex(0);
|
|
56
|
-
rowHeights.current = {
|
|
57
|
-
...rowHeights.current,
|
|
58
|
-
[index]: size
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
// Renderer for virtualized rows in `VariableSizeList`.
|
|
62
|
-
function ListLegendRow({ index , style }) {
|
|
63
|
-
// Storing a ref to the row's `ListLegendItem`, so we can get the "real"
|
|
64
|
-
// height and adjust the height of the row based on it, enabling the dynamic
|
|
65
|
-
// heights on hover.
|
|
66
|
-
const rowRef = (0, _react.useRef)(null);
|
|
67
|
-
// useCallback is important here to avoid constantly running the useEffect
|
|
68
|
-
// that calls this in `ListLegendItem`.
|
|
69
|
-
const handleRowLayoutChange = (0, _react.useCallback)(()=>{
|
|
70
|
-
// Handle size changes from hovering on a list item.
|
|
71
|
-
if (rowRef.current) {
|
|
72
|
-
setRowHeight(index, rowRef.current.clientHeight);
|
|
73
|
-
}
|
|
74
|
-
}, [
|
|
75
|
-
index
|
|
76
|
-
]);
|
|
77
|
-
// Adjust row heights when the row being rendered changes.
|
|
78
|
-
(0, _react.useEffect)(()=>{
|
|
79
|
-
handleRowLayoutChange();
|
|
80
|
-
}, [
|
|
81
|
-
handleRowLayoutChange
|
|
82
|
-
]);
|
|
83
|
-
const item = items[index];
|
|
84
|
-
if (!item) {
|
|
85
|
-
// This shouldn't happen if configured correctly, but covering
|
|
86
|
-
// the case to appease the type checking and to cover any edge
|
|
87
|
-
// cases.
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
const originalTop = parseFloat(`${style.top}`);
|
|
91
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
92
|
-
style: {
|
|
93
|
-
...style,
|
|
94
|
-
// Adjust the top position to simulate top padding on the list.
|
|
95
|
-
top: `${originalTop + LIST_PADDING}px`
|
|
96
|
-
},
|
|
97
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
98
|
-
ref: rowRef,
|
|
41
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactVirtuoso.Virtuoso, {
|
|
42
|
+
style: {
|
|
43
|
+
height,
|
|
44
|
+
width
|
|
45
|
+
},
|
|
46
|
+
data: items,
|
|
47
|
+
itemContent: (index, item)=>{
|
|
48
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
|
|
99
49
|
item: item,
|
|
100
50
|
truncateLabel: truncateLabels,
|
|
101
|
-
|
|
51
|
+
isVisuallySelected: (0, _model.isLegendItemVisuallySelected)(item, selectedItems),
|
|
52
|
+
onClick: onLegendItemClick,
|
|
102
53
|
sx: {
|
|
103
54
|
// Having an explicit width is important for the ellipsizing to
|
|
104
55
|
// work correctly. Subtract padding to simulate padding.
|
|
@@ -106,32 +57,16 @@ function ListLegend({ items , height , width , initialRowHeight =DEFAULT_INITIAL
|
|
|
106
57
|
wordBreak: 'break-word',
|
|
107
58
|
overflow: 'hidden'
|
|
108
59
|
}
|
|
109
|
-
}, item.id)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const InnerElementType = /*#__PURE__*/ (0, _react.forwardRef)(function InnerElementType({ style , ...rest }, ref) {
|
|
116
|
-
const originalHeight = (style === null || style === void 0 ? void 0 : style.height) ? parseFloat(`${style === null || style === void 0 ? void 0 : style.height}`) : 0;
|
|
117
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
118
|
-
ref: ref,
|
|
119
|
-
role: "list",
|
|
120
|
-
style: {
|
|
121
|
-
...style,
|
|
122
|
-
// Adjust height to account for simulated padding.
|
|
123
|
-
height: `${originalHeight + LIST_PADDING * 2}px`
|
|
60
|
+
}, item.id);
|
|
61
|
+
},
|
|
62
|
+
role: "list",
|
|
63
|
+
components: {
|
|
64
|
+
Header: ()=>{
|
|
65
|
+
return mockPadding;
|
|
124
66
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
height: height,
|
|
130
|
-
width: width,
|
|
131
|
-
itemCount: items.length,
|
|
132
|
-
itemSize: getRowHeight,
|
|
133
|
-
innerElementType: InnerElementType,
|
|
134
|
-
ref: listRef,
|
|
135
|
-
children: ListLegendRow
|
|
67
|
+
Footer: ()=>{
|
|
68
|
+
return mockPadding;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
136
71
|
});
|
|
137
72
|
}
|
|
@@ -62,7 +62,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
62
62
|
}
|
|
63
63
|
return newObj;
|
|
64
64
|
}
|
|
65
|
-
const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLegendItem({ item , sx , truncateLabel ,
|
|
65
|
+
const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLegendItem({ item , sx , truncateLabel , onClick , isVisuallySelected , ...others }, ref) {
|
|
66
66
|
const [noWrap, setNoWrap] = (0, _react.useState)(truncateLabel);
|
|
67
67
|
function handleMouseOver() {
|
|
68
68
|
if (truncateLabel) {
|
|
@@ -74,14 +74,11 @@ const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLeg
|
|
|
74
74
|
setNoWrap(true);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
noWrap,
|
|
83
|
-
onLayoutChange
|
|
84
|
-
]);
|
|
77
|
+
const handleClick = (e)=>{
|
|
78
|
+
var ref;
|
|
79
|
+
onClick(e, item.id);
|
|
80
|
+
(ref = item.onClick) === null || ref === void 0 ? void 0 : ref.call(item, e);
|
|
81
|
+
};
|
|
85
82
|
return /*#__PURE__*/ (0, _react.createElement)(_material.ListItem, {
|
|
86
83
|
...others,
|
|
87
84
|
component: "div",
|
|
@@ -92,8 +89,8 @@ const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLeg
|
|
|
92
89
|
}, sx),
|
|
93
90
|
dense: true,
|
|
94
91
|
key: item.id,
|
|
95
|
-
onClick:
|
|
96
|
-
selected:
|
|
92
|
+
onClick: handleClick,
|
|
93
|
+
selected: isVisuallySelected,
|
|
97
94
|
ref: ref,
|
|
98
95
|
children: [
|
|
99
96
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
@@ -26,7 +26,6 @@ const _charts = require("echarts/charts");
|
|
|
26
26
|
const _components = require("echarts/components");
|
|
27
27
|
const _renderers = require("echarts/renderers");
|
|
28
28
|
const _echart = require("../EChart");
|
|
29
|
-
const _graph = require("../model/graph");
|
|
30
29
|
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
31
30
|
const _timeSeriesTooltip = require("../TimeSeriesTooltip");
|
|
32
31
|
const _timeZoneProvider = require("../context/TimeZoneProvider");
|
|
@@ -85,12 +84,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
85
84
|
]);
|
|
86
85
|
function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfig ={
|
|
87
86
|
wrapLabels: true
|
|
88
|
-
} , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride }) {
|
|
87
|
+
} , noDataVariant ='message' , onDataZoom , onDoubleClick , __experimentalEChartsOptionsOverride }) {
|
|
89
88
|
var ref;
|
|
90
89
|
const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
|
|
91
90
|
const chartRef = (0, _react.useRef)();
|
|
92
91
|
const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
|
|
93
|
-
const [
|
|
92
|
+
const [isTooltipPinned, setIsTooltipPinned] = (0, _react.useState)(false);
|
|
94
93
|
const { timeZone } = (0, _timeZoneProvider.useTimeZone)();
|
|
95
94
|
const handleEvents = (0, _react.useMemo)(()=>{
|
|
96
95
|
return {
|
|
@@ -98,7 +97,7 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
98
97
|
if (onDataZoom === undefined) {
|
|
99
98
|
setTimeout(()=>{
|
|
100
99
|
// workaround so unpin happens after click event
|
|
101
|
-
|
|
100
|
+
setIsTooltipPinned(false);
|
|
102
101
|
}, 10);
|
|
103
102
|
}
|
|
104
103
|
if (onDataZoom === undefined || params.batch[0] === undefined) return;
|
|
@@ -122,13 +121,13 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
122
121
|
}, [
|
|
123
122
|
data,
|
|
124
123
|
onDataZoom,
|
|
125
|
-
|
|
124
|
+
setIsTooltipPinned
|
|
126
125
|
]);
|
|
127
126
|
if (chartRef.current !== undefined) {
|
|
128
127
|
(0, _utils.enableDataZoom)(chartRef.current);
|
|
129
128
|
}
|
|
130
129
|
const handleOnDoubleClick = (e)=>{
|
|
131
|
-
|
|
130
|
+
setIsTooltipPinned(false);
|
|
132
131
|
// either dispatch ECharts restore action to return to orig state or allow consumer to define behavior
|
|
133
132
|
if (onDoubleClick === undefined) {
|
|
134
133
|
if (chartRef.current !== undefined) {
|
|
@@ -141,9 +140,9 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
141
140
|
const { noDataOption } = chartsTheme;
|
|
142
141
|
const option = (0, _react.useMemo)(()=>{
|
|
143
142
|
if (data.timeSeries === undefined) return {};
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
|
|
143
|
+
// The "chart" `noDataVariant` is only used when the `timeSeries` is an
|
|
144
|
+
// empty array because a `null` value will throw an error.
|
|
145
|
+
if (data.timeSeries === null || data.timeSeries.length === 0 && noDataVariant === 'message') return noDataOption;
|
|
147
146
|
var _rangeMs;
|
|
148
147
|
const rangeMs = (_rangeMs = data.rangeMs) !== null && _rangeMs !== void 0 ? _rangeMs : (0, _utils.getDateRange)(data.xAxis);
|
|
149
148
|
const option = {
|
|
@@ -161,13 +160,17 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
161
160
|
yAxis: (0, _utils.getYAxes)(yAxis, unit),
|
|
162
161
|
animation: false,
|
|
163
162
|
tooltip: {
|
|
164
|
-
show:
|
|
163
|
+
show: true,
|
|
165
164
|
trigger: 'axis',
|
|
166
|
-
showContent: false
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
showContent: false
|
|
166
|
+
},
|
|
167
|
+
// https://echarts.apache.org/en/option.html#axisPointer
|
|
168
|
+
axisPointer: {
|
|
169
|
+
type: 'line',
|
|
170
|
+
z: 0,
|
|
171
|
+
triggerEmphasis: false,
|
|
172
|
+
triggerTooltip: false,
|
|
173
|
+
snap: true
|
|
171
174
|
},
|
|
172
175
|
toolbox: {
|
|
173
176
|
feature: {
|
|
@@ -192,17 +195,21 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
192
195
|
legend,
|
|
193
196
|
noDataOption,
|
|
194
197
|
timeZone,
|
|
195
|
-
__experimentalEChartsOptionsOverride
|
|
198
|
+
__experimentalEChartsOptionsOverride,
|
|
199
|
+
noDataVariant
|
|
196
200
|
]);
|
|
197
201
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
198
202
|
sx: {
|
|
199
203
|
height
|
|
200
204
|
},
|
|
201
|
-
onClick: ()=>{
|
|
202
|
-
|
|
205
|
+
onClick: (e)=>{
|
|
206
|
+
// Pin and unpin when clicking on chart canvas but not tooltip text.
|
|
207
|
+
if (e.target instanceof HTMLCanvasElement) {
|
|
208
|
+
setIsTooltipPinned((current)=>!current);
|
|
209
|
+
}
|
|
203
210
|
},
|
|
204
211
|
onMouseDown: (e)=>{
|
|
205
|
-
//
|
|
212
|
+
// Hide tooltip when user drags to zoom, but allow clicking inside tooltip to copy labels.
|
|
206
213
|
if (e.target instanceof HTMLCanvasElement) {
|
|
207
214
|
setShowTooltip(false);
|
|
208
215
|
}
|
|
@@ -212,7 +219,6 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
212
219
|
},
|
|
213
220
|
onMouseLeave: ()=>{
|
|
214
221
|
setShowTooltip(false);
|
|
215
|
-
setPinTooltip(false);
|
|
216
222
|
},
|
|
217
223
|
onMouseEnter: ()=>{
|
|
218
224
|
setShowTooltip(true);
|
|
@@ -226,8 +232,11 @@ function LineChart({ height , data , yAxis , unit , grid , legend , tooltipConfi
|
|
|
226
232
|
chartRef: chartRef,
|
|
227
233
|
chartData: data,
|
|
228
234
|
wrapLabels: tooltipConfig.wrapLabels,
|
|
229
|
-
|
|
230
|
-
unit: unit
|
|
235
|
+
isTooltipPinned: isTooltipPinned,
|
|
236
|
+
unit: unit,
|
|
237
|
+
onUnpinClick: ()=>{
|
|
238
|
+
setIsTooltipPinned(false);
|
|
239
|
+
}
|
|
231
240
|
}),
|
|
232
241
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_echart.EChart, {
|
|
233
242
|
sx: {
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
Object.defineProperty(exports, "InnerTable", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>InnerTable
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _react = require("react");
|
|
24
|
+
const StyledMuiTable = (0, _material.styled)(_material.Table)(({ theme })=>({
|
|
25
|
+
// This value is needed to have a consistent table layout when scrolling.
|
|
26
|
+
tableLayout: 'fixed',
|
|
27
|
+
borderCollapse: 'separate',
|
|
28
|
+
backgroundColor: theme.palette.background.paper
|
|
29
|
+
}));
|
|
30
|
+
const TABLE_DENSITY_CONFIG = {
|
|
31
|
+
compact: 'small',
|
|
32
|
+
standard: 'medium'
|
|
33
|
+
};
|
|
34
|
+
const InnerTable = /*#__PURE__*/ (0, _react.forwardRef)(function InnerTable({ density , width , ...otherProps }, ref) {
|
|
35
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(StyledMuiTable, {
|
|
36
|
+
...otherProps,
|
|
37
|
+
tabIndex: -1,
|
|
38
|
+
size: TABLE_DENSITY_CONFIG[density],
|
|
39
|
+
ref: ref,
|
|
40
|
+
sx: {
|
|
41
|
+
width: width
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|