@perses-dev/components 0.15.0 → 0.17.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.
Files changed (138) hide show
  1. package/dist/LineChart/LineChart.d.ts +3 -2
  2. package/dist/LineChart/LineChart.d.ts.map +1 -1
  3. package/dist/LineChart/LineChart.js +6 -16
  4. package/dist/LineChart/LineChart.js.map +1 -1
  5. package/dist/LineChart/utils.d.ts +18 -0
  6. package/dist/LineChart/utils.d.ts.map +1 -1
  7. package/dist/LineChart/utils.js +35 -9
  8. package/dist/LineChart/utils.js.map +1 -1
  9. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts +13 -0
  10. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts.map +1 -0
  11. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +28 -0
  12. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -0
  13. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts +5 -0
  14. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -0
  15. package/dist/OptionsEditorLayout/OptionsEditorControl.js +50 -0
  16. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -0
  17. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts +13 -0
  18. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts.map +1 -0
  19. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +26 -0
  20. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -0
  21. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +13 -0
  22. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -0
  23. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +36 -0
  24. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -0
  25. package/dist/OptionsEditorLayout/index.d.ts +5 -0
  26. package/dist/OptionsEditorLayout/index.d.ts.map +1 -0
  27. package/dist/OptionsEditorLayout/index.js +18 -0
  28. package/dist/OptionsEditorLayout/index.js.map +1 -0
  29. package/dist/Tooltip/SeriesInfo.d.ts +1 -0
  30. package/dist/Tooltip/SeriesInfo.d.ts.map +1 -1
  31. package/dist/Tooltip/SeriesInfo.js +3 -3
  32. package/dist/Tooltip/SeriesInfo.js.map +1 -1
  33. package/dist/Tooltip/Tooltip.d.ts +2 -1
  34. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  35. package/dist/Tooltip/Tooltip.js +2 -2
  36. package/dist/Tooltip/Tooltip.js.map +1 -1
  37. package/dist/Tooltip/TooltipContent.d.ts.map +1 -1
  38. package/dist/Tooltip/TooltipContent.js +2 -1
  39. package/dist/Tooltip/TooltipContent.js.map +1 -1
  40. package/dist/Tooltip/focused-series.d.ts +4 -3
  41. package/dist/Tooltip/focused-series.d.ts.map +1 -1
  42. package/dist/Tooltip/focused-series.js +6 -3
  43. package/dist/Tooltip/focused-series.js.map +1 -1
  44. package/dist/Tooltip/focused-series.test.js +20 -2
  45. package/dist/Tooltip/focused-series.test.js.map +1 -1
  46. package/dist/UnitSelector/UnitSelector.d.ts +8 -0
  47. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -0
  48. package/dist/UnitSelector/UnitSelector.js +112 -0
  49. package/dist/UnitSelector/UnitSelector.js.map +1 -0
  50. package/dist/UnitSelector/UnitSelector.test.d.ts +2 -0
  51. package/dist/UnitSelector/UnitSelector.test.d.ts.map +1 -0
  52. package/dist/UnitSelector/UnitSelector.test.js +211 -0
  53. package/dist/UnitSelector/UnitSelector.test.js.map +1 -0
  54. package/dist/UnitSelector/index.d.ts +2 -0
  55. package/dist/UnitSelector/index.d.ts.map +1 -0
  56. package/dist/UnitSelector/index.js +15 -0
  57. package/dist/UnitSelector/index.js.map +1 -0
  58. package/dist/YAxisLabel.d.ts +8 -0
  59. package/dist/YAxisLabel.d.ts.map +1 -0
  60. package/dist/YAxisLabel.js +39 -0
  61. package/dist/YAxisLabel.js.map +1 -0
  62. package/dist/cjs/LineChart/LineChart.js +5 -15
  63. package/dist/cjs/LineChart/utils.js +23 -1
  64. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +32 -0
  65. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +61 -0
  66. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +29 -0
  67. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +40 -0
  68. package/dist/cjs/OptionsEditorLayout/index.js +31 -0
  69. package/dist/cjs/Tooltip/SeriesInfo.js +3 -3
  70. package/dist/cjs/Tooltip/Tooltip.js +2 -2
  71. package/dist/cjs/Tooltip/TooltipContent.js +2 -1
  72. package/dist/cjs/Tooltip/focused-series.js +6 -3
  73. package/dist/cjs/Tooltip/focused-series.test.js +20 -2
  74. package/dist/cjs/UnitSelector/UnitSelector.js +118 -0
  75. package/dist/cjs/UnitSelector/UnitSelector.test.js +218 -0
  76. package/dist/cjs/UnitSelector/index.js +28 -0
  77. package/dist/cjs/YAxisLabel.js +45 -0
  78. package/dist/cjs/index.js +5 -2
  79. package/dist/cjs/model/units/bytes.js +60 -0
  80. package/dist/cjs/model/units/constants.js +23 -0
  81. package/dist/cjs/model/units/decimal.js +67 -0
  82. package/dist/cjs/model/units/index.js +30 -0
  83. package/dist/cjs/model/units/percent.js +64 -0
  84. package/dist/cjs/model/units/time.js +138 -0
  85. package/dist/cjs/model/units/types.js +28 -0
  86. package/dist/cjs/model/units/units.js +104 -0
  87. package/dist/cjs/utils/component-ids.js +31 -0
  88. package/dist/cjs/utils/index.js +1 -0
  89. package/dist/index.d.ts +5 -2
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +5 -2
  92. package/dist/index.js.map +1 -1
  93. package/dist/model/units/bytes.d.ts +12 -0
  94. package/dist/model/units/bytes.d.ts.map +1 -0
  95. package/dist/model/units/bytes.js +48 -0
  96. package/dist/model/units/bytes.js.map +1 -0
  97. package/dist/model/units/constants.d.ts +2 -0
  98. package/dist/model/units/constants.d.ts.map +1 -0
  99. package/dist/model/units/constants.js +17 -0
  100. package/dist/model/units/constants.js.map +1 -0
  101. package/dist/model/units/decimal.d.ts +24 -0
  102. package/dist/model/units/decimal.d.ts.map +1 -0
  103. package/dist/model/units/decimal.js +59 -0
  104. package/dist/model/units/decimal.js.map +1 -0
  105. package/dist/model/units/index.d.ts +4 -0
  106. package/dist/model/units/index.d.ts.map +1 -0
  107. package/dist/model/units/index.js +17 -0
  108. package/dist/model/units/index.js.map +1 -0
  109. package/dist/model/units/percent.d.ts +12 -0
  110. package/dist/model/units/percent.d.ts.map +1 -0
  111. package/dist/model/units/percent.js +51 -0
  112. package/dist/model/units/percent.js.map +1 -0
  113. package/dist/model/units/time.d.ts +11 -0
  114. package/dist/model/units/time.d.ts.map +1 -0
  115. package/dist/model/units/time.js +125 -0
  116. package/dist/model/units/time.js.map +1 -0
  117. package/dist/model/units/types.d.ts +38 -0
  118. package/dist/model/units/types.d.ts.map +1 -0
  119. package/dist/model/units/types.js +22 -0
  120. package/dist/model/units/types.js.map +1 -0
  121. package/dist/model/units/units.d.ts +40 -0
  122. package/dist/model/units/units.d.ts.map +1 -0
  123. package/dist/model/units/units.js +83 -0
  124. package/dist/model/units/units.js.map +1 -0
  125. package/dist/utils/component-ids.d.ts +8 -0
  126. package/dist/utils/component-ids.d.ts.map +1 -0
  127. package/dist/utils/component-ids.js +27 -0
  128. package/dist/utils/component-ids.js.map +1 -0
  129. package/dist/utils/index.d.ts +1 -0
  130. package/dist/utils/index.d.ts.map +1 -1
  131. package/dist/utils/index.js +1 -0
  132. package/dist/utils/index.js.map +1 -1
  133. package/package.json +2 -2
  134. package/dist/cjs/model/units.js +0 -203
  135. package/dist/model/units.d.ts +0 -36
  136. package/dist/model/units.d.ts.map +0 -1
  137. package/dist/model/units.js +0 -196
  138. package/dist/model/units.js.map +0 -1
@@ -15,7 +15,7 @@ import { Box, Divider, Stack, Typography } from '@mui/material';
15
15
  import { SeriesMarker } from './SeriesMarker';
16
16
  import { TOOLTIP_LABELS_MAX_WIDTH } from './tooltip-model';
17
17
  export function SeriesInfo(props) {
18
- const { seriesName , y , markerColor , totalSeries , wrapLabels } = props;
18
+ const { seriesName , formattedY , markerColor , totalSeries , wrapLabels } = props;
19
19
  // TODO (sjcobb): regex to remove __name__, improve series labels
20
20
  const formattedSeriesLabels = seriesName.replace(/[{}"]/g, '');
21
21
  if (totalSeries === 1) {
@@ -48,7 +48,7 @@ export function SeriesInfo(props) {
48
48
  fontWeight: 700,
49
49
  paddingLeft: '2px'
50
50
  }),
51
- children: y
51
+ children: formattedY
52
52
  })
53
53
  ]
54
54
  })
@@ -134,7 +134,7 @@ export function SeriesInfo(props) {
134
134
  textAlign: 'right',
135
135
  verticalAlign: 'top'
136
136
  },
137
- children: y
137
+ children: formattedY
138
138
  })
139
139
  ]
140
140
  });
@@ -1 +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 markerColor: string;\n totalSeries: number;\n wrapLabels?: boolean;\n}\n\nexport function SeriesInfo(props: SeriesInfoProps) {\n const { seriesName, y, 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 {y}\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 {y}\n </Box>\n </Box>\n );\n}\n"],"names":["Box","Divider","Stack","Typography","SeriesMarker","TOOLTIP_LABELS_MAX_WIDTH","SeriesInfo","props","seriesName","y","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;AAU3D,OAAO,SAASC,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,UAAU,CAAA,EAAEC,CAAC,CAAA,EAAEC,WAAW,CAAA,EAAEC,WAAW,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGL,KAAK,AAAC;IAEtE,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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nC,UAAU,GAAG,QAAQ,GAAG,QAAQ;gCAC5CoC,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,CAAC;cACE;;MACF,CACN;AACJ,CAAC"}
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,MAAM;4BACfC,aAAa,EAAE,KAAK;4BACpBC,UAAU,EAAE,QAAQ;4BACpBC,cAAc,EAAE,MAAM;4BACtBC,KAAK,EAAEN,KAAK,CAACO,O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BACFG,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"}
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
2
  import { ECharts as EChartsInstance } from 'echarts/core';
3
- import { EChartsDataFormat } from '../model/graph';
3
+ import { EChartsDataFormat, UnitOptions } from '../model';
4
4
  interface TooltipProps {
5
5
  chartRef: React.MutableRefObject<EChartsInstance | undefined>;
6
6
  chartData: EChartsDataFormat;
7
7
  pinTooltip: boolean;
8
8
  wrapLabels?: boolean;
9
+ unit?: UnitOptions;
9
10
  }
10
11
  declare const Tooltip: React.NamedExoticComponent<TooltipProps>;
11
12
  export { Tooltip };
@@ -1 +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,MAAM,gBAAgB,CAAC;AAMnD,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;CACtB;AAED,QAAA,MAAM,OAAO,0CAqDX,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,CAAC"}
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"}
@@ -17,14 +17,14 @@ import { getFocusedSeriesData } from './focused-series';
17
17
  import { TOOLTIP_MAX_HEIGHT, TOOLTIP_MAX_WIDTH, useMousePosition } from './tooltip-model';
18
18
  import { TooltipContent } from './TooltipContent';
19
19
  import { assembleTransform } from './utils';
20
- const Tooltip = /*#__PURE__*/ React.memo(function Tooltip({ chartRef , chartData , wrapLabels , pinTooltip }) {
20
+ const Tooltip = /*#__PURE__*/ React.memo(function Tooltip({ chartRef , chartData , wrapLabels , pinTooltip , unit }) {
21
21
  const [pinnedPos, setPinnedPos] = useState(null);
22
22
  const mousePos = useMousePosition();
23
23
  if (mousePos === null || mousePos.target === null) return null;
24
24
  // ensure user is hovering over a chart before checking for nearby series
25
25
  if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
26
26
  const chart = chartRef.current;
27
- const focusedSeries = getFocusedSeriesData(mousePos, chartData, pinnedPos, chart);
27
+ const focusedSeries = getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit);
28
28
  var ref;
29
29
  const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : 750;
30
30
  var ref1;
@@ -1 +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 } from '../model/graph';\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}\n\nconst Tooltip = React.memo(function Tooltip({ chartRef, chartData, wrapLabels, pinTooltip }: 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);\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","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,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAClD,SAASC,iBAAiB,QAAQ,SAAS,CAAC;AAS5C,MAAMC,OAAO,iBAAGV,KAAK,CAACW,IAAI,CAAC,SAASD,OAAO,CAAC,EAAEE,QAAQ,CAAA,EAAEC,SAAS,CAAA,EAAEC,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YAAY,CAACC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,qBACE,KAACf,MAAM;kBACL,cAAA,KAACD,GAAG;YACF4B,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;oBACdC,QAAQ,EAAE1B,iBAAiB;oBAC3B2B,SAAS,EAAE5B,kBAAkB;oBAC7B6B,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,KAACpB,cAAc;gBAACe,aAAa,EAAEA,aAAa;gBAAET,UAAU,EAAEA,UAAU;cAAI;UACpE;MACC,CACT;AACJ,CAAC,CAAC,AAAC;AAEH,SAASJ,OAAO,GAAG"}
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,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAClD,SAASC,iBAAiB,QAAQ,SAAS,CAAC;AAU5C,MAAMC,OAAO,iBAAGV,KAAK,CAACW,IAAI,CAAC,SAASD,OAAO,CAAC,EAAEE,QAAQ,CAAA,EAAEC,SAAS,CAAA,EAAEC,UAAU,CAAA,EAAEC,UAAU,CAAA,EAAEC,IAAI,CAAA,EAAgB,EAAE;IAC/G,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGjB,QAAQ,CAA2B,IAAI,CAAC,AAAC;IAC3E,MAAMkB,QAAQ,GAAGZ,gBAAgB,EAAE,AAAC;IAEpC,IAAIY,QAAQ,KAAK,IAAI,IAAIA,QAAQ,CAACC,MAAM,KAA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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"}
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../src/Tooltip/TooltipContent.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,UAAU,mBAAmB;IAC3B,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAgExD"}
1
+ {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../src/Tooltip/TooltipContent.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,UAAU,mBAAmB;IAC3B,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAiExD"}
@@ -67,12 +67,13 @@ export function TooltipContent(props) {
67
67
  sx: {
68
68
  display: 'table'
69
69
  },
70
- children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , markerColor })=>{
70
+ children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , formattedY , markerColor })=>{
71
71
  if (datumIdx === null || seriesIdx === null) return null;
72
72
  const key = seriesIdx.toString() + datumIdx.toString();
73
73
  return /*#__PURE__*/ _jsx(SeriesInfo, {
74
74
  seriesName: seriesName,
75
75
  y: y,
76
+ formattedY: formattedY,
76
77
  markerColor: markerColor,
77
78
  totalSeries: sortedFocusedSeries.length,
78
79
  wrapLabels: wrapLabels
@@ -1 +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';\n\ninterface TooltipContentProps {\n focusedSeries: FocusedSeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { focusedSeries, wrapLabels } = props;\n\n const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;\n\n const formatTimeSeriesHeader = (timeString: string) => {\n const [month, year, time] = timeString.split(',');\n return (\n <>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {month}, {year} –\n </Typography>\n <Typography variant=\"caption\">\n <strong>{time}</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, 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 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","TooltipContent","props","focusedSeries","wrapLabels","seriesTime","date","formatTimeSeriesHeader","timeString","month","year","time","split","variant","sx","theme","color","palette","common","white","strong","sortedFocusedSeries","sort","a","b","y","py","px","spacing","borderColor","grey","display","map","datumIdx","seriesIdx","seriesName","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;AAO1C,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,aAAa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AG;;8BACjC,KAAC7B,UAAU;oBAACc,OAAO,EAAC,SAAS;8BAAEN,sBAAsB,CAACF,UAAU,CAAC;kBAAc;8BAC/E,KAACR,OAAO;oBACNiB,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;4BACdc,WAAW,EAAEd,KAAK,CAACE,OAAO,CAACa,IAAI,CAAC,KAAK,CAAC;yBACvC,CAAA,AAAC;kBACF;8BACF,KAAClC,GAAG;oBACFkB,EAAE,EAAE;wBACFiB,OAAO,EAAE,OAAO;qBACjB;8BAEAV,mBAAmB,CAACW,GAAG,CAAC,CAAC,EAAEC,QAAQ,CAAA,EAAEC,SAAS,CAAA,EAAEC,UAAU,CAAA,EAAEV,CAAC,CAAA,EAAEW,WAAW,CAAA,EAAE,GAAK;wBAChF,IAAIH,QAAQ,KAAK,IAAI,IAAIC,SAAS,KAAK,IAAI,EAAE,OAAO,IAAI,CAAC;wBACzD,MAAMG,GAAG,GAAGH,SAAS,CAACI,QAAQ,EAAE,GAAGL,QAAQ,CAACK,QAAQ,EAAE,AAAC;wBAEvD,qBACE,KAACtC,UAAU;4BAETmC,UAAU,EAAEA,UAAU;4BACtBV,CAAC,EAAEA,CAAC;4BACJW,WAAW,EAAEA,WAAW;4BACxBG,WAAW,EAAElB,mBAAmB,CAACmB,MAAM;4BACvCpC,UAAU,EAAEA,UAAU;2BALjBiC,GAAG,CAMR,CACF;oBACJ,CAAC,CAAC;kBACE;;UACA,CACR;IACJ,OAAO;QACL,qBAAO,mBAAK,CAAC;IACf,CAAC;AACH,CAAC"}
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';\n\ninterface TooltipContentProps {\n focusedSeries: FocusedSeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { focusedSeries, wrapLabels } = props;\n\n const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;\n\n const formatTimeSeriesHeader = (timeString: string) => {\n const [month, year, time] = timeString.split(',');\n return (\n <>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {month}, {year} –\n </Typography>\n <Typography variant=\"caption\">\n <strong>{time}</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","TooltipContent","props","focusedSeries","wrapLabels","seriesTime","date","formatTimeSeriesHeader","timeString","month","year","time","split","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;AAO1C,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,aAAa,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGF,KAAK,AAAC;IAE5C,MAAMG,UAAU,GAAGF,aAAa,IAAIA,aAAa,CAAC,CAAC,CAAC,IAAIA,aAAa,CAAC,CAAC,CAAC,CAACG,IAAI,GAAGH,aAAa,CAAC,CAAC,CAAC,CAACG,IAAI,GAAG,IAAI,AAAC;IAE7G,MAAMC,sBAAsB,GAAG,CAACC,UAAkB,GAAK;QACrD,MAAM,CAACC,KAAK,EAAEC,IAAI,EAAEC,IAAI,CAAC,GAAGH,UAAU,CAACI,KAAK,CAAC,GAAG,CAAC,AAAC;QAClD,qBACE;;8BACE,MAACb,UAAU;oBACTc,OAAO,EAAC,SAAS;oBACjBC,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;4BACdC,KAAK,EAAED,KAAK,CAACE,OAAO,CAACC,MAAM,CAACC,KAAK;yBAClC,CAAA,AAAC;;wBAEDV,KAAK;wBAAC,IAAE;wBAACC,IAAI;wBAAC,IACjB;;kBAAa;8BACb,KAACX,UAAU;oBAACc,OAAO,EAAC,SAAS;8BAC3B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AC;wBAEvD,qBACE,KAACvC,UAAU;4BAETmC,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"}
@@ -1,5 +1,5 @@
1
1
  import { ECharts as EChartsInstance } from 'echarts/core';
2
- import { EChartsDataFormat } from '../model/graph';
2
+ import { UnitOptions, EChartsDataFormat } from '../model';
3
3
  import { CursorData } from './tooltip-model';
4
4
  export interface FocusedSeriesInfo {
5
5
  seriesIdx: number | null;
@@ -9,16 +9,17 @@ export interface FocusedSeriesInfo {
9
9
  markerColor: string;
10
10
  x: number;
11
11
  y: number;
12
+ formattedY: string;
12
13
  }
13
14
  export declare type FocusedSeriesArray = FocusedSeriesInfo[];
14
15
  /**
15
16
  * Returns formatted series data for the points that are close to the user's cursor
16
17
  * Adjust yBuffer to increase or decrease number of series shown
17
18
  */
18
- export declare function getNearbySeries(data: EChartsDataFormat, pointInGrid: number[], yBuffer: number): FocusedSeriesArray;
19
+ export declare function getNearbySeries(data: EChartsDataFormat, pointInGrid: number[], yBuffer: number, unit?: UnitOptions): FocusedSeriesArray;
19
20
  /**
20
21
  * Uses mouse position to determine whether user is hovering over a chart canvas
21
22
  * If yes, convert from pixel values to logical cartesian coordinates and return all focused series
22
23
  */
23
- export declare function getFocusedSeriesData(mousePos: CursorData['coords'], chartData: EChartsDataFormat, pinnedPos: CursorData['coords'], chart?: EChartsInstance): FocusedSeriesArray;
24
+ export declare function getFocusedSeriesData(mousePos: CursorData['coords'], chartData: EChartsDataFormat, pinnedPos: CursorData['coords'], chart?: EChartsInstance, unit?: UnitOptions): FocusedSeriesArray;
24
25
  //# sourceMappingURL=focused-series.d.ts.map
@@ -1 +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,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,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;CACX;AAED,oBAAY,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;AAErD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,CA0CnH;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,sBA2CxB"}
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"}
@@ -10,11 +10,12 @@
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 { formatValue } from '../model';
13
14
  import { TOOLTIP_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';
14
15
  /**
15
16
  * Returns formatted series data for the points that are close to the user's cursor
16
17
  * Adjust yBuffer to increase or decrease number of series shown
17
- */ export function getNearbySeries(data, pointInGrid, yBuffer) {
18
+ */ export function getNearbySeries(data, pointInGrid, yBuffer, unit) {
18
19
  const currentFocusedData = [];
19
20
  var ref;
20
21
  const focusedX = (ref = pointInGrid[0]) !== null && ref !== void 0 ? ref : null;
@@ -42,6 +43,7 @@ import { TOOLTIP_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';
42
43
  // determine whether to convert timestamp to ms, see: https://stackoverflow.com/a/23982005/17575201
43
44
  const xValueMilliSeconds = xValue > 99999999999 ? xValue : xValue * 1000;
44
45
  const formattedDate = TOOLTIP_DATE_FORMAT.format(xValueMilliSeconds);
46
+ const formattedY = formatValue(yValue, unit);
45
47
  currentFocusedData.push({
46
48
  seriesIdx: seriesIdx,
47
49
  datumIdx: datumIdx,
@@ -49,6 +51,7 @@ import { TOOLTIP_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';
49
51
  date: formattedDate,
50
52
  x: xValue,
51
53
  y: yValue,
54
+ formattedY: formattedY,
52
55
  markerColor: markerColor.toString()
53
56
  });
54
57
  }
@@ -63,7 +66,7 @@ import { TOOLTIP_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';
63
66
  /**
64
67
  * Uses mouse position to determine whether user is hovering over a chart canvas
65
68
  * If yes, convert from pixel values to logical cartesian coordinates and return all focused series
66
- */ export function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart) {
69
+ */ export function getFocusedSeriesData(mousePos, chartData, pinnedPos, chart, unit) {
67
70
  if (chart === undefined || mousePos === null) return [];
68
71
  // prevents multiple tooltips showing from adjacent charts
69
72
  let cursorTargetMatchesChart = false;
@@ -99,7 +102,7 @@ import { TOOLTIP_DATE_FORMAT, TOOLTIP_MAX_ITEMS } from './tooltip-model';
99
102
  if (chart.containPixel('grid', pointInPixel)) {
100
103
  const pointInGrid = chart.convertFromPixel('grid', pointInPixel);
101
104
  if (pointInGrid[0] !== undefined && pointInGrid[1] !== undefined) {
102
- return getNearbySeries(chartData, pointInGrid, yBuffer);
105
+ return getNearbySeries(chartData, pointInGrid, yBuffer, unit);
103
106
  }
104
107
  }
105
108
  return [];
@@ -1 +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 { EChartsDataFormat } from '../model/graph';\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}\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(data: EChartsDataFormat, pointInGrid: number[], yBuffer: number): 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 currentFocusedData.push({\n seriesIdx: seriesIdx,\n datumIdx: datumIdx,\n seriesName: currentSeriesName,\n date: formattedDate,\n x: xValue,\n y: yValue,\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) {\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);\n }\n }\n return [];\n}\n"],"names":["TOOLTIP_DATE_FORMAT","TOOLTIP_MAX_ITEMS","getNearbySeries","data","pointInGrid","yBuffer","currentFocusedData","focusedX","focusedY","Array","isArray","xAxis","timeSeries","seriesIdx","length","currentSeries","undefined","currentSeriesName","name","toString","markerColor","color","datumIdx","xValue","yValue","xValueMilliSeconds","formattedDate","format","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;AAIjC,SAAqBA,mBAAmB,EAAEC,iBAAiB,QAAQ,iBAAiB,CAAC;AAcrF;;;CAGC,GACD,OAAO,SAASC,eAAe,CAACC,IAAuB,EAAEC,WAAqB,EAAEC,OAAe,EAAsB;IACnH,MAAMC,kBAAkB,GAAuB,EAAE,AAAC;QAClBF,GAAc;IAA9C,MAAMG,QAAQ,GAAkBH,CAAAA,GAAc,GAAdA,WAAW,CAAC,CAAC,CAAC,cAAdA,GAAc,cAAdA,GAAc,GAAI,IAAI,AAAC;QACvBA,IAAc;IAA9C,MAAMI,QAAQ,GAAkBJ,CAAAA,IAAc,GAAdA,WAAW,CAAC,CAAC,CAAC,cAAdA,IAAc,cAAdA,IAAc,GAAI,IAAI,AAAC;IAEvD,IAAIG,QAAQ,KAAK,IAAI,IAAIC,QAAQ,KAAK,IAAI,EAAE;QAC1C,OAAOF,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAIG,KAAK,CAACC,OAAO,CAACP,IAAI,CAACQ,KAAK,CAAC,IAAIF,KAAK,CAACC,OAAO,CAACP,IAAI,CAACS,UAAU,CAAC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,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
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,cAA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,CAACmB,UAAU,CAACtB,CAAC,cAArBG,EAAqB,cAArBA,EAAqB,GAAI,CAAC;QAAEA,CAAAA,EAAqB,GAArBA,QAAQ,CAACmB,UAAU,CAACrB,CAAC,cAArBE,EAAqB,cAArBA,EAAqB,GAAI,CAAC;KAAC,AAAC;IAC9E,IAAIG,KAAK,CAACiB,YAAY,CAAC,MAAM,EAAEF,YAAY,CAAC,EAAE;QAC5C,MAAMlD,WAAW,GAAGmC,KAAK,CAACkB,gBAAgB,CAAC,MAAM,EAAEH,YAAY,CAAC,AAAC;QACjE,IAAIlD,WAAW,CAAC,CAAC,CAAC,KAAKa,SAAS,IAAIb,WAAW,CAAC,CAAC,CAAC,KAAKa,SAAS,EAAE;YAChE,OAAOf,eAAe,CAACmC,SAAS,EAAEjC,WAAW,EAAEC,OAAO,EAAEC,IAAI,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -64,11 +64,29 @@ describe('getNearbySeries', ()=>{
64
64
  seriesName: 'env="demo", instance="demo.do.prometheus", job="node", mode="test alt"',
65
65
  seriesIdx: 1,
66
66
  x: 1654007895000,
67
- y: 0.0524463040446356
67
+ y: 0.0524463040446356,
68
+ formattedY: '0.05'
68
69
  }
69
70
  ];
70
71
  it('should return focused series data for points nearby the cursor', ()=>{
71
- expect(getNearbySeries(chartData, pointInGrid, yBuffer)).toEqual(focusedSeriesOutput);
72
+ const decimalUnit = {
73
+ kind: 'Decimal',
74
+ decimal_places: 2
75
+ };
76
+ expect(getNearbySeries(chartData, pointInGrid, yBuffer, decimalUnit)).toEqual(focusedSeriesOutput);
77
+ });
78
+ it('should return series values formatted as a percent', ()=>{
79
+ const percentFormattedOutput = [
80
+ ...focusedSeriesOutput
81
+ ];
82
+ if (percentFormattedOutput[0]) {
83
+ percentFormattedOutput[0].formattedY = '5%';
84
+ }
85
+ const percentFormattedUnit = {
86
+ kind: 'PercentDecimal',
87
+ decimal_places: 0
88
+ };
89
+ expect(getNearbySeries(chartData, pointInGrid, yBuffer, percentFormattedUnit)).toEqual(percentFormattedOutput);
72
90
  });
73
91
  });
74
92
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Tooltip/focused-series.test.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 { EChartsDataFormat } from '../model';\nimport { getNearbySeries } from './focused-series';\n\ndescribe('getNearbySeries', () => {\n const chartData: EChartsDataFormat = {\n timeSeries: [\n {\n type: 'line',\n name: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test\"',\n color: 'hsla(-1365438424,50%,50%,0.8)',\n data: [\n 0.0002315202231525094, 0.00022873082287300112, 0.00023152022315149463, 0.00023152022315149463,\n 0.00022873082287300112,\n ],\n symbol: 'circle',\n },\n {\n type: 'line',\n name: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test alt\"',\n color: 'hsla(286664040,50%,50%,0.8)',\n data: [0.05245188284519867, 0.0524463040446356, 0.0524463040446356, 0.05247140864723438, 0.052482566248230646],\n symbol: 'circle',\n },\n ],\n xAxis: [1654007865000, 1654007880000, 1654007895000, 1654007910000, 1654007925000],\n rangeMs: 60000,\n };\n\n // https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel\n const pointInGrid = [2, 0.0560655737704918]; // converted from chart.getZr() mousemove coordinates\n\n const yBuffer = 0.02; // calculated from y axis interval\n\n const focusedSeriesOutput = [\n {\n date: 'May 31, 2022, 2:38:15 PM',\n datumIdx: 2,\n markerColor: 'hsla(286664040,50%,50%,0.8)',\n seriesName: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test alt\"',\n seriesIdx: 1,\n x: 1654007895000,\n y: 0.0524463040446356,\n },\n ];\n\n it('should return focused series data for points nearby the cursor', () => {\n expect(getNearbySeries(chartData, pointInGrid, yBuffer)).toEqual(focusedSeriesOutput);\n });\n});\n"],"names":["getNearbySeries","describe","chartData","timeSeries","type","name","color","data","symbol","xAxis","rangeMs","pointInGrid","yBuffer","focusedSeriesOutput","date","datumIdx","markerColor","seriesName","seriesIdx","x","y","it","expect","toEqual"],"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,eAAe,QAAQ,kBAAkB,CAAC;AAEnDC,QAAQ,CAAC,iBAAiB,EAAE,IAAM;IAChC,MAAMC,SAAS,GAAsB;QACnCC,UAAU,EAAE;YACV;gBACEC,IAAI,EAAE,MAAM;gBACZC,IAAI,EAAE,oEAAoE;gBAC1EC,KAAK,EAAE,+BAA+B;gBACtCC,IAAI,EAAE;AACJ,yCAAqB;AAAE,0CAAsB;AAAE,0CAAsB;AAAE,0CAAsB;AAC7F,0CAAsB;iBACvB;gBACDC,MAAM,EAAE,QAAQ;aACjB;YACD;gBACEJ,IAAI,EAAE,MAAM;gBACZC,IAAI,EAAE,wEAAwE;gBAC9EC,KAAK,EAAE,6BAA6B;gBACpCC,IAAI,EAAE;AAAC,uCAAmB;AAAE,sCAAkB;AAAE,sCAAkB;AAAE,uCAAmB;AAAE,wCAAoB;iBAAC;gBAC9GC,MAAM,EAAE,QAAQ;aACjB;SACF;QACDC,KAAK,EAAE;AAAC,yBAAa;AAAE,yBAAa;AAAE,yBAAa;AAAE,yBAAa;AAAE,yBAAa;SAAC;QAClFC,OAAO,EAAE,KAAK;KACf,AAAC;IAEF,0EAA0E;IAC1E,MAAMC,WAAW,GAAG;AAAC,SAAC;AAAE,0BAAkB;KAAC,AAAC,EAAC,qDAAqD;IAElG,MAAMC,OAAO,GAAG,IAAI,AAAC,EAAC,kCAAkC;IAExD,MAAMC,mBAAmB,GAAG;QAC1B;YACEC,IAAI,EAAE,0BAA0B;YAChCC,QAAQ,EAAE,CAAC;YACXC,WAAW,EAAE,6BAA6B;YAC1CC,UAAU,EAAE,wEAAwE;YACpFC,SAAS,EAAE,CAAC;YACZC,CAAC,EAAE,aAAa;YAChBC,CAAC,EAAE,kBAAkB;SACtB;KACF,AAAC;IAEFC,EAAE,CAAC,gEAAgE,EAAE,IAAM;QACzEC,MAAM,CAACtB,eAAe,CAACE,SAAS,EAAES,WAAW,EAAEC,OAAO,CAAC,CAAC,CAACW,OAAO,CAACV,mBAAmB,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/Tooltip/focused-series.test.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 { EChartsDataFormat, UnitOptions } from '../model';\nimport { getNearbySeries } from './focused-series';\n\ndescribe('getNearbySeries', () => {\n const chartData: EChartsDataFormat = {\n timeSeries: [\n {\n type: 'line',\n name: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test\"',\n color: 'hsla(-1365438424,50%,50%,0.8)',\n data: [\n 0.0002315202231525094, 0.00022873082287300112, 0.00023152022315149463, 0.00023152022315149463,\n 0.00022873082287300112,\n ],\n symbol: 'circle',\n },\n {\n type: 'line',\n name: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test alt\"',\n color: 'hsla(286664040,50%,50%,0.8)',\n data: [0.05245188284519867, 0.0524463040446356, 0.0524463040446356, 0.05247140864723438, 0.052482566248230646],\n symbol: 'circle',\n },\n ],\n xAxis: [1654007865000, 1654007880000, 1654007895000, 1654007910000, 1654007925000],\n rangeMs: 60000,\n };\n\n // https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel\n const pointInGrid = [2, 0.0560655737704918]; // converted from chart.getZr() mousemove coordinates\n\n const yBuffer = 0.02; // calculated from y axis interval\n\n const focusedSeriesOutput = [\n {\n date: 'May 31, 2022, 2:38:15 PM',\n datumIdx: 2,\n markerColor: 'hsla(286664040,50%,50%,0.8)',\n seriesName: 'env=\"demo\", instance=\"demo.do.prometheus\", job=\"node\", mode=\"test alt\"',\n seriesIdx: 1,\n x: 1654007895000,\n y: 0.0524463040446356,\n formattedY: '0.05',\n },\n ];\n\n it('should return focused series data for points nearby the cursor', () => {\n const decimalUnit: UnitOptions = {\n kind: 'Decimal',\n decimal_places: 2,\n };\n expect(getNearbySeries(chartData, pointInGrid, yBuffer, decimalUnit)).toEqual(focusedSeriesOutput);\n });\n\n it('should return series values formatted as a percent', () => {\n const percentFormattedOutput = [...focusedSeriesOutput];\n if (percentFormattedOutput[0]) {\n percentFormattedOutput[0].formattedY = '5%';\n }\n const percentFormattedUnit: UnitOptions = {\n kind: 'PercentDecimal',\n decimal_places: 0,\n };\n expect(getNearbySeries(chartData, pointInGrid, yBuffer, percentFormattedUnit)).toEqual(percentFormattedOutput);\n });\n});\n"],"names":["getNearbySeries","describe","chartData","timeSeries","type","name","color","data","symbol","xAxis","rangeMs","pointInGrid","yBuffer","focusedSeriesOutput","date","datumIdx","markerColor","seriesName","seriesIdx","x","y","formattedY","it","decimalUnit","kind","decimal_places","expect","toEqual","percentFormattedOutput","percentFormattedUnit"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,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;IAEFC,EAAE,CAAC,gEAAgE,EAAE,IAAM;QACzE,MAAMC,WAAW,GAAgB;YAC/BC,IAAI,EAAE,SAAS;YACfC,cAAc,EAAE,CAAC;SAClB,AAAC;QACFC,MAAM,CAAC1B,eAAe,CAACE,SAAS,EAAES,WAAW,EAAEC,OAAO,EAAEW,WAAW,CAAC,CAAC,CAACI,OAAO,CAACd,mBAAmB,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;IAEHS,EAAE,CAAC,oDAAoD,EAAE,IAAM;QAC7D,MAAMM,sBAAsB,GAAG;eAAIf,mBAAmB;SAAC,AAAC;QACxD,IAAIe,sBAAsB,CAAC,CAAC,CAAC,EAAE;YAC7BA,sBAAsB,CAAC,CAAC,CAAC,CAACP,UAAU,GAAG,IAAI,CAAC;QAC9C,CAAC;QACD,MAAMQ,oBAAoB,GAAgB;YACxCL,IAAI,EAAE,gBAAgB;YACtBC,cAAc,EAAE,CAAC;SAClB,AAAC;QACFC,MAAM,CAAC1B,eAAe,CAACE,SAAS,EAAES,WAAW,EAAEC,OAAO,EAAEiB,oBAAoB,CAAC,CAAC,CAACF,OAAO,CAACC,sBAAsB,CAAC,CAAC;IACjH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { UnitOptions } from '../model';
3
+ export interface UnitSelectorProps {
4
+ value: UnitOptions;
5
+ onChange: (unit: UnitOptions) => void;
6
+ }
7
+ export declare function UnitSelector({ value, onChange }: UnitSelectorProps): JSX.Element;
8
+ //# sourceMappingURL=UnitSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnitSelector.d.ts","sourceRoot":"","sources":["../../src/UnitSelector/UnitSelector.tsx"],"names":[],"mappings":";AAaA,OAAO,EACL,WAAW,EAMZ,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACvC;AAeD,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,eAiFlE"}
@@ -0,0 +1,112 @@
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 { Box, Switch, TextField, Autocomplete } from '@mui/material';
15
+ import { UNIT_CONFIG, DEFAULT_DECIMAL_PLACES, isUnitWithDecimalPlaces, isUnitWithAbbreviate } from '../model';
16
+ import { OptionsEditorControl } from '../OptionsEditorLayout';
17
+ const KIND_OPTIONS = Object.entries(UNIT_CONFIG).map(([id, config])=>{
18
+ return {
19
+ id: id,
20
+ ...config
21
+ };
22
+ }).filter((config)=>!config.disableSelectorOption);
23
+ const DECIMAL_OPTIONS = [
24
+ 0,
25
+ 1,
26
+ 2,
27
+ 3,
28
+ 4
29
+ ];
30
+ export function UnitSelector({ value , onChange }) {
31
+ const hasDecimalPlaces = isUnitWithDecimalPlaces(value);
32
+ const hasAbbreviate = isUnitWithAbbreviate(value);
33
+ const handleKindChange = (_, newValue)=>{
34
+ onChange({
35
+ kind: newValue.id
36
+ });
37
+ };
38
+ const handleDecimalChange = (_, newValue)=>{
39
+ if (hasDecimalPlaces) {
40
+ onChange({
41
+ ...value,
42
+ decimal_places: newValue
43
+ });
44
+ }
45
+ };
46
+ const handleAbbreviateChange = (_, checked)=>{
47
+ if (hasAbbreviate) {
48
+ onChange({
49
+ ...value,
50
+ abbreviate: checked
51
+ });
52
+ }
53
+ };
54
+ const kindConfig = UNIT_CONFIG[value.kind];
55
+ var _decimal_places;
56
+ return /*#__PURE__*/ _jsxs(_Fragment, {
57
+ children: [
58
+ /*#__PURE__*/ _jsx(OptionsEditorControl, {
59
+ label: "Abbreviate",
60
+ control: /*#__PURE__*/ _jsx(Switch, {
61
+ checked: hasAbbreviate ? !!value.abbreviate : false,
62
+ onChange: handleAbbreviateChange,
63
+ disabled: !hasAbbreviate
64
+ })
65
+ }),
66
+ /*#__PURE__*/ _jsx(OptionsEditorControl, {
67
+ label: "Units",
68
+ control: /*#__PURE__*/ _jsx(Autocomplete, {
69
+ value: {
70
+ id: value.kind,
71
+ ...kindConfig
72
+ },
73
+ options: KIND_OPTIONS,
74
+ isOptionEqualToValue: (option, value)=>option.id === value.id,
75
+ groupBy: (option)=>option.group,
76
+ renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
77
+ ...params
78
+ }),
79
+ renderOption: (renderOptsProps, option)=>{
80
+ // Custom option needed to get some increased left padding to make
81
+ // the items more distinct from the group label.
82
+ return /*#__PURE__*/ _jsx("li", {
83
+ ...renderOptsProps,
84
+ children: /*#__PURE__*/ _jsx(Box, {
85
+ paddingLeft: (theme)=>theme.spacing(1),
86
+ children: option.label
87
+ })
88
+ });
89
+ },
90
+ onChange: handleKindChange,
91
+ disableClearable: true
92
+ })
93
+ }),
94
+ /*#__PURE__*/ _jsx(OptionsEditorControl, {
95
+ label: "Decimal",
96
+ control: /*#__PURE__*/ _jsx(Autocomplete, {
97
+ value: hasDecimalPlaces ? (_decimal_places = value.decimal_places) !== null && _decimal_places !== void 0 ? _decimal_places : DEFAULT_DECIMAL_PLACES : 0,
98
+ options: DECIMAL_OPTIONS,
99
+ getOptionLabel: (option)=>`${option}`,
100
+ renderInput: (params)=>/*#__PURE__*/ _jsx(TextField, {
101
+ ...params
102
+ }),
103
+ onChange: handleDecimalChange,
104
+ disabled: !hasDecimalPlaces,
105
+ disableClearable: true
106
+ })
107
+ })
108
+ ]
109
+ });
110
+ }
111
+
112
+ //# sourceMappingURL=UnitSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/UnitSelector/UnitSelector.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.\nimport { Box, Switch, TextField, Autocomplete, SwitchProps } from '@mui/material';\nimport {\n UnitOptions,\n UNIT_CONFIG,\n DEFAULT_DECIMAL_PLACES,\n UnitConfig,\n isUnitWithDecimalPlaces,\n isUnitWithAbbreviate,\n} from '../model';\nimport { OptionsEditorControl } from '../OptionsEditorLayout';\n\nexport interface UnitSelectorProps {\n value: UnitOptions;\n onChange: (unit: UnitOptions) => void;\n}\n\ntype AutocompleteKindOption = UnitConfig & { id: UnitOptions['kind'] };\n\nconst KIND_OPTIONS: AutocompleteKindOption[] = Object.entries(UNIT_CONFIG)\n .map(([id, config]) => {\n return {\n id: id as UnitOptions['kind'],\n ...config,\n };\n })\n .filter((config) => !config.disableSelectorOption);\n\nconst DECIMAL_OPTIONS = [0, 1, 2, 3, 4];\n\nexport function UnitSelector({ value, onChange }: UnitSelectorProps) {\n const hasDecimalPlaces = isUnitWithDecimalPlaces(value);\n const hasAbbreviate = isUnitWithAbbreviate(value);\n\n const handleKindChange = (_: unknown, newValue: AutocompleteKindOption) => {\n onChange({\n kind: newValue.id,\n });\n };\n\n const handleDecimalChange = (_: unknown, newValue: number) => {\n if (hasDecimalPlaces) {\n onChange({\n ...value,\n decimal_places: newValue,\n });\n }\n };\n\n const handleAbbreviateChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n if (hasAbbreviate) {\n onChange({\n ...value,\n abbreviate: checked,\n });\n }\n };\n\n const kindConfig = UNIT_CONFIG[value.kind];\n\n return (\n <>\n <OptionsEditorControl\n label=\"Abbreviate\"\n control={\n <Switch\n checked={hasAbbreviate ? !!value.abbreviate : false}\n onChange={handleAbbreviateChange}\n disabled={!hasAbbreviate}\n />\n }\n />\n <OptionsEditorControl\n label=\"Units\"\n control={\n <Autocomplete\n value={{ id: value.kind, ...kindConfig }}\n options={KIND_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n groupBy={(option) => option.group}\n renderInput={(params) => <TextField {...params} />}\n renderOption={(renderOptsProps, option) => {\n // Custom option needed to get some increased left padding to make\n // the items more distinct from the group label.\n return (\n <li {...renderOptsProps}>\n <Box paddingLeft={(theme) => theme.spacing(1)}>{option.label}</Box>\n </li>\n );\n }}\n onChange={handleKindChange}\n disableClearable\n ></Autocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Decimal\"\n control={\n <Autocomplete\n value={hasDecimalPlaces ? value.decimal_places ?? DEFAULT_DECIMAL_PLACES : 0}\n options={DECIMAL_OPTIONS}\n getOptionLabel={(option) => `${option}`}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleDecimalChange}\n disabled={!hasDecimalPlaces}\n disableClearable\n ></Autocomplete>\n }\n />\n </>\n );\n}\n"],"names":["Box","Switch","TextField","Autocomplete","UNIT_CONFIG","DEFAULT_DECIMAL_PLACES","isUnitWithDecimalPlaces","isUnitWithAbbreviate","OptionsEditorControl","KIND_OPTIONS","Object","entries","map","id","config","filter","disableSelectorOption","DECIMAL_OPTIONS","UnitSelector","value","onChange","hasDecimalPlaces","hasAbbreviate","handleKindChange","_","newValue","kind","handleDecimalChange","decimal_places","handleAbbreviateChange","checked","abbreviate","kindConfig","label","control","disabled","options","isOptionEqualToValue","option","groupBy","group","renderInput","params","renderOption","renderOptsProps","li","paddingLeft","theme","spacing","disableClearable","getOptionLabel"],"mappings":"AAAA,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AAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;0CAAGV,MAAM,CAACL,KAAK;8BAAO;0BAChE,CACL;oBACJ,CAAC;oBACDb,QAAQ,EAAEG,gBAAgB;oBAC1B0B,gBAAgB;kBACF;cAElB;0BACF,KAACzC,oBAAoB;gBACnByB,KAAK,EAAC,SAAS;gBACfC,OAAO,gBACL,KAAC/B,YAAY;oBACXgB,KAAK,EAAEE,gBAAgB,GAAGF,CAAAA,eAAoB,GAApBA,KAAK,CAACS,cAAc,cAApBT,eAAoB,cAApBA,eAAoB,GAAId,sBAAsB,GAAG,CAAC;oBAC5E+B,OAAO,EAAEnB,eAAe;oBACxBiC,cAAc,EAAE,CAACZ,MAAM,GAAK,CAAC,EAAEA,MAAM,CAAC,CAAC;oBACvCG,WAAW,EAAE,CAACC,MAAM,iBAAK,KAACxC,SAAS;4BAAE,GAAGwC,MAAM;0BAAI;oBAClDtB,QAAQ,EAAEO,mBAAmB;oBAC7BQ,QAAQ,EAAE,CAACd,gBAAgB;oBAC3B4B,gBAAgB;kBACF;cAElB;;MACD,CACH;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=UnitSelector.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnitSelector.test.d.ts","sourceRoot":"","sources":["../../src/UnitSelector/UnitSelector.test.tsx"],"names":[],"mappings":""}