@perses-dev/components 0.0.0-snapshot-time-range-height-80d08fc
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/LICENSE +201 -0
- package/README.md +18 -0
- package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts +9 -0
- package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -0
- package/dist/DateTimeRangePicker/AbsoluteTimePicker.js +181 -0
- package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +12 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js +79 -0
- package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -0
- package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts +17 -0
- package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -0
- package/dist/DateTimeRangePicker/TimeRangeSelector.js +58 -0
- package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -0
- package/dist/DateTimeRangePicker/index.d.ts +4 -0
- package/dist/DateTimeRangePicker/index.d.ts.map +1 -0
- package/dist/DateTimeRangePicker/index.js +17 -0
- package/dist/DateTimeRangePicker/index.js.map +1 -0
- package/dist/DateTimeRangePicker/utils.d.ts +7 -0
- package/dist/DateTimeRangePicker/utils.d.ts.map +1 -0
- package/dist/DateTimeRangePicker/utils.js +37 -0
- package/dist/DateTimeRangePicker/utils.js.map +1 -0
- package/dist/Drawer/Drawer.d.ts +9 -0
- package/dist/Drawer/Drawer.d.ts.map +1 -0
- package/dist/Drawer/Drawer.js +34 -0
- package/dist/Drawer/Drawer.js.map +1 -0
- package/dist/Drawer/index.d.ts +2 -0
- package/dist/Drawer/index.d.ts.map +1 -0
- package/dist/Drawer/index.js +15 -0
- package/dist/Drawer/index.js.map +1 -0
- package/dist/EChart.d.ts +61 -0
- package/dist/EChart.d.ts.map +1 -0
- package/dist/EChart.js +143 -0
- package/dist/EChart.js.map +1 -0
- package/dist/ErrorAlert.d.ts +9 -0
- package/dist/ErrorAlert.d.ts.map +1 -0
- package/dist/ErrorAlert.js +25 -0
- package/dist/ErrorAlert.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +3 -0
- package/dist/ErrorBoundary.d.ts.map +1 -0
- package/dist/ErrorBoundary.js +16 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/GaugeChart/GaugeChart.d.ts +15 -0
- package/dist/GaugeChart/GaugeChart.d.ts.map +1 -0
- package/dist/GaugeChart/GaugeChart.js +172 -0
- package/dist/GaugeChart/GaugeChart.js.map +1 -0
- package/dist/GaugeChart/index.d.ts +2 -0
- package/dist/GaugeChart/index.d.ts.map +1 -0
- package/dist/GaugeChart/index.js +15 -0
- package/dist/GaugeChart/index.js.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.d.ts +17 -0
- package/dist/InfoTooltip/InfoTooltip.d.ts.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.js +76 -0
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.test.d.ts +2 -0
- package/dist/InfoTooltip/InfoTooltip.test.d.ts.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.test.js +36 -0
- package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
- package/dist/InfoTooltip/index.d.ts +2 -0
- package/dist/InfoTooltip/index.d.ts.map +1 -0
- package/dist/InfoTooltip/index.js +15 -0
- package/dist/InfoTooltip/index.js.map +1 -0
- package/dist/JSONEditor.d.ts +8 -0
- package/dist/JSONEditor.d.ts.map +1 -0
- package/dist/JSONEditor.js +51 -0
- package/dist/JSONEditor.js.map +1 -0
- package/dist/Legend/CompactLegend.d.ts +13 -0
- package/dist/Legend/CompactLegend.d.ts.map +1 -0
- package/dist/Legend/CompactLegend.js +45 -0
- package/dist/Legend/CompactLegend.js.map +1 -0
- package/dist/Legend/Legend.d.ts +11 -0
- package/dist/Legend/Legend.d.ts.map +1 -0
- package/dist/Legend/Legend.js +39 -0
- package/dist/Legend/Legend.js.map +1 -0
- package/dist/Legend/LegendColorBadge.d.ts +7 -0
- package/dist/Legend/LegendColorBadge.d.ts.map +1 -0
- package/dist/Legend/LegendColorBadge.js +31 -0
- package/dist/Legend/LegendColorBadge.js.map +1 -0
- package/dist/Legend/ListLegend.d.ts +11 -0
- package/dist/Legend/ListLegend.d.ts.map +1 -0
- package/dist/Legend/ListLegend.js +40 -0
- package/dist/Legend/ListLegend.js.map +1 -0
- package/dist/Legend/ListLegendItem.d.ts +9 -0
- package/dist/Legend/ListLegendItem.d.ts.map +1 -0
- package/dist/Legend/ListLegendItem.js +47 -0
- package/dist/Legend/ListLegendItem.js.map +1 -0
- package/dist/Legend/index.d.ts +2 -0
- package/dist/Legend/index.d.ts.map +1 -0
- package/dist/Legend/index.js +15 -0
- package/dist/Legend/index.js.map +1 -0
- package/dist/LineChart/LineChart.d.ts +19 -0
- package/dist/LineChart/LineChart.d.ts.map +1 -0
- package/dist/LineChart/LineChart.js +189 -0
- package/dist/LineChart/LineChart.js.map +1 -0
- package/dist/LineChart/index.d.ts +3 -0
- package/dist/LineChart/index.d.ts.map +1 -0
- package/dist/LineChart/index.js +15 -0
- package/dist/LineChart/index.js.map +1 -0
- package/dist/LineChart/utils.d.ts +30 -0
- package/dist/LineChart/utils.d.ts.map +1 -0
- package/dist/LineChart/utils.js +90 -0
- package/dist/LineChart/utils.js.map +1 -0
- package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts +13 -0
- package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts.map +1 -0
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +28 -0
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -0
- package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts +5 -0
- package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -0
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +50 -0
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -0
- package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts +13 -0
- package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts.map +1 -0
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +26 -0
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -0
- package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +13 -0
- package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -0
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +36 -0
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -0
- package/dist/OptionsEditorLayout/index.d.ts +5 -0
- package/dist/OptionsEditorLayout/index.d.ts.map +1 -0
- package/dist/OptionsEditorLayout/index.js +18 -0
- package/dist/OptionsEditorLayout/index.js.map +1 -0
- package/dist/StatChart/StatChart.d.ts +19 -0
- package/dist/StatChart/StatChart.d.ts.map +1 -0
- package/dist/StatChart/StatChart.js +121 -0
- package/dist/StatChart/StatChart.js.map +1 -0
- package/dist/StatChart/StatChart.test.d.ts +2 -0
- package/dist/StatChart/StatChart.test.d.ts.map +1 -0
- package/dist/StatChart/StatChart.test.js +87 -0
- package/dist/StatChart/StatChart.test.js.map +1 -0
- package/dist/StatChart/index.d.ts +2 -0
- package/dist/StatChart/index.d.ts.map +1 -0
- package/dist/StatChart/index.js +15 -0
- package/dist/StatChart/index.js.map +1 -0
- package/dist/Tooltip/SeriesInfo.d.ts +12 -0
- package/dist/Tooltip/SeriesInfo.d.ts.map +1 -0
- package/dist/Tooltip/SeriesInfo.js +143 -0
- package/dist/Tooltip/SeriesInfo.js.map +1 -0
- package/dist/Tooltip/SeriesMarker.d.ts +7 -0
- package/dist/Tooltip/SeriesMarker.d.ts.map +1 -0
- package/dist/Tooltip/SeriesMarker.js +33 -0
- package/dist/Tooltip/SeriesMarker.js.map +1 -0
- package/dist/Tooltip/Tooltip.d.ts +13 -0
- package/dist/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/Tooltip/Tooltip.js +72 -0
- package/dist/Tooltip/Tooltip.js.map +1 -0
- package/dist/Tooltip/TooltipContent.d.ts +9 -0
- package/dist/Tooltip/TooltipContent.d.ts.map +1 -0
- package/dist/Tooltip/TooltipContent.js +89 -0
- package/dist/Tooltip/TooltipContent.js.map +1 -0
- package/dist/Tooltip/focused-series.d.ts +25 -0
- package/dist/Tooltip/focused-series.d.ts.map +1 -0
- package/dist/Tooltip/focused-series.js +111 -0
- package/dist/Tooltip/focused-series.js.map +1 -0
- package/dist/Tooltip/focused-series.test.d.ts +2 -0
- package/dist/Tooltip/focused-series.test.d.ts.map +1 -0
- package/dist/Tooltip/focused-series.test.js +93 -0
- package/dist/Tooltip/focused-series.test.js.map +1 -0
- package/dist/Tooltip/index.d.ts +3 -0
- package/dist/Tooltip/index.d.ts.map +1 -0
- package/dist/Tooltip/index.js +16 -0
- package/dist/Tooltip/index.js.map +1 -0
- package/dist/Tooltip/tooltip-model.d.ts +79 -0
- package/dist/Tooltip/tooltip-model.d.ts.map +1 -0
- package/dist/Tooltip/tooltip-model.js +80 -0
- package/dist/Tooltip/tooltip-model.js.map +1 -0
- package/dist/Tooltip/utils.d.ts +6 -0
- package/dist/Tooltip/utils.d.ts.map +1 -0
- package/dist/Tooltip/utils.js +46 -0
- package/dist/Tooltip/utils.js.map +1 -0
- package/dist/UnitSelector/UnitSelector.d.ts +8 -0
- package/dist/UnitSelector/UnitSelector.d.ts.map +1 -0
- package/dist/UnitSelector/UnitSelector.js +112 -0
- package/dist/UnitSelector/UnitSelector.js.map +1 -0
- package/dist/UnitSelector/UnitSelector.test.d.ts +2 -0
- package/dist/UnitSelector/UnitSelector.test.d.ts.map +1 -0
- package/dist/UnitSelector/UnitSelector.test.js +205 -0
- package/dist/UnitSelector/UnitSelector.test.js.map +1 -0
- package/dist/UnitSelector/index.d.ts +2 -0
- package/dist/UnitSelector/index.d.ts.map +1 -0
- package/dist/UnitSelector/index.js +15 -0
- package/dist/UnitSelector/index.js.map +1 -0
- package/dist/YAxisLabel.d.ts +8 -0
- package/dist/YAxisLabel.d.ts.map +1 -0
- package/dist/YAxisLabel.js +39 -0
- package/dist/YAxisLabel.js.map +1 -0
- package/dist/cjs/DateTimeRangePicker/AbsoluteTimePicker.js +187 -0
- package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +85 -0
- package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +69 -0
- package/dist/cjs/DateTimeRangePicker/index.js +30 -0
- package/dist/cjs/DateTimeRangePicker/utils.js +45 -0
- package/dist/cjs/Drawer/Drawer.js +40 -0
- package/dist/cjs/Drawer/index.js +28 -0
- package/dist/cjs/EChart.js +188 -0
- package/dist/cjs/ErrorAlert.js +29 -0
- package/dist/cjs/ErrorBoundary.js +22 -0
- package/dist/cjs/GaugeChart/GaugeChart.js +178 -0
- package/dist/cjs/GaugeChart/index.js +28 -0
- package/dist/cjs/InfoTooltip/InfoTooltip.js +93 -0
- package/dist/cjs/InfoTooltip/InfoTooltip.test.js +43 -0
- package/dist/cjs/InfoTooltip/index.js +28 -0
- package/dist/cjs/JSONEditor.js +57 -0
- package/dist/cjs/Legend/CompactLegend.js +48 -0
- package/dist/cjs/Legend/Legend.js +45 -0
- package/dist/cjs/Legend/LegendColorBadge.js +42 -0
- package/dist/cjs/Legend/ListLegend.js +44 -0
- package/dist/cjs/Legend/ListLegendItem.js +91 -0
- package/dist/cjs/Legend/index.js +28 -0
- package/dist/cjs/LineChart/LineChart.js +195 -0
- package/dist/cjs/LineChart/index.js +28 -0
- package/dist/cjs/LineChart/utils.js +95 -0
- package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +32 -0
- package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +61 -0
- package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +29 -0
- package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +40 -0
- package/dist/cjs/OptionsEditorLayout/index.js +31 -0
- package/dist/cjs/StatChart/StatChart.js +165 -0
- package/dist/cjs/StatChart/StatChart.test.js +89 -0
- package/dist/cjs/StatChart/index.js +28 -0
- package/dist/cjs/Tooltip/SeriesInfo.js +149 -0
- package/dist/cjs/Tooltip/SeriesMarker.js +39 -0
- package/dist/cjs/Tooltip/Tooltip.js +116 -0
- package/dist/cjs/Tooltip/TooltipContent.js +95 -0
- package/dist/cjs/Tooltip/focused-series.js +117 -0
- package/dist/cjs/Tooltip/focused-series.test.js +95 -0
- package/dist/cjs/Tooltip/index.js +29 -0
- package/dist/cjs/Tooltip/tooltip-model.js +98 -0
- package/dist/cjs/Tooltip/utils.js +50 -0
- package/dist/cjs/UnitSelector/UnitSelector.js +118 -0
- package/dist/cjs/UnitSelector/UnitSelector.test.js +212 -0
- package/dist/cjs/UnitSelector/index.js +28 -0
- package/dist/cjs/YAxisLabel.js +45 -0
- package/dist/cjs/context/ChartsThemeProvider.js +83 -0
- package/dist/cjs/context/TimeZoneProvider.js +90 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/model/graph.js +21 -0
- package/dist/cjs/model/index.js +30 -0
- package/dist/cjs/model/theme.js +16 -0
- package/dist/cjs/model/units/bytes.js +60 -0
- package/dist/cjs/model/units/constants.js +23 -0
- package/dist/cjs/model/units/decimal.js +67 -0
- package/dist/cjs/model/units/index.js +30 -0
- package/dist/cjs/model/units/percent.js +64 -0
- package/dist/cjs/model/units/time.js +102 -0
- package/dist/cjs/model/units/types.js +28 -0
- package/dist/cjs/model/units/units.js +104 -0
- package/dist/cjs/test/index.js +28 -0
- package/dist/cjs/test/render.js +36 -0
- package/dist/cjs/test/setup-tests.js +20 -0
- package/dist/cjs/test-utils/index.js +28 -0
- package/dist/cjs/test-utils/theme.js +28 -0
- package/dist/cjs/theme/index.js +28 -0
- package/dist/cjs/theme/palette/background.js +40 -0
- package/dist/cjs/theme/palette/colors/blue.js +35 -0
- package/dist/cjs/theme/palette/colors/common.js +28 -0
- package/dist/cjs/theme/palette/colors/green.js +35 -0
- package/dist/cjs/theme/palette/colors/grey.js +35 -0
- package/dist/cjs/theme/palette/colors/index.js +35 -0
- package/dist/cjs/theme/palette/colors/orange.js +35 -0
- package/dist/cjs/theme/palette/colors/purple.js +35 -0
- package/dist/cjs/theme/palette/colors/red.js +35 -0
- package/dist/cjs/theme/palette/colors/types.js +16 -0
- package/dist/cjs/theme/palette/error.js +32 -0
- package/dist/cjs/theme/palette/grey.js +44 -0
- package/dist/cjs/theme/palette/index.js +28 -0
- package/dist/cjs/theme/palette/palette-options.js +59 -0
- package/dist/cjs/theme/palette/primary.js +32 -0
- package/dist/cjs/theme/palette/secondary.js +32 -0
- package/dist/cjs/theme/palette/success.js +32 -0
- package/dist/cjs/theme/palette/text.js +42 -0
- package/dist/cjs/theme/palette/warning.js +32 -0
- package/dist/cjs/theme/theme.js +64 -0
- package/dist/cjs/theme/types/ThemeExtension.d.js +17 -0
- package/dist/cjs/theme/typography.js +96 -0
- package/dist/cjs/utils/combine-sx.js +29 -0
- package/dist/cjs/utils/component-ids.js +31 -0
- package/dist/cjs/utils/format.js +56 -0
- package/dist/cjs/utils/format.test.js +47 -0
- package/dist/cjs/utils/index.js +31 -0
- package/dist/cjs/utils/mathjs.js +25 -0
- package/dist/cjs/utils/theme-gen.js +188 -0
- package/dist/cjs/utils/theme-gen.test.js +197 -0
- package/dist/context/ChartsThemeProvider.d.ts +10 -0
- package/dist/context/ChartsThemeProvider.d.ts.map +1 -0
- package/dist/context/ChartsThemeProvider.js +31 -0
- package/dist/context/ChartsThemeProvider.js.map +1 -0
- package/dist/context/TimeZoneProvider.d.ts +13 -0
- package/dist/context/TimeZoneProvider.d.ts.map +1 -0
- package/dist/context/TimeZoneProvider.js +38 -0
- package/dist/context/TimeZoneProvider.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/model/graph.d.ts +34 -0
- package/dist/model/graph.d.ts.map +1 -0
- package/dist/model/graph.js +16 -0
- package/dist/model/graph.js.map +1 -0
- package/dist/model/index.d.ts +4 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +17 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/theme.d.ts +15 -0
- package/dist/model/theme.d.ts.map +1 -0
- package/dist/model/theme.js +15 -0
- package/dist/model/theme.js.map +1 -0
- package/dist/model/units/bytes.d.ts +12 -0
- package/dist/model/units/bytes.d.ts.map +1 -0
- package/dist/model/units/bytes.js +48 -0
- package/dist/model/units/bytes.js.map +1 -0
- package/dist/model/units/constants.d.ts +2 -0
- package/dist/model/units/constants.d.ts.map +1 -0
- package/dist/model/units/constants.js +17 -0
- package/dist/model/units/constants.js.map +1 -0
- package/dist/model/units/decimal.d.ts +24 -0
- package/dist/model/units/decimal.d.ts.map +1 -0
- package/dist/model/units/decimal.js +59 -0
- package/dist/model/units/decimal.js.map +1 -0
- package/dist/model/units/index.d.ts +4 -0
- package/dist/model/units/index.d.ts.map +1 -0
- package/dist/model/units/index.js +17 -0
- package/dist/model/units/index.js.map +1 -0
- package/dist/model/units/percent.d.ts +12 -0
- package/dist/model/units/percent.d.ts.map +1 -0
- package/dist/model/units/percent.js +51 -0
- package/dist/model/units/percent.js.map +1 -0
- package/dist/model/units/time.d.ts +22 -0
- package/dist/model/units/time.d.ts.map +1 -0
- package/dist/model/units/time.js +88 -0
- package/dist/model/units/time.js.map +1 -0
- package/dist/model/units/types.d.ts +38 -0
- package/dist/model/units/types.d.ts.map +1 -0
- package/dist/model/units/types.js +22 -0
- package/dist/model/units/types.js.map +1 -0
- package/dist/model/units/units.d.ts +40 -0
- package/dist/model/units/units.d.ts.map +1 -0
- package/dist/model/units/units.js +83 -0
- package/dist/model/units/units.js.map +1 -0
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +15 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/render.d.ts +7 -0
- package/dist/test/render.d.ts.map +1 -0
- package/dist/test/render.js +32 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.d.ts +2 -0
- package/dist/test/setup-tests.d.ts.map +1 -0
- package/dist/test/setup-tests.js +18 -0
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +15 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/theme.d.ts +3 -0
- package/dist/test-utils/theme.d.ts.map +1 -0
- package/dist/test-utils/theme.js +22 -0
- package/dist/test-utils/theme.js.map +1 -0
- package/dist/theme/index.d.ts +37 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +15 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/palette/background.d.ts +3 -0
- package/dist/theme/palette/background.d.ts.map +1 -0
- package/dist/theme/palette/background.js +34 -0
- package/dist/theme/palette/background.js.map +1 -0
- package/dist/theme/palette/colors/blue.d.ts +3 -0
- package/dist/theme/palette/colors/blue.d.ts.map +1 -0
- package/dist/theme/palette/colors/blue.js +29 -0
- package/dist/theme/palette/colors/blue.js.map +1 -0
- package/dist/theme/palette/colors/common.d.ts +3 -0
- package/dist/theme/palette/colors/common.d.ts.map +1 -0
- package/dist/theme/palette/colors/common.js +16 -0
- package/dist/theme/palette/colors/common.js.map +1 -0
- package/dist/theme/palette/colors/green.d.ts +3 -0
- package/dist/theme/palette/colors/green.d.ts.map +1 -0
- package/dist/theme/palette/colors/green.js +29 -0
- package/dist/theme/palette/colors/green.js.map +1 -0
- package/dist/theme/palette/colors/grey.d.ts +3 -0
- package/dist/theme/palette/colors/grey.d.ts.map +1 -0
- package/dist/theme/palette/colors/grey.js +29 -0
- package/dist/theme/palette/colors/grey.js.map +1 -0
- package/dist/theme/palette/colors/index.d.ts +9 -0
- package/dist/theme/palette/colors/index.d.ts.map +1 -0
- package/dist/theme/palette/colors/index.js +22 -0
- package/dist/theme/palette/colors/index.js.map +1 -0
- package/dist/theme/palette/colors/orange.d.ts +3 -0
- package/dist/theme/palette/colors/orange.d.ts.map +1 -0
- package/dist/theme/palette/colors/orange.js +29 -0
- package/dist/theme/palette/colors/orange.js.map +1 -0
- package/dist/theme/palette/colors/purple.d.ts +3 -0
- package/dist/theme/palette/colors/purple.d.ts.map +1 -0
- package/dist/theme/palette/colors/purple.js +29 -0
- package/dist/theme/palette/colors/purple.js.map +1 -0
- package/dist/theme/palette/colors/red.d.ts +3 -0
- package/dist/theme/palette/colors/red.d.ts.map +1 -0
- package/dist/theme/palette/colors/red.js +29 -0
- package/dist/theme/palette/colors/red.js.map +1 -0
- package/dist/theme/palette/colors/types.d.ts +17 -0
- package/dist/theme/palette/colors/types.d.ts.map +1 -0
- package/dist/theme/palette/colors/types.js +15 -0
- package/dist/theme/palette/colors/types.js.map +1 -0
- package/dist/theme/palette/error.d.ts +3 -0
- package/dist/theme/palette/error.d.ts.map +1 -0
- package/dist/theme/palette/error.js +26 -0
- package/dist/theme/palette/error.js.map +1 -0
- package/dist/theme/palette/grey.d.ts +3 -0
- package/dist/theme/palette/grey.d.ts.map +1 -0
- package/dist/theme/palette/grey.js +38 -0
- package/dist/theme/palette/grey.js.map +1 -0
- package/dist/theme/palette/index.d.ts +3 -0
- package/dist/theme/palette/index.d.ts.map +1 -0
- package/dist/theme/palette/index.js +15 -0
- package/dist/theme/palette/index.js.map +1 -0
- package/dist/theme/palette/palette-options.d.ts +6 -0
- package/dist/theme/palette/palette-options.d.ts.map +1 -0
- package/dist/theme/palette/palette-options.js +55 -0
- package/dist/theme/palette/palette-options.js.map +1 -0
- package/dist/theme/palette/primary.d.ts +3 -0
- package/dist/theme/palette/primary.d.ts.map +1 -0
- package/dist/theme/palette/primary.js +26 -0
- package/dist/theme/palette/primary.js.map +1 -0
- package/dist/theme/palette/secondary.d.ts +3 -0
- package/dist/theme/palette/secondary.d.ts.map +1 -0
- package/dist/theme/palette/secondary.js +26 -0
- package/dist/theme/palette/secondary.js.map +1 -0
- package/dist/theme/palette/success.d.ts +3 -0
- package/dist/theme/palette/success.d.ts.map +1 -0
- package/dist/theme/palette/success.js +26 -0
- package/dist/theme/palette/success.js.map +1 -0
- package/dist/theme/palette/text.d.ts +3 -0
- package/dist/theme/palette/text.d.ts.map +1 -0
- package/dist/theme/palette/text.js +36 -0
- package/dist/theme/palette/text.js.map +1 -0
- package/dist/theme/palette/warning.d.ts +3 -0
- package/dist/theme/palette/warning.d.ts.map +1 -0
- package/dist/theme/palette/warning.js +26 -0
- package/dist/theme/palette/warning.js.map +1 -0
- package/dist/theme/theme.d.ts +13 -0
- package/dist/theme/theme.d.ts.map +1 -0
- package/dist/theme/theme.js +67 -0
- package/dist/theme/theme.js.map +1 -0
- package/dist/theme/types/ThemeExtension.d.js +16 -0
- package/dist/theme/types/ThemeExtension.d.js.map +1 -0
- package/dist/theme/typography.d.ts +10 -0
- package/dist/theme/typography.d.ts.map +1 -0
- package/dist/theme/typography.js +92 -0
- package/dist/theme/typography.js.map +1 -0
- package/dist/utils/combine-sx.d.ts +8 -0
- package/dist/utils/combine-sx.d.ts.map +1 -0
- package/dist/utils/combine-sx.js +27 -0
- package/dist/utils/combine-sx.js.map +1 -0
- package/dist/utils/component-ids.d.ts +8 -0
- package/dist/utils/component-ids.d.ts.map +1 -0
- package/dist/utils/component-ids.js +27 -0
- package/dist/utils/component-ids.js.map +1 -0
- package/dist/utils/format.d.ts +3 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +44 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/format.test.d.ts +2 -0
- package/dist/utils/format.test.d.ts.map +1 -0
- package/dist/utils/format.test.js +45 -0
- package/dist/utils/format.test.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/mathjs.d.ts +6 -0
- package/dist/utils/mathjs.d.ts.map +1 -0
- package/dist/utils/mathjs.js +20 -0
- package/dist/utils/mathjs.js.map +1 -0
- package/dist/utils/theme-gen.d.ts +6 -0
- package/dist/utils/theme-gen.d.ts.map +1 -0
- package/dist/utils/theme-gen.js +182 -0
- package/dist/utils/theme-gen.js.map +1 -0
- package/dist/utils/theme-gen.test.d.ts +2 -0
- package/dist/utils/theme-gen.test.d.ts.map +1 -0
- package/dist/utils/theme-gen.test.js +195 -0
- package/dist/utils/theme-gen.test.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Copyright 2022 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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Box, Divider, Stack, Typography } from '@mui/material';
|
|
15
|
+
import { SeriesMarker } from './SeriesMarker';
|
|
16
|
+
import { TOOLTIP_LABELS_MAX_WIDTH } from './tooltip-model';
|
|
17
|
+
export function SeriesInfo(props) {
|
|
18
|
+
const { seriesName , formattedY , markerColor , totalSeries , wrapLabels } = props;
|
|
19
|
+
// TODO (sjcobb): regex to remove __name__, improve series labels
|
|
20
|
+
const formattedSeriesLabels = seriesName.replace(/[{}"]/g, '');
|
|
21
|
+
if (totalSeries === 1) {
|
|
22
|
+
const jsonFormattedSeries = seriesName[0] === '{' ? true : false;
|
|
23
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
24
|
+
spacing: 0.5,
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
27
|
+
sx: (theme)=>({
|
|
28
|
+
height: '16px',
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
justifyContent: 'left',
|
|
33
|
+
color: theme.palette.common.white,
|
|
34
|
+
fontSize: '11px'
|
|
35
|
+
}),
|
|
36
|
+
children: [
|
|
37
|
+
/*#__PURE__*/ _jsx(SeriesMarker, {
|
|
38
|
+
markerColor: markerColor
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
41
|
+
component: "span",
|
|
42
|
+
children: [
|
|
43
|
+
"value:",
|
|
44
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
45
|
+
component: "span",
|
|
46
|
+
sx: (theme)=>({
|
|
47
|
+
color: theme.palette.common.white,
|
|
48
|
+
fontWeight: 700,
|
|
49
|
+
paddingLeft: '2px'
|
|
50
|
+
}),
|
|
51
|
+
children: formattedY
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ _jsx(Divider, {
|
|
58
|
+
sx: (theme)=>({
|
|
59
|
+
borderColor: theme.palette.grey['500']
|
|
60
|
+
})
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
63
|
+
sx: (theme)=>({
|
|
64
|
+
color: theme.palette.common.white
|
|
65
|
+
}),
|
|
66
|
+
children: formattedSeriesLabels.split(',').map((name)=>{
|
|
67
|
+
if (name) {
|
|
68
|
+
const [key, value] = jsonFormattedSeries ? name.split(':') : name.split('=');
|
|
69
|
+
const formattedKey = value !== undefined ? `${key}: ` : key;
|
|
70
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
71
|
+
sx: {
|
|
72
|
+
display: 'flex',
|
|
73
|
+
gap: '4px'
|
|
74
|
+
},
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
77
|
+
sx: {
|
|
78
|
+
fontSize: '11px'
|
|
79
|
+
},
|
|
80
|
+
children: formattedKey
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
83
|
+
sx: (theme)=>({
|
|
84
|
+
color: theme.palette.common.white,
|
|
85
|
+
fontWeight: 700,
|
|
86
|
+
fontSize: '11px'
|
|
87
|
+
}),
|
|
88
|
+
children: value
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
}, name);
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const inlineSeriesLabels = formattedSeriesLabels.replace(/[,]/g, ', ').replace(/[:=]/g, ': ');
|
|
99
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
100
|
+
sx: {
|
|
101
|
+
display: 'table-row',
|
|
102
|
+
paddingTop: 0.5
|
|
103
|
+
},
|
|
104
|
+
children: [
|
|
105
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
106
|
+
sx: {
|
|
107
|
+
display: 'table-cell',
|
|
108
|
+
maxWidth: '520px'
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ _jsx(SeriesMarker, {
|
|
112
|
+
markerColor: markerColor
|
|
113
|
+
}),
|
|
114
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
115
|
+
component: "span",
|
|
116
|
+
sx: (theme)=>({
|
|
117
|
+
color: theme.palette.common.white,
|
|
118
|
+
display: 'inline-block',
|
|
119
|
+
maxWidth: TOOLTIP_LABELS_MAX_WIDTH,
|
|
120
|
+
overflow: 'hidden',
|
|
121
|
+
textOverflow: 'ellipsis',
|
|
122
|
+
whiteSpace: wrapLabels ? 'normal' : 'nowrap',
|
|
123
|
+
width: 'calc(100% - 20px)'
|
|
124
|
+
}),
|
|
125
|
+
children: inlineSeriesLabels
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
130
|
+
sx: {
|
|
131
|
+
display: 'table-cell',
|
|
132
|
+
fontWeight: '700',
|
|
133
|
+
paddingLeft: 1.5,
|
|
134
|
+
textAlign: 'right',
|
|
135
|
+
verticalAlign: 'top'
|
|
136
|
+
},
|
|
137
|
+
children: formattedY
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=SeriesInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Tooltip/SeriesInfo.tsx"],"sourcesContent":["// Copyright 2022 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 { Box, Divider, Stack, Typography } from '@mui/material';\nimport { SeriesMarker } from './SeriesMarker';\nimport { TOOLTIP_LABELS_MAX_WIDTH } from './tooltip-model';\n\ninterface SeriesInfoProps {\n seriesName: string;\n y: number;\n formattedY: string;\n markerColor: string;\n totalSeries: number;\n wrapLabels?: boolean;\n}\n\nexport function SeriesInfo(props: SeriesInfoProps) {\n const { seriesName, formattedY, markerColor, totalSeries, wrapLabels } = props;\n\n // TODO (sjcobb): regex to remove __name__, improve series labels\n const formattedSeriesLabels = seriesName.replace(/[{}\"]/g, '');\n\n if (totalSeries === 1) {\n const jsonFormattedSeries = seriesName[0] === '{' ? true : false;\n return (\n <Stack spacing={0.5}>\n <Box\n sx={(theme) => ({\n height: '16px',\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'left',\n color: theme.palette.common.white,\n fontSize: '11px',\n })}\n >\n <SeriesMarker markerColor={markerColor} />\n <Box component=\"span\">\n value:\n <Box\n component=\"span\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n fontWeight: 700,\n paddingLeft: '2px',\n })}\n >\n {formattedY}\n </Box>\n </Box>\n </Box>\n <Divider\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n })}\n />\n <Box\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedSeriesLabels.split(',').map((name) => {\n if (name) {\n const [key, value] = jsonFormattedSeries ? name.split(':') : name.split('=');\n const formattedKey = value !== undefined ? `${key}: ` : key;\n return (\n <Box key={name} sx={{ display: 'flex', gap: '4px' }}>\n <Typography sx={{ fontSize: '11px' }}>{formattedKey}</Typography>\n <Typography\n sx={(theme) => ({\n color: theme.palette.common.white,\n fontWeight: 700,\n fontSize: '11px',\n })}\n >\n {value}\n </Typography>\n </Box>\n );\n }\n })}\n </Box>\n </Stack>\n );\n }\n\n const inlineSeriesLabels = formattedSeriesLabels.replace(/[,]/g, ', ').replace(/[:=]/g, ': ');\n return (\n <Box\n sx={{\n display: 'table-row',\n paddingTop: 0.5,\n }}\n >\n <Box\n sx={{\n display: 'table-cell',\n maxWidth: '520px',\n }}\n >\n <SeriesMarker markerColor={markerColor} />\n <Box\n component=\"span\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n display: 'inline-block',\n maxWidth: TOOLTIP_LABELS_MAX_WIDTH,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: wrapLabels ? 'normal' : 'nowrap',\n width: 'calc(100% - 20px)',\n })}\n >\n {inlineSeriesLabels}\n </Box>\n </Box>\n <Box\n sx={{\n display: 'table-cell',\n fontWeight: '700',\n paddingLeft: 1.5,\n textAlign: 'right',\n verticalAlign: 'top',\n }}\n >\n {formattedY}\n </Box>\n </Box>\n );\n}\n"],"names":["Box","Divider","Stack","Typography","SeriesMarker","TOOLTIP_LABELS_MAX_WIDTH","SeriesInfo","props","seriesName","formattedY","markerColor","totalSeries","wrapLabels","formattedSeriesLabels","replace","jsonFormattedSeries","spacing","sx","theme","height","display","flexDirection","alignItems","justifyContent","color","palette","common","white","fontSize","component","fontWeight","paddingLeft","borderColor","grey","split","map","name","key","value","formattedKey","undefined","gap","inlineSeriesLabels","paddingTop","maxWidth","overflow","textOverflow","whiteSpace","width","textAlign","verticalAlign"],"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;AAAA,SAASA,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAChE,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAC9C,SAASC,wBAAwB,QAAQ,iBAAiB,CAAC;AAW3D,OAAO,SAASC,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,UAAU,CAAA,EAAEC,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAEC,WAAW,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGL,KAAK,AAAC;IAE/E,iEAAiE;IACjE,MAAMM,qBAAqB,GAAGL,UAAU,CAACM,OAAO,WAAW,EAAE,CAAC,AAAC;IAE/D,IAAIH,WAAW,KAAK,CAAC,EAAE;QACrB,MAAMI,mBAAmB,GAAGP,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,IAAI,GAAG,KAAK,AAAC;QACjE,qBACE,MAACN,KAAK;YAACc,OAAO,EAAE,GAAG;;8BACjB,MAAChB,GAAG;oBACFiB,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;4BACdC,MAAM,EAAE,MAAM;4BACdC,OAAO,EAAE,MAA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CoC,KAAK,EAAE,mBAAmB;6BAC3B,CAAA,AAAC;kCAEDN,kBAAkB;sBACf;;cACF;0BACN,KAAC1C,GAAG;gBACFiB,EAAE,EAAE;oBACFG,OAAO,EAAE,YAAY;oBACrBU,UAAU,EAAE,KAAK;oBACjBC,WAAW,EAAE,GAAG;oBAChBkB,SAAS,EAAE,OAAO;oBAClBC,aAAa,EAAE,KAAK;iBACrB;0BAEAzC,UAAU;cACP;;MACF,CACN;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeriesMarker.d.ts","sourceRoot":"","sources":["../../src/Tooltip/SeriesMarker.tsx"],"names":[],"mappings":";AAeA,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAgBpD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2022 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 { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { Box } from '@mui/material';
|
|
15
|
+
export function SeriesMarker(props) {
|
|
16
|
+
const { markerColor } = props;
|
|
17
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
18
|
+
sx: {
|
|
19
|
+
display: 'inline-block',
|
|
20
|
+
width: '12px',
|
|
21
|
+
borderRadius: '2px',
|
|
22
|
+
height: '12px',
|
|
23
|
+
marginTop: 0.25,
|
|
24
|
+
marginRight: 1,
|
|
25
|
+
verticalAlign: 'top'
|
|
26
|
+
},
|
|
27
|
+
style: {
|
|
28
|
+
backgroundColor: markerColor
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=SeriesMarker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Tooltip/SeriesMarker.tsx"],"sourcesContent":["// Copyright 2022 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 { Box } from '@mui/material';\n\ninterface SeriesMarkerProps {\n markerColor: string;\n}\n\nexport function SeriesMarker(props: SeriesMarkerProps) {\n const { markerColor } = props;\n return (\n <Box\n sx={{\n display: 'inline-block',\n width: '12px',\n borderRadius: '2px',\n height: '12px',\n marginTop: 0.25,\n marginRight: 1,\n verticalAlign: 'top',\n }}\n style={{ backgroundColor: markerColor }}\n ></Box>\n );\n}\n"],"names":["Box","SeriesMarker","props","markerColor","sx","display","width","borderRadius","height","marginTop","marginRight","verticalAlign","style","backgroundColor"],"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;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AAMpC,OAAO,SAASC,YAAY,CAACC,KAAwB,EAAE;IACrD,MAAM,EAAEC,WAAW,CAAA,EAAE,GAAGD,KAAK,AAAC;IAC9B,qBACE,KAACF,GAAG;QACFI,EAAE,EAAE;YACFC,OAAO,EAAE,cAAc;YACvBC,KAAK,EAAE,MAAM;YACbC,YAAY,EAAE,KAAK;YACnBC,MAAM,EAAE,MAAM;YACdC,SAAS,EAAE,IAAI;YACfC,WAAW,EAAE,CAAC;YACdC,aAAa,EAAE,KAAK;SACrB;QACDC,KAAK,EAAE;YAAEC,eAAe,EAAEV,WAAW;SAAE;MAClC,CACP;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ECharts as EChartsInstance } from 'echarts/core';
|
|
3
|
+
import { EChartsDataFormat, UnitOptions } from '../model';
|
|
4
|
+
interface TooltipProps {
|
|
5
|
+
chartRef: React.MutableRefObject<EChartsInstance | undefined>;
|
|
6
|
+
chartData: EChartsDataFormat;
|
|
7
|
+
pinTooltip: boolean;
|
|
8
|
+
wrapLabels?: boolean;
|
|
9
|
+
unit?: UnitOptions;
|
|
10
|
+
}
|
|
11
|
+
declare const Tooltip: React.NamedExoticComponent<TooltipProps>;
|
|
12
|
+
export { Tooltip };
|
|
13
|
+
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAM1D,UAAU,YAAY;IACpB,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,QAAA,MAAM,OAAO,0CAqDX,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright 2022 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 { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import React, { useState } from 'react';
|
|
15
|
+
import { Box, Portal } from '@mui/material';
|
|
16
|
+
import { getFocusedSeriesData } from './focused-series';
|
|
17
|
+
import { TOOLTIP_MAX_HEIGHT, TOOLTIP_MAX_WIDTH, useMousePosition } from './tooltip-model';
|
|
18
|
+
import { TooltipContent } from './TooltipContent';
|
|
19
|
+
import { assembleTransform } from './utils';
|
|
20
|
+
const Tooltip = /*#__PURE__*/ React.memo(function Tooltip({ chartRef , chartData , wrapLabels , pinTooltip , unit }) {
|
|
21
|
+
const [pinnedPos, setPinnedPos] = useState(null);
|
|
22
|
+
const mousePos = useMousePosition();
|
|
23
|
+
if (mousePos === null || mousePos.target === null) return null;
|
|
24
|
+
// ensure user is hovering over a chart before checking for nearby series
|
|
25
|
+
if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
|
|
26
|
+
const chart = chartRef.current;
|
|
27
|
+
const focusedSeries = getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit);
|
|
28
|
+
var ref;
|
|
29
|
+
const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : 750;
|
|
30
|
+
var ref1;
|
|
31
|
+
const chartHeight = (ref1 = chart === null || chart === void 0 ? void 0 : chart.getHeight()) !== null && ref1 !== void 0 ? ref1 : 230;
|
|
32
|
+
const cursorTransform = assembleTransform(mousePos, focusedSeries.length, chartWidth, chartHeight, pinnedPos);
|
|
33
|
+
if (focusedSeries.length === 0) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (pinTooltip === true && pinnedPos === null) {
|
|
37
|
+
setPinnedPos(mousePos);
|
|
38
|
+
}
|
|
39
|
+
return /*#__PURE__*/ _jsx(Portal, {
|
|
40
|
+
children: /*#__PURE__*/ _jsx(Box, {
|
|
41
|
+
sx: (theme)=>({
|
|
42
|
+
maxWidth: TOOLTIP_MAX_WIDTH,
|
|
43
|
+
maxHeight: TOOLTIP_MAX_HEIGHT,
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
top: 0,
|
|
46
|
+
left: 0,
|
|
47
|
+
backgroundColor: '#2E313E',
|
|
48
|
+
borderRadius: '6px',
|
|
49
|
+
color: '#fff',
|
|
50
|
+
fontSize: '11px',
|
|
51
|
+
visibility: 'visible',
|
|
52
|
+
opacity: 1,
|
|
53
|
+
transition: 'all 0.1s ease-out',
|
|
54
|
+
zIndex: theme.zIndex.tooltip,
|
|
55
|
+
overflow: 'hidden',
|
|
56
|
+
'&:hover': {
|
|
57
|
+
overflowY: 'auto'
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
style: {
|
|
61
|
+
transform: cursorTransform
|
|
62
|
+
},
|
|
63
|
+
children: /*#__PURE__*/ _jsx(TooltipContent, {
|
|
64
|
+
focusedSeries: focusedSeries,
|
|
65
|
+
wrapLabels: wrapLabels
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
export { Tooltip };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Tooltip/Tooltip.tsx"],"sourcesContent":["// Copyright 2022 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 React, { useState } from 'react';\nimport { Box, Portal } from '@mui/material';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { EChartsDataFormat, UnitOptions } from '../model';\nimport { getFocusedSeriesData } from './focused-series';\nimport { CursorCoordinates, TOOLTIP_MAX_HEIGHT, TOOLTIP_MAX_WIDTH, useMousePosition } from './tooltip-model';\nimport { TooltipContent } from './TooltipContent';\nimport { assembleTransform } from './utils';\n\ninterface TooltipProps {\n chartRef: React.MutableRefObject<EChartsInstance | undefined>;\n chartData: EChartsDataFormat;\n pinTooltip: boolean;\n wrapLabels?: boolean;\n unit?: UnitOptions;\n}\n\nconst Tooltip = React.memo(function Tooltip({ chartRef, chartData, wrapLabels, pinTooltip, unit }: TooltipProps) {\n const [pinnedPos, setPinnedPos] = useState<CursorCoordinates | null>(null);\n const mousePos = useMousePosition();\n\n if (mousePos === null || mousePos.target === null) return null;\n\n // ensure user is hovering over a chart before checking for nearby series\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n const chart = chartRef.current;\n const focusedSeries = getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit);\n const chartWidth = chart?.getWidth() ?? 750;\n const chartHeight = chart?.getHeight() ?? 230;\n const cursorTransform = assembleTransform(mousePos, focusedSeries.length, chartWidth, chartHeight, pinnedPos);\n\n if (focusedSeries.length === 0) {\n return null;\n }\n\n if (pinTooltip === true && pinnedPos === null) {\n setPinnedPos(mousePos);\n }\n\n return (\n <Portal>\n <Box\n sx={(theme) => ({\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: TOOLTIP_MAX_HEIGHT,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: '#2E313E', // TODO: use colors from theme, separate styles for dark mode\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n zIndex: theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n })}\n style={{\n transform: cursorTransform,\n }}\n >\n <TooltipContent focusedSeries={focusedSeries} wrapLabels={wrapLabels} />\n </Box>\n </Portal>\n );\n});\n\nexport { Tooltip };\n"],"names":["React","useState","Box","Portal","getFocusedSeriesData","TOOLTIP_MAX_HEIGHT","TOOLTIP_MAX_WIDTH","useMousePosition","TooltipContent","assembleTransform","Tooltip","memo","chartRef","chartData","wrapLabels","pinTooltip","unit","pinnedPos","setPinnedPos","mousePos","target","tagName","chart","current","focusedSeries","chartWidth","getWidth","chartHeight","getHeight","cursorTransform","length","sx","theme","maxWidth","maxHeight","position","top","left","backgroundColor","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY","style","transform"],"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;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO,CAAC;AACxC,SAASC,GAAG,EAAEC,MAAM,QAAQ,eAAe,CAAC;AAG5C,SAASC,oBAAoB,QAAQ,kBAAkB,CAAC;AACxD,SAA4BC,kBAAkB,EAAEC,iBAAiB,EAAEC,gBAAgB,QAAQ,iBAAiB,CAAC;AAC7G,SAAS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a,CAACM,MAAM,EAAEL,UAAU,EAAEE,WAAW,EAAEV,SAAS,CAAC,AAAC;IAE9G,IAAIO,aAAa,CAACM,MAAM,KAAK,CAAC,EAAE;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAIf,UAAU,KAAK,IAAI,IAAIE,SAAS,KAAK,IAAI,EAAE;QAC7CC,YAAY,CAACC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,qBACE,KAAChB,MAAM;kBACL,cAAA,KAACD,GAAG;YACF6B,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;oBACdC,QAAQ,EAAE3B,iBAAiB;oBAC3B4B,SAAS,EAAE7B,kBAAkB;oBAC7B8B,QAAQ,EAAE,UAAU;oBACpBC,GAAG,EAAE,CAAC;oBACNC,IAAI,EAAE,CAAC;oBACPC,eAAe,EAAE,SAAS;oBAC1BC,YAAY,EAAE,KAAK;oBACnBC,KAAK,EAAE,MAAM;oBACbC,QAAQ,EAAE,MAAM;oBAChBC,UAAU,EAAE,SAAS;oBACrBC,OAAO,EAAE,CAAC;oBACVC,UAAU,EAAE,mBAAmB;oBAC/BC,MAAM,EAAEb,KAAK,CAACa,MAAM,CAACC,OAAO;oBAC5BC,QAAQ,EAAE,QAAQ;oBAClB,SAAS,EAAE;wBACTC,SAAS,EAAE,MAAM;qBAClB;iBACF,CAAA,AAAC;YACFC,KAAK,EAAE;gBACLC,SAAS,EAAErB,eAAe;aAC3B;sBAED,cAAA,KAACrB,cAAc;gBAACgB,aAAa,EAAEA,aAAa;gBAAEV,UAAU,EAAEA,UAAU;cAAI;UACpE;MACC,CACT;AACJ,CAAC,CAAC,AAAC;AAEH,SAASJ,OAAO,GAAG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FocusedSeriesArray } from './focused-series';
|
|
3
|
+
interface TooltipContentProps {
|
|
4
|
+
focusedSeries: FocusedSeriesArray | null;
|
|
5
|
+
wrapLabels?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function TooltipContent(props: TooltipContentProps): JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=TooltipContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../src/Tooltip/TooltipContent.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,UAAU,mBAAmB;IAC3B,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAqExD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Copyright 2022 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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { useMemo } from 'react';
|
|
15
|
+
import { Box, Divider, Stack, Typography } from '@mui/material';
|
|
16
|
+
import { SeriesInfo } from './SeriesInfo';
|
|
17
|
+
import { useTimeZone } from '../context/TimeZoneProvider';
|
|
18
|
+
export function TooltipContent(props) {
|
|
19
|
+
const { focusedSeries , wrapLabels } = props;
|
|
20
|
+
const { formatWithUserTimeZone } = useTimeZone();
|
|
21
|
+
const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;
|
|
22
|
+
const formatTimeSeriesHeader = (timeString)=>{
|
|
23
|
+
const date = new Date(timeString);
|
|
24
|
+
const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');
|
|
25
|
+
const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');
|
|
26
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
27
|
+
children: [
|
|
28
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
29
|
+
variant: "caption",
|
|
30
|
+
sx: (theme)=>({
|
|
31
|
+
color: theme.palette.common.white
|
|
32
|
+
}),
|
|
33
|
+
children: formattedDate
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
36
|
+
variant: "caption",
|
|
37
|
+
children: /*#__PURE__*/ _jsx("strong", {
|
|
38
|
+
children: formattedTime
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const sortedFocusedSeries = useMemo(()=>{
|
|
45
|
+
if (focusedSeries === null) return null;
|
|
46
|
+
return focusedSeries.sort((a, b)=>a.y > b.y ? -1 : 1);
|
|
47
|
+
}, [
|
|
48
|
+
focusedSeries
|
|
49
|
+
]);
|
|
50
|
+
if (sortedFocusedSeries !== null && seriesTime !== null) {
|
|
51
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
52
|
+
py: 1,
|
|
53
|
+
px: 1.5,
|
|
54
|
+
spacing: 0.5,
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
57
|
+
variant: "caption",
|
|
58
|
+
children: formatTimeSeriesHeader(seriesTime)
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ _jsx(Divider, {
|
|
61
|
+
sx: (theme)=>({
|
|
62
|
+
borderColor: theme.palette.grey['500']
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
66
|
+
sx: {
|
|
67
|
+
display: 'table'
|
|
68
|
+
},
|
|
69
|
+
children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , formattedY , markerColor })=>{
|
|
70
|
+
if (datumIdx === null || seriesIdx === null) return null;
|
|
71
|
+
const key = seriesIdx.toString() + datumIdx.toString();
|
|
72
|
+
return /*#__PURE__*/ _jsx(SeriesInfo, {
|
|
73
|
+
seriesName: seriesName,
|
|
74
|
+
y: y,
|
|
75
|
+
formattedY: formattedY,
|
|
76
|
+
markerColor: markerColor,
|
|
77
|
+
totalSeries: sortedFocusedSeries.length,
|
|
78
|
+
wrapLabels: wrapLabels
|
|
79
|
+
}, key);
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
return /*#__PURE__*/ _jsx(_Fragment, {});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=TooltipContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Tooltip/TooltipContent.tsx"],"sourcesContent":["// Copyright 2022 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 { useMemo } from 'react';\nimport { Box, Divider, Stack, Typography } from '@mui/material';\nimport { FocusedSeriesArray } from './focused-series';\nimport { SeriesInfo } from './SeriesInfo';\nimport { useTimeZone } from '../context/TimeZoneProvider';\n\ninterface TooltipContentProps {\n focusedSeries: FocusedSeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { focusedSeries, wrapLabels } = props;\n const { formatWithUserTimeZone } = useTimeZone();\n\n const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;\n\n const formatTimeSeriesHeader = (timeString: string) => {\n const date = new Date(timeString);\n const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');\n const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');\n\n return (\n <>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedDate}\n </Typography>\n <Typography variant=\"caption\">\n <strong>{formattedTime}</strong>\n </Typography>\n </>\n );\n };\n\n const sortedFocusedSeries = useMemo(() => {\n if (focusedSeries === null) return null;\n return focusedSeries.sort((a, b) => (a.y > b.y ? -1 : 1));\n }, [focusedSeries]);\n\n if (sortedFocusedSeries !== null && seriesTime !== null) {\n return (\n <Stack py={1} px={1.5} spacing={0.5}>\n <Typography variant=\"caption\">{formatTimeSeriesHeader(seriesTime)}</Typography>\n <Divider\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n })}\n />\n <Box\n sx={{\n display: 'table',\n }}\n >\n {sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor }) => {\n if (datumIdx === null || seriesIdx === null) return null;\n const key = seriesIdx.toString() + datumIdx.toString();\n\n return (\n <SeriesInfo\n key={key}\n seriesName={seriesName}\n y={y}\n formattedY={formattedY}\n markerColor={markerColor}\n totalSeries={sortedFocusedSeries.length}\n wrapLabels={wrapLabels}\n />\n );\n })}\n </Box>\n </Stack>\n );\n } else {\n return <></>;\n }\n}\n"],"names":["useMemo","Box","Divider","Stack","Typography","SeriesInfo","useTimeZone","TooltipContent","props","focusedSeries","wrapLabels","formatWithUserTimeZone","seriesTime","date","formatTimeSeriesHeader","timeString","Date","formattedDate","formattedTime","variant","sx","theme","color","palette","common","white","strong","sortedFocusedSeries","sort","a","b","y","py","px","spacing","borderColor","grey","display","map","datumIdx","seriesIdx","seriesName","formattedY","markerColor","key","toString","totalSeries","length"],"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;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAEhE,SAASC,UAAU,QAAQ,cAAc,CAAC;AAC1C,SAASC,WAAW,QAAQ,6BAA6B,CAAC;AAO1D,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,aAAa,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGF,KAAK,AAAC;IAC5C,MAAM,EAAEG,sBAAsB,CAAA,EAAE,GAAGL,WAAW,EAAE,AAAC;IAEjD,MAAMM,UAAU,GAAGH,aAAa,IAAIA,aAAa,CAAC,CAAC,CAAC,IAAIA,aAAa,CAAC,CAAC,CAAC,CAACI,IAAI,GAAGJ,aAAa,CAAC,CAAC,CAAC,CAACI,IAAI,GAAG,IAAI,AAAC;IAE7G,MAAMC,sBAAsB,GAAG,CAACC,UAAkB,GAAK;QACrD,MAAMF,IAAI,GAAG,IAAIG,IAAI,CAACD,UAAU,CAAC,AAAC;QAClC,MAAME,aAAa,GAAGN,sBAAsB,CAACE,IAAI,EAAE,iBAAiB,CAAC,AAAC;QACtE,MAAMK,aAAa,GAAGP,sBAAsB,CAACE,IAAI,EAAE,UAAU,CAAC,AAAC;QAE/D,qBACE;;8BACE,KAACT,UAAU;oBACTe,OAAO,EAAC,SAAS;oBACjBC,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;4BACdC,KAAK,EAAED,KAAK,CAACE,OAAO,CAACC,MAAM,CAACC,KAAK;yBAClC,CAAA,AAAC;8BAEDR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SAAS,CAACK,QAAQ,EAAE,GAAGN,QAAQ,CAACM,QAAQ,EAAE,AAAC;wBAEvD,qBACE,KAACxC,UAAU;4BAEToC,UAAU,EAAEA,UAAU;4BACtBV,CAAC,EAAEA,CAAC;4BACJW,UAAU,EAAEA,UAAU;4BACtBC,WAAW,EAAEA,WAAW;4BACxBG,WAAW,EAAEnB,mBAAmB,CAACoB,MAAM;4BACvCrC,UAAU,EAAEA,UAAU;2BANjBkC,GAAG,CAOR,CACF;oBACJ,CAAC,CAAC;kBACE;;UACA,CACR;IACJ,OAAO;QACL,qBAAO,mBAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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: string;
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focused-series.d.ts","sourceRoot":"","sources":["../../src/Tooltip/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,EAA0C,MAAM,iBAAiB,CAAC;AAErF,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"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright 2022 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_DATE_FORMAT, 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
|
+
var _datumIdx1;
|
|
40
|
+
const yValue = (_datumIdx1 = currentSeries.data[datumIdx]) !== null && _datumIdx1 !== void 0 ? _datumIdx1 : 0;
|
|
41
|
+
if (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 formattedDate = TOOLTIP_DATE_FORMAT.format(xValueMilliSeconds);
|
|
46
|
+
const formattedY = formatValue(yValue, unit);
|
|
47
|
+
currentFocusedData.push({
|
|
48
|
+
seriesIdx: seriesIdx,
|
|
49
|
+
datumIdx: datumIdx,
|
|
50
|
+
seriesName: currentSeriesName,
|
|
51
|
+
date: formattedDate,
|
|
52
|
+
x: xValue,
|
|
53
|
+
y: yValue,
|
|
54
|
+
formattedY: formattedY,
|
|
55
|
+
markerColor: markerColor.toString()
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return currentFocusedData;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Uses mouse position to determine whether user is hovering over a chart canvas
|
|
68
|
+
* If yes, convert from pixel values to logical cartesian coordinates and return all focused series
|
|
69
|
+
*/ export function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit) {
|
|
70
|
+
if (chart === undefined || mousePos === null) return [];
|
|
71
|
+
// prevents multiple tooltips showing from adjacent charts
|
|
72
|
+
let cursorTargetMatchesChart = false;
|
|
73
|
+
if (mousePos.target !== null) {
|
|
74
|
+
const currentParent = mousePos.target.parentElement;
|
|
75
|
+
if (currentParent !== null) {
|
|
76
|
+
const currentGrandparent = currentParent.parentElement;
|
|
77
|
+
if (currentGrandparent !== null) {
|
|
78
|
+
const chartDom = chart.getDom();
|
|
79
|
+
if (chartDom === currentGrandparent) {
|
|
80
|
+
cursorTargetMatchesChart = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// allows moving cursor inside tooltip
|
|
86
|
+
if (pinnedPos !== null) {
|
|
87
|
+
mousePos = pinnedPos;
|
|
88
|
+
cursorTargetMatchesChart = true;
|
|
89
|
+
}
|
|
90
|
+
if (cursorTargetMatchesChart === false) return [];
|
|
91
|
+
if (chart['_model'] === undefined) return [];
|
|
92
|
+
const chartModel = chart['_model'];
|
|
93
|
+
const yAxisInterval = chartModel.getComponent('yAxis').axis.scale._interval;
|
|
94
|
+
const seriesNum = chartData.timeSeries.length;
|
|
95
|
+
// tooltip trigger area gets smaller with more series
|
|
96
|
+
const yBuffer = seriesNum > TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 2;
|
|
97
|
+
var _x, _y;
|
|
98
|
+
const pointInPixel = [
|
|
99
|
+
(_x = mousePos.plotCanvas.x) !== null && _x !== void 0 ? _x : 0,
|
|
100
|
+
(_y = mousePos.plotCanvas.y) !== null && _y !== void 0 ? _y : 0
|
|
101
|
+
];
|
|
102
|
+
if (chart.containPixel('grid', pointInPixel)) {
|
|
103
|
+
const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
|
|
104
|
+
if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
|
|
105
|
+
return getNearbySeries(chartData, pointInGrid, yBuffer, unit);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=focused-series.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Tooltip/focused-series.ts"],"sourcesContent":["// Copyright 2022 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_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';\n\nexport interface FocusedSeriesInfo {\n seriesIdx: number | null;\n datumIdx: number | null;\n seriesName: string;\n date: string;\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] ?? 0;\n if (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 formattedDate = TOOLTIP_DATE_FORMAT.format(xValueMilliSeconds);\n const formattedY = formatValue(yValue, unit);\n currentFocusedData.push({\n seriesIdx: seriesIdx,\n datumIdx: datumIdx,\n seriesName: currentSeriesName,\n date: formattedDate,\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 const seriesNum = chartData.timeSeries.length;\n // tooltip trigger area gets smaller with more series\n const yBuffer = seriesNum > TOOLTIP_MAX_ITEMS ? yAxisInterval * 0.5 : yAxisInterval * 2;\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_DATE_FORMAT","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","formattedDate","format","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,mBAAmB,EAAEC,iBAAiB,QAAQ,iBAAiB,CAAC;AAerF;;;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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