@perses-dev/stat-chart-plugin 0.14.0 → 0.15.0-beta.1

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 (139) hide show
  1. package/__mf/js/StatChart.cfc077f0.js +7 -0
  2. package/__mf/js/async/121.dd7133cb.js +2 -0
  3. package/__mf/js/async/192.6939be34.js +1 -0
  4. package/__mf/js/async/2.8caf67bd.js +1 -0
  5. package/__mf/js/async/235.c6d2c4f5.js +1 -0
  6. package/__mf/js/async/274.7345c704.js +2 -0
  7. package/__mf/js/async/345.242802c4.js +29 -0
  8. package/__mf/js/async/354.6ea77f69.js +4 -0
  9. package/__mf/js/async/354.6ea77f69.js.LICENSE.txt +9 -0
  10. package/__mf/js/async/356.b00937de.js +1 -0
  11. package/__mf/js/async/392.559f0a15.js +2 -0
  12. package/__mf/js/async/449.6d8fc8b3.js +43 -0
  13. package/__mf/js/async/{580.4076ee7b.js.LICENSE.txt → 449.6d8fc8b3.js.LICENSE.txt} +41 -1
  14. package/__mf/js/async/470.16a500aa.js +2 -0
  15. package/__mf/js/async/570.34dc9996.js +2 -0
  16. package/__mf/js/async/587.7eb542f2.js +1 -0
  17. package/__mf/js/async/616.6b72e257.js +1 -0
  18. package/__mf/js/async/663.2de74425.js +1 -0
  19. package/__mf/js/async/{866.cb6cbc7a.js → 866.d7ad9e7a.js} +5 -5
  20. package/__mf/js/async/941.1589eeae.js +2 -0
  21. package/__mf/js/async/968.ebdf1f2d.js +1 -0
  22. package/__mf/js/async/970.f5882828.js +2 -0
  23. package/__mf/js/async/__federation_expose_StatChart.7973125b.js +1 -0
  24. package/__mf/js/async/lib-router.73f6cef1.js +2 -0
  25. package/__mf/js/{main.fe3736c5.js → main.cd844a8c.js} +3 -3
  26. package/lib/StatChart.d.ts +3 -3
  27. package/lib/StatChart.d.ts.map +1 -1
  28. package/lib/StatChart.js +4 -4
  29. package/lib/StatChart.js.map +1 -1
  30. package/lib/StatChartBase.d.ts +4 -4
  31. package/lib/StatChartBase.d.ts.map +1 -1
  32. package/lib/StatChartBase.js +12 -12
  33. package/lib/StatChartBase.js.map +1 -1
  34. package/lib/StatChartOptionsEditorSettings.d.ts +2 -2
  35. package/lib/StatChartOptionsEditorSettings.d.ts.map +1 -1
  36. package/lib/StatChartOptionsEditorSettings.js +8 -8
  37. package/lib/StatChartOptionsEditorSettings.js.map +1 -1
  38. package/lib/StatChartPanel.d.ts +4 -4
  39. package/lib/StatChartPanel.d.ts.map +1 -1
  40. package/lib/StatChartPanel.js +14 -9
  41. package/lib/StatChartPanel.js.map +1 -1
  42. package/lib/StatChartValueMappingEditor.d.ts +3 -3
  43. package/lib/StatChartValueMappingEditor.d.ts.map +1 -1
  44. package/lib/StatChartValueMappingEditor.js +1 -1
  45. package/lib/StatChartValueMappingEditor.js.map +1 -1
  46. package/lib/bootstrap.js +2 -2
  47. package/lib/getPluginModule.d.ts +1 -1
  48. package/lib/getPluginModule.d.ts.map +1 -1
  49. package/lib/getPluginModule.js +3 -1
  50. package/lib/getPluginModule.js.map +1 -1
  51. package/lib/index-federation.js +1 -1
  52. package/lib/index.js +7 -7
  53. package/lib/index.js.map +1 -1
  54. package/lib/setup-tests.d.ts +1 -1
  55. package/lib/setup-tests.d.ts.map +1 -1
  56. package/lib/setup-tests.js +2 -2
  57. package/lib/setup-tests.js.map +1 -1
  58. package/lib/stat-chart-model.d.ts +3 -3
  59. package/lib/stat-chart-model.d.ts.map +1 -1
  60. package/lib/stat-chart-model.js.map +1 -1
  61. package/lib/utils/calculate-font-size.d.ts +1 -1
  62. package/lib/utils/calculate-font-size.d.ts.map +1 -1
  63. package/lib/utils/calculate-font-size.js +2 -2
  64. package/lib/utils/calculate-font-size.js.map +1 -1
  65. package/lib/utils/calculate-value.d.ts +3 -2
  66. package/lib/utils/calculate-value.d.ts.map +1 -1
  67. package/lib/utils/calculate-value.js +1 -1
  68. package/lib/utils/calculate-value.js.map +1 -1
  69. package/lib/utils/data-transform.d.ts +3 -3
  70. package/lib/utils/data-transform.d.ts.map +1 -1
  71. package/lib/utils/data-transform.js.map +1 -1
  72. package/lib/utils/format-stat-chart-value.d.ts +1 -1
  73. package/lib/utils/format-stat-chart-value.d.ts.map +1 -1
  74. package/lib/utils/format-stat-chart-value.js +1 -1
  75. package/lib/utils/format-stat-chart-value.js.map +1 -1
  76. package/lib/utils/get-color.d.ts +2 -2
  77. package/lib/utils/get-color.d.ts.map +1 -1
  78. package/lib/utils/get-color.js +1 -1
  79. package/lib/utils/get-color.js.map +1 -1
  80. package/mf-manifest.json +29 -73
  81. package/mf-stats.json +29 -81
  82. package/package.json +10 -10
  83. package/__mf/js/StatChart.19a287b0.js +0 -7
  84. package/__mf/js/async/121.a33651ce.js +0 -2
  85. package/__mf/js/async/177.4dddf131.js +0 -1
  86. package/__mf/js/async/187.d7e6b2db.js +0 -7
  87. package/__mf/js/async/187.d7e6b2db.js.LICENSE.txt +0 -39
  88. package/__mf/js/async/192.0b251884.js +0 -1
  89. package/__mf/js/async/2.e8bdc16f.js +0 -1
  90. package/__mf/js/async/235.f388b6fd.js +0 -1
  91. package/__mf/js/async/274.b762faf5.js +0 -2
  92. package/__mf/js/async/356.3f7b970d.js +0 -1
  93. package/__mf/js/async/392.70b1a3c5.js +0 -2
  94. package/__mf/js/async/450.bdfbd76f.js +0 -1
  95. package/__mf/js/async/465.7c60371f.js +0 -2
  96. package/__mf/js/async/470.cc046da0.js +0 -2
  97. package/__mf/js/async/546.f27d00a1.js +0 -24
  98. package/__mf/js/async/546.f27d00a1.js.LICENSE.txt +0 -19
  99. package/__mf/js/async/558.e8f8691f.js +0 -1
  100. package/__mf/js/async/570.264704d1.js +0 -2
  101. package/__mf/js/async/580.4076ee7b.js +0 -66
  102. package/__mf/js/async/587.7d22fb82.js +0 -1
  103. package/__mf/js/async/588.c00e3759.js +0 -1
  104. package/__mf/js/async/616.22b37336.js +0 -1
  105. package/__mf/js/async/71.1f2caf38.js +0 -1
  106. package/__mf/js/async/721.5c1c6916.js +0 -1
  107. package/__mf/js/async/873.13ff7de6.js +0 -1
  108. package/__mf/js/async/941.230549f5.js +0 -2
  109. package/__mf/js/async/968.bfd3594f.js +0 -1
  110. package/__mf/js/async/978.98475f4b.js +0 -1
  111. package/__mf/js/async/__federation_expose_StatChart.f4a2f598.js +0 -1
  112. package/__mf/js/async/lib-router.6c58ccc7.js +0 -2
  113. package/lib/cjs/StatChart.js +0 -43
  114. package/lib/cjs/StatChartBase.js +0 -263
  115. package/lib/cjs/StatChartOptionsEditorSettings.js +0 -171
  116. package/lib/cjs/StatChartPanel.js +0 -130
  117. package/lib/cjs/StatChartValueMappingEditor.js +0 -36
  118. package/lib/cjs/bootstrap.js +0 -26
  119. package/lib/cjs/env.d.js +0 -14
  120. package/lib/cjs/getPluginModule.js +0 -39
  121. package/lib/cjs/index-federation.js +0 -55
  122. package/lib/cjs/index.js +0 -42
  123. package/lib/cjs/setup-tests.js +0 -19
  124. package/lib/cjs/stat-chart-model.js +0 -74
  125. package/lib/cjs/utils/calculate-font-size.js +0 -55
  126. package/lib/cjs/utils/calculate-value.js +0 -30
  127. package/lib/cjs/utils/data-transform.js +0 -36
  128. package/lib/cjs/utils/format-stat-chart-value.js +0 -34
  129. package/lib/cjs/utils/get-color.js +0 -66
  130. /package/__mf/css/async/{187.85c2cbf6.css → 449.85c2cbf6.css} +0 -0
  131. /package/__mf/js/async/{121.a33651ce.js.LICENSE.txt → 121.dd7133cb.js.LICENSE.txt} +0 -0
  132. /package/__mf/js/async/{274.b762faf5.js.LICENSE.txt → 274.7345c704.js.LICENSE.txt} +0 -0
  133. /package/__mf/js/async/{392.70b1a3c5.js.LICENSE.txt → 392.559f0a15.js.LICENSE.txt} +0 -0
  134. /package/__mf/js/async/{470.cc046da0.js.LICENSE.txt → 470.16a500aa.js.LICENSE.txt} +0 -0
  135. /package/__mf/js/async/{570.264704d1.js.LICENSE.txt → 570.34dc9996.js.LICENSE.txt} +0 -0
  136. /package/__mf/js/async/{866.cb6cbc7a.js.LICENSE.txt → 866.d7ad9e7a.js.LICENSE.txt} +0 -0
  137. /package/__mf/js/async/{941.230549f5.js.LICENSE.txt → 941.1589eeae.js.LICENSE.txt} +0 -0
  138. /package/__mf/js/async/{465.7c60371f.js.LICENSE.txt → 970.f5882828.js.LICENSE.txt} +0 -0
  139. /package/__mf/js/async/{lib-router.6c58ccc7.js.LICENSE.txt → lib-router.73f6cef1.js.LICENSE.txt} +0 -0
package/lib/StatChart.js CHANGED
@@ -10,10 +10,10 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { createInitialStatChartOptions } from './stat-chart-model';
14
- import { StatChartValueMappingEditor } from './StatChartValueMappingEditor';
15
- import { StatChartOptionsEditorSettings } from './StatChartOptionsEditorSettings';
16
- import { StatChartPanel } from './StatChartPanel';
13
+ import { createInitialStatChartOptions } from "./stat-chart-model.js";
14
+ import { StatChartOptionsEditorSettings } from "./StatChartOptionsEditorSettings.js";
15
+ import { StatChartPanel } from "./StatChartPanel.js";
16
+ import { StatChartValueMappingEditor } from "./StatChartValueMappingEditor.js";
17
17
  /**
18
18
  * The core StatChart panel plugin for Perses.
19
19
  */ export const StatChart = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StatChart.ts"],"sourcesContent":["// Copyright 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 { PanelPlugin } from '@perses-dev/plugin-system';\nimport { createInitialStatChartOptions, StatChartOptions } from './stat-chart-model';\nimport { StatChartValueMappingEditor } from './StatChartValueMappingEditor';\nimport { StatChartOptionsEditorSettings } from './StatChartOptionsEditorSettings';\nimport { StatChartPanel, StatChartPanelProps } from './StatChartPanel';\n\n/**\n * The core StatChart panel plugin for Perses.\n */\nexport const StatChart: PanelPlugin<StatChartOptions, StatChartPanelProps> = {\n PanelComponent: StatChartPanel,\n supportedQueryTypes: ['TimeSeriesQuery'],\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: StatChartOptionsEditorSettings,\n },\n { label: 'Value mapping', content: StatChartValueMappingEditor },\n ],\n createInitialOptions: createInitialStatChartOptions,\n};\n"],"names":["createInitialStatChartOptions","StatChartValueMappingEditor","StatChartOptionsEditorSettings","StatChartPanel","StatChart","PanelComponent","supportedQueryTypes","panelOptionsEditorComponents","label","content","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,6BAA6B,QAA0B,qBAAqB;AACrF,SAASC,2BAA2B,QAAQ,gCAAgC;AAC5E,SAASC,8BAA8B,QAAQ,mCAAmC;AAClF,SAASC,cAAc,QAA6B,mBAAmB;AAEvE;;CAEC,GACD,OAAO,MAAMC,YAAgE;IAC3EC,gBAAgBF;IAChBG,qBAAqB;QAAC;KAAkB;IACxCC,8BAA8B;QAC5B;YACEC,OAAO;YACPC,SAASP;QACX;QACA;YAAEM,OAAO;YAAiBC,SAASR;QAA4B;KAChE;IACDS,sBAAsBV;AACxB,EAAE"}
1
+ {"version":3,"sources":["../../src/StatChart.ts"],"sourcesContent":["// Copyright 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 type { PanelPlugin } from '@perses-dev/plugin-system';\n\nimport type { StatChartOptions } from './stat-chart-model';\nimport { createInitialStatChartOptions } from './stat-chart-model';\nimport { StatChartOptionsEditorSettings } from './StatChartOptionsEditorSettings';\nimport type { StatChartPanelProps } from './StatChartPanel';\nimport { StatChartPanel } from './StatChartPanel';\nimport { StatChartValueMappingEditor } from './StatChartValueMappingEditor';\n\n/**\n * The core StatChart panel plugin for Perses.\n */\nexport const StatChart: PanelPlugin<StatChartOptions, StatChartPanelProps> = {\n PanelComponent: StatChartPanel,\n supportedQueryTypes: ['TimeSeriesQuery'],\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: StatChartOptionsEditorSettings,\n },\n { label: 'Value mapping', content: StatChartValueMappingEditor },\n ],\n createInitialOptions: createInitialStatChartOptions,\n};\n"],"names":["createInitialStatChartOptions","StatChartOptionsEditorSettings","StatChartPanel","StatChartValueMappingEditor","StatChart","PanelComponent","supportedQueryTypes","panelOptionsEditorComponents","label","content","createInitialOptions"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAKjC,SAASA,6BAA6B,QAAQ,wBAAqB;AACnE,SAASC,8BAA8B,QAAQ,sCAAmC;AAElF,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,2BAA2B,QAAQ,mCAAgC;AAE5E;;CAEC,GACD,OAAO,MAAMC,YAAgE;IAC3EC,gBAAgBH;IAChBI,qBAAqB;QAAC;KAAkB;IACxCC,8BAA8B;QAC5B;YACEC,OAAO;YACPC,SAASR;QACX;QACA;YAAEO,OAAO;YAAiBC,SAASN;QAA4B;KAChE;IACDO,sBAAsBV;AACxB,EAAE"}
@@ -1,7 +1,7 @@
1
- import { FC } from 'react';
2
- import { LineSeriesOption } from 'echarts/charts';
3
- import { FontSizeOption, FormatOptions, GraphSeries } from '@perses-dev/components';
4
- import { ColorMode } from './stat-chart-model';
1
+ import type { FontSizeOption, FormatOptions, GraphSeries } from '@perses-dev/components';
2
+ import type { LineSeriesOption } from 'echarts/charts';
3
+ import type { FC } from 'react';
4
+ import type { ColorMode } from './stat-chart-model';
5
5
  export interface StatChartData {
6
6
  color: string;
7
7
  calculatedValue?: string | number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"StatChartBase.d.ts","sourceRoot":"","sources":["../../src/StatChartBase.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAsB,MAAM,OAAO,CAAC;AAI/C,OAAO,EAAiC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGjF,OAAO,EAAU,cAAc,EAAE,aAAa,EAAE,WAAW,EAAkB,MAAM,wBAAwB,CAAC;AAI5G,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAW/C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,cAAc,CA4M5C,CAAC"}
1
+ {"version":3,"file":"StatChartBase.d.ts","sourceRoot":"","sources":["../../src/StatChartBase.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,OAAO,KAAK,EAAE,EAAE,EAAa,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAapD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,cAAc,CA4M5C,CAAC"}
@@ -11,18 +11,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { useMemo } from 'react';
15
- import { Box, Typography, styled, useTheme } from '@mui/material';
16
- import merge from 'lodash/merge';
17
- import { use } from 'echarts/core';
18
- import { LineChart as EChartsLineChart } from 'echarts/charts';
19
- import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';
20
- import { CanvasRenderer } from 'echarts/renderers';
21
- import { EChart, useChartsTheme } from '@perses-dev/components';
22
- import chroma from 'chroma-js';
23
- import { useOptimalFontSize } from './utils/calculate-font-size';
24
- import { formatStatChartValue } from './utils/format-stat-chart-value';
25
- use([
14
+ import { Box, Typography, styled, useTheme } from "@mui/material";
15
+ import { EChart, useChartsTheme } from "@perses-dev/components";
16
+ import chroma from "chroma-js";
17
+ import { LineChart as EChartsLineChart } from "echarts/charts";
18
+ import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from "echarts/components";
19
+ import { use as registerECharts } from "echarts/core";
20
+ import { CanvasRenderer } from "echarts/renderers";
21
+ import merge from "lodash/merge";
22
+ import { useMemo } from "react";
23
+ import { useOptimalFontSize } from "./utils/calculate-font-size.js";
24
+ import { formatStatChartValue } from "./utils/format-stat-chart-value.js";
25
+ registerECharts([
26
26
  EChartsLineChart,
27
27
  GridComponent,
28
28
  DatasetComponent,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StatChartBase.tsx"],"sourcesContent":["// Copyright 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 { FC, ReactNode, useMemo } from 'react';\nimport { Box, Typography, styled, useTheme } from '@mui/material';\nimport merge from 'lodash/merge';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { LineChart as EChartsLineChart, LineSeriesOption } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, FontSizeOption, FormatOptions, GraphSeries, useChartsTheme } from '@perses-dev/components';\nimport chroma from 'chroma-js';\nimport { useOptimalFontSize } from './utils/calculate-font-size';\nimport { formatStatChartValue } from './utils/format-stat-chart-value';\nimport { ColorMode } from './stat-chart-model';\n\nuse([EChartsLineChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst LINE_HEIGHT = 1.2;\nconst SERIES_NAME_MAX_FONT_SIZE = 30;\nconst SERIES_NAME_FONT_WEIGHT = 400;\nconst VALUE_FONT_WEIGHT = 700;\nconst WHITE_COLOR_CODE = '#FFFFFF';\nconst BLACK_COLOR_CODE = '#000000';\n\nexport interface StatChartData {\n color: string;\n calculatedValue?: string | number | null;\n seriesData?: GraphSeries;\n}\n\nexport interface StatChartProps {\n width: number;\n height: number;\n data: StatChartData;\n format?: FormatOptions;\n sparkline?: LineSeriesOption;\n showSeriesName?: boolean;\n valueFontSize?: FontSizeOption;\n colorMode?: ColorMode;\n}\n\nexport const StatChartBase: FC<StatChartProps> = (props) => {\n const {\n width,\n height,\n data,\n data: { color },\n sparkline,\n showSeriesName,\n format,\n valueFontSize,\n colorMode,\n } = props;\n\n const {\n palette: {\n mode: paletteMode,\n text: { secondary },\n },\n } = useTheme();\n const chartsTheme = useChartsTheme();\n const formattedValue = formatStatChartValue(data.calculatedValue, format);\n const containerPadding = chartsTheme.container.padding.default;\n\n // calculate series name font size and height\n let seriesNameFontSize = useOptimalFontSize({\n text: data?.seriesData?.name ?? '',\n fontWeight: SERIES_NAME_FONT_WEIGHT,\n width,\n height: height * 0.125, // assume series name will take 12.5% of available height\n lineHeight: LINE_HEIGHT,\n maxSize: SERIES_NAME_MAX_FONT_SIZE,\n });\n\n const seriesNameHeight = showSeriesName ? seriesNameFontSize * LINE_HEIGHT + containerPadding : 0;\n\n // calculate value font size and height\n const availableWidth = width - containerPadding * 2;\n const availableHeight = height - seriesNameHeight;\n const optimalValueFontSize = useOptimalFontSize({\n text: formattedValue,\n // override the font size if user selects it in the settings\n fontSizeOverride: valueFontSize,\n fontWeight: VALUE_FONT_WEIGHT,\n // without sparkline, use only 50% of the available width so it looks better for multiseries\n width: sparkline ? availableWidth : availableWidth * 0.5,\n // with sparkline, use only 25% of available height to leave room for chart\n // without sparkline, value should take up 90% of available space\n height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,\n lineHeight: LINE_HEIGHT,\n });\n const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;\n\n // make sure the series name font size is slightly smaller than value font size\n seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (!data.seriesData) return chartsTheme.noDataOption;\n\n const series = data.seriesData;\n const statSeries: LineSeriesOption[] = [];\n\n if (sparkline) {\n const lineSeries = {\n type: 'line',\n name: series.name,\n data: series.values,\n zlevel: 1,\n symbol: 'none',\n animation: false,\n silent: true,\n };\n\n const clonedSparkLine = { ...sparkline };\n if (colorMode === 'background_solid') {\n clonedSparkLine.areaStyle = { color: WHITE_COLOR_CODE, opacity: 0.4 };\n clonedSparkLine.lineStyle = { color: WHITE_COLOR_CODE, opacity: 1 };\n }\n\n const mergedSeries = merge(lineSeries, clonedSparkLine);\n statSeries.push(mergedSeries);\n }\n\n const option: EChartsCoreOption = {\n title: {\n show: false,\n },\n grid: {\n show: false,\n top: '35%', // adds space above sparkline\n right: 0,\n bottom: 0,\n left: 0,\n containLabel: false,\n },\n xAxis: {\n type: 'time',\n show: false,\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n show: false,\n min: (value: { min: number; max: number }): number => {\n if (value.min >= 0 && value.min <= 1) {\n // helps with percent-decimal units, or datasets that return 0 or 1 booleans\n return 0;\n }\n return value.min;\n },\n },\n tooltip: {\n show: false,\n },\n series: statSeries,\n };\n\n return option;\n }, [data, chartsTheme, sparkline, colorMode]);\n\n const textAlignment = sparkline ? 'auto' : 'center';\n\n const styledFormattedValue = useMemo(() => {\n let valueColor = '';\n\n switch (colorMode) {\n case 'background_solid':\n valueColor =\n chroma.contrast(color, WHITE_COLOR_CODE) > chroma.contrast(color, BLACK_COLOR_CODE)\n ? WHITE_COLOR_CODE\n : BLACK_COLOR_CODE;\n break;\n case 'none':\n valueColor = paletteMode === 'dark' ? WHITE_COLOR_CODE : BLACK_COLOR_CODE;\n break;\n case 'value':\n default:\n valueColor = color;\n break;\n }\n\n return (\n <Value variant=\"h3\" color={valueColor} fontSize={optimalValueFontSize} padding={containerPadding}>\n {formattedValue}\n </Value>\n );\n }, [colorMode, containerPadding, optimalValueFontSize, formattedValue, color, paletteMode]);\n\n const seriesName = useMemo((): ReactNode | null => {\n if (!showSeriesName) return null;\n\n let textColor = '';\n\n switch (colorMode) {\n case 'background_solid':\n textColor =\n chroma.contrast(color, WHITE_COLOR_CODE) > chroma.contrast(color, BLACK_COLOR_CODE)\n ? WHITE_COLOR_CODE\n : BLACK_COLOR_CODE;\n break;\n case 'none':\n case 'value':\n default:\n textColor = secondary;\n break;\n }\n\n return (\n <SeriesName padding={containerPadding} fontSize={seriesNameFontSize} color={textColor}>\n {data.seriesData?.name}\n </SeriesName>\n );\n }, [colorMode, showSeriesName, secondary, color, containerPadding, seriesNameFontSize, data?.seriesData?.name]);\n\n return (\n <Box\n sx={{\n height: '100%',\n width: '100%',\n backgroundColor: colorMode === 'background_solid' ? color : 'transparent',\n display: 'flex',\n flexDirection: 'column',\n justifyContent: textAlignment,\n alignItems: textAlignment,\n }}\n >\n {seriesName}\n {styledFormattedValue}\n {sparkline && (\n <EChart\n sx={{\n width: '100%',\n }}\n style={{\n // ECharts rounds the height to the nearest integer by default.\n // This can cause unneccessary scrollbars when the total height of this chart exceeds the 'height' prop.\n height: Math.floor(height - seriesNameHeight - valueFontHeight),\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\n )}\n </Box>\n );\n};\n\nconst SeriesName = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'padding' && prop !== 'fontSize',\n})<{ padding?: number; fontSize?: number; textAlignment?: string; color?: string }>(({ padding, fontSize, color }) => ({\n color: color,\n padding: `${padding}px`,\n fontSize: `${fontSize}px`,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}));\n\nconst Value = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline',\n})<{ color?: string; padding?: number; fontSize?: number; sparkline?: boolean }>(\n ({ theme, color, padding, fontSize, sparkline }) => ({\n color: color ?? theme.palette.text.primary,\n fontSize: `${fontSize}px`,\n padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,\n whiteSpace: 'nowrap',\n lineHeight: LINE_HEIGHT,\n })\n);\n"],"names":["useMemo","Box","Typography","styled","useTheme","merge","use","LineChart","EChartsLineChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","CanvasRenderer","EChart","useChartsTheme","chroma","useOptimalFontSize","formatStatChartValue","LINE_HEIGHT","SERIES_NAME_MAX_FONT_SIZE","SERIES_NAME_FONT_WEIGHT","VALUE_FONT_WEIGHT","WHITE_COLOR_CODE","BLACK_COLOR_CODE","StatChartBase","props","width","height","data","color","sparkline","showSeriesName","format","valueFontSize","colorMode","palette","mode","paletteMode","text","secondary","chartsTheme","formattedValue","calculatedValue","containerPadding","container","padding","default","seriesNameFontSize","seriesData","name","fontWeight","lineHeight","maxSize","seriesNameHeight","availableWidth","availableHeight","optimalValueFontSize","fontSizeOverride","valueFontHeight","Math","min","option","noDataOption","series","statSeries","lineSeries","type","values","zlevel","symbol","animation","silent","clonedSparkLine","areaStyle","opacity","lineStyle","mergedSeries","push","title","show","grid","top","right","bottom","left","containLabel","xAxis","boundaryGap","yAxis","value","tooltip","textAlignment","styledFormattedValue","valueColor","contrast","Value","variant","fontSize","seriesName","textColor","SeriesName","sx","backgroundColor","display","flexDirection","justifyContent","alignItems","style","floor","theme","echartsTheme","renderer","shouldForwardProp","prop","overflow","textOverflow","whiteSpace","primary"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;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AAO,CAACG,IAAI,CAAC+E,OAAO;QAC1CpB,UAAU,GAAGA,SAAS,EAAE,CAAC;QACzBpD,SAASf,YAAY,GAAGe,QAAQ,GAAG,EAAEA,QAAQ,KAAK,EAAEA,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,EAAEA,QAAQ,EAAE,CAAC;QACnFuE,YAAY;QACZjE,YAAYjC;IACd,CAAA"}
1
+ {"version":3,"sources":["../../src/StatChartBase.tsx"],"sourcesContent":["// Copyright 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, Typography, styled, useTheme } from '@mui/material';\nimport type { FontSizeOption, FormatOptions, GraphSeries } from '@perses-dev/components';\nimport { EChart, useChartsTheme } from '@perses-dev/components';\nimport chroma from 'chroma-js';\nimport type { LineSeriesOption } from 'echarts/charts';\nimport { LineChart as EChartsLineChart } from 'echarts/charts';\nimport { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport type { EChartsCoreOption } from 'echarts/core';\nimport { use as registerECharts } from 'echarts/core';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport merge from 'lodash/merge';\nimport type { FC, ReactNode } from 'react';\nimport { useMemo } from 'react';\n\nimport type { ColorMode } from './stat-chart-model';\nimport { useOptimalFontSize } from './utils/calculate-font-size';\nimport { formatStatChartValue } from './utils/format-stat-chart-value';\n\nregisterECharts([EChartsLineChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nconst LINE_HEIGHT = 1.2;\nconst SERIES_NAME_MAX_FONT_SIZE = 30;\nconst SERIES_NAME_FONT_WEIGHT = 400;\nconst VALUE_FONT_WEIGHT = 700;\nconst WHITE_COLOR_CODE = '#FFFFFF';\nconst BLACK_COLOR_CODE = '#000000';\n\nexport interface StatChartData {\n color: string;\n calculatedValue?: string | number | null;\n seriesData?: GraphSeries;\n}\n\nexport interface StatChartProps {\n width: number;\n height: number;\n data: StatChartData;\n format?: FormatOptions;\n sparkline?: LineSeriesOption;\n showSeriesName?: boolean;\n valueFontSize?: FontSizeOption;\n colorMode?: ColorMode;\n}\n\nexport const StatChartBase: FC<StatChartProps> = (props) => {\n const {\n width,\n height,\n data,\n data: { color },\n sparkline,\n showSeriesName,\n format,\n valueFontSize,\n colorMode,\n } = props;\n\n const {\n palette: {\n mode: paletteMode,\n text: { secondary },\n },\n } = useTheme();\n const chartsTheme = useChartsTheme();\n const formattedValue = formatStatChartValue(data.calculatedValue, format);\n const containerPadding = chartsTheme.container.padding.default;\n\n // calculate series name font size and height\n let seriesNameFontSize = useOptimalFontSize({\n text: data?.seriesData?.name ?? '',\n fontWeight: SERIES_NAME_FONT_WEIGHT,\n width,\n height: height * 0.125, // assume series name will take 12.5% of available height\n lineHeight: LINE_HEIGHT,\n maxSize: SERIES_NAME_MAX_FONT_SIZE,\n });\n\n const seriesNameHeight = showSeriesName ? seriesNameFontSize * LINE_HEIGHT + containerPadding : 0;\n\n // calculate value font size and height\n const availableWidth = width - containerPadding * 2;\n const availableHeight = height - seriesNameHeight;\n const optimalValueFontSize = useOptimalFontSize({\n text: formattedValue,\n // override the font size if user selects it in the settings\n fontSizeOverride: valueFontSize,\n fontWeight: VALUE_FONT_WEIGHT,\n // without sparkline, use only 50% of the available width so it looks better for multiseries\n width: sparkline ? availableWidth : availableWidth * 0.5,\n // with sparkline, use only 25% of available height to leave room for chart\n // without sparkline, value should take up 90% of available space\n height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,\n lineHeight: LINE_HEIGHT,\n });\n const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;\n\n // make sure the series name font size is slightly smaller than value font size\n seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (!data.seriesData) return chartsTheme.noDataOption;\n\n const series = data.seriesData;\n const statSeries: LineSeriesOption[] = [];\n\n if (sparkline) {\n const lineSeries = {\n type: 'line',\n name: series.name,\n data: series.values,\n zlevel: 1,\n symbol: 'none',\n animation: false,\n silent: true,\n };\n\n const clonedSparkLine = { ...sparkline };\n if (colorMode === 'background_solid') {\n clonedSparkLine.areaStyle = { color: WHITE_COLOR_CODE, opacity: 0.4 };\n clonedSparkLine.lineStyle = { color: WHITE_COLOR_CODE, opacity: 1 };\n }\n\n const mergedSeries = merge(lineSeries, clonedSparkLine);\n statSeries.push(mergedSeries);\n }\n\n const option: EChartsCoreOption = {\n title: {\n show: false,\n },\n grid: {\n show: false,\n top: '35%', // adds space above sparkline\n right: 0,\n bottom: 0,\n left: 0,\n containLabel: false,\n },\n xAxis: {\n type: 'time',\n show: false,\n boundaryGap: false,\n },\n yAxis: {\n type: 'value',\n show: false,\n min: (value: { min: number; max: number }): number => {\n if (value.min >= 0 && value.min <= 1) {\n // helps with percent-decimal units, or datasets that return 0 or 1 booleans\n return 0;\n }\n return value.min;\n },\n },\n tooltip: {\n show: false,\n },\n series: statSeries,\n };\n\n return option;\n }, [data, chartsTheme, sparkline, colorMode]);\n\n const textAlignment = sparkline ? 'auto' : 'center';\n\n const styledFormattedValue = useMemo(() => {\n let valueColor = '';\n\n switch (colorMode) {\n case 'background_solid':\n valueColor =\n chroma.contrast(color, WHITE_COLOR_CODE) > chroma.contrast(color, BLACK_COLOR_CODE)\n ? WHITE_COLOR_CODE\n : BLACK_COLOR_CODE;\n break;\n case 'none':\n valueColor = paletteMode === 'dark' ? WHITE_COLOR_CODE : BLACK_COLOR_CODE;\n break;\n case 'value':\n default:\n valueColor = color;\n break;\n }\n\n return (\n <Value variant=\"h3\" color={valueColor} fontSize={optimalValueFontSize} padding={containerPadding}>\n {formattedValue}\n </Value>\n );\n }, [colorMode, containerPadding, optimalValueFontSize, formattedValue, color, paletteMode]);\n\n const seriesName = useMemo((): ReactNode | null => {\n if (!showSeriesName) return null;\n\n let textColor = '';\n\n switch (colorMode) {\n case 'background_solid':\n textColor =\n chroma.contrast(color, WHITE_COLOR_CODE) > chroma.contrast(color, BLACK_COLOR_CODE)\n ? WHITE_COLOR_CODE\n : BLACK_COLOR_CODE;\n break;\n case 'none':\n case 'value':\n default:\n textColor = secondary;\n break;\n }\n\n return (\n <SeriesName padding={containerPadding} fontSize={seriesNameFontSize} color={textColor}>\n {data.seriesData?.name}\n </SeriesName>\n );\n }, [colorMode, showSeriesName, secondary, color, containerPadding, seriesNameFontSize, data?.seriesData?.name]);\n\n return (\n <Box\n sx={{\n height: '100%',\n width: '100%',\n backgroundColor: colorMode === 'background_solid' ? color : 'transparent',\n display: 'flex',\n flexDirection: 'column',\n justifyContent: textAlignment,\n alignItems: textAlignment,\n }}\n >\n {seriesName}\n {styledFormattedValue}\n {sparkline && (\n <EChart\n sx={{\n width: '100%',\n }}\n style={{\n // ECharts rounds the height to the nearest integer by default.\n // This can cause unneccessary scrollbars when the total height of this chart exceeds the 'height' prop.\n height: Math.floor(height - seriesNameHeight - valueFontHeight),\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n renderer=\"svg\"\n />\n )}\n </Box>\n );\n};\n\nconst SeriesName = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'padding' && prop !== 'fontSize',\n})<{ padding?: number; fontSize?: number; textAlignment?: string; color?: string }>(({ padding, fontSize, color }) => ({\n color: color,\n padding: `${padding}px`,\n fontSize: `${fontSize}px`,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}));\n\nconst Value = styled(Typography, {\n shouldForwardProp: (prop) => prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline',\n})<{ color?: string; padding?: number; fontSize?: number; sparkline?: boolean }>(\n ({ theme, color, padding, fontSize, sparkline }) => ({\n color: color ?? theme.palette.text.primary,\n fontSize: `${fontSize}px`,\n padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,\n whiteSpace: 'nowrap',\n lineHeight: LINE_HEIGHT,\n }),\n);\n"],"names":["Box","Typography","styled","useTheme","EChart","useChartsTheme","chroma","LineChart","EChartsLineChart","GridComponent","DatasetComponent","TitleComponent","TooltipComponent","use","registerECharts","CanvasRenderer","merge","useMemo","useOptimalFontSize","formatStatChartValue","LINE_HEIGHT","SERIES_NAME_MAX_FONT_SIZE","SERIES_NAME_FONT_WEIGHT","VALUE_FONT_WEIGHT","WHITE_COLOR_CODE","BLACK_COLOR_CODE","StatChartBase","props","width","height","data","color","sparkline","showSeriesName","format","valueFontSize","colorMode","palette","mode","paletteMode","text","secondary","chartsTheme","formattedValue","calculatedValue","containerPadding","container","padding","default","seriesNameFontSize","seriesData","name","fontWeight","lineHeight","maxSize","seriesNameHeight","availableWidth","availableHeight","optimalValueFontSize","fontSizeOverride","valueFontHeight","Math","min","option","noDataOption","series","statSeries","lineSeries","type","values","zlevel","symbol","animation","silent","clonedSparkLine","areaStyle","opacity","lineStyle","mergedSeries","push","title","show","grid","top","right","bottom","left","containLabel","xAxis","boundaryGap","yAxis","value","tooltip","textAlignment","styledFormattedValue","valueColor","contrast","Value","variant","fontSize","seriesName","textColor","SeriesName","sx","backgroundColor","display","flexDirection","justifyContent","alignItems","style","floor","theme","echartsTheme","renderer","shouldForwardProp","prop","overflow","textOverflow","whiteSpace","primary"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,gBAAgB;AAElE,SAASC,MAAM,EAAEC,cAAc,QAAQ,yBAA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C,GAAG,EAAEA,QAAQ,EAAE,CAAC;QACnFuE,YAAY;QACZjE,YAAYjC;IACd,CAAA"}
@@ -1,4 +1,4 @@
1
- import { ReactElement } from 'react';
2
- import { StatChartOptionsEditorProps } from './stat-chart-model';
1
+ import type { ReactElement } from 'react';
2
+ import type { StatChartOptionsEditorProps } from './stat-chart-model';
3
3
  export declare function StatChartOptionsEditorSettings(props: StatChartOptionsEditorProps): ReactElement;
4
4
  //# sourceMappingURL=StatChartOptionsEditorSettings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../src/StatChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AAqCA,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAC3D,OAAO,EAML,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAI5B,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,2BAA2B,GAAG,YAAY,CA0I/F"}
1
+ {"version":3,"file":"StatChartOptionsEditorSettings.d.ts","sourceRoot":"","sources":["../../src/StatChartOptionsEditorSettings.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAIV,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAK5B,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,2BAA2B,GAAG,YAAY,CA0I/F"}
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
1
  // Copyright The Perses Authors
3
2
  // Licensed under the Apache License, Version 2.0 (the "License");
4
3
  // you may not use this file except in compliance with the License.
@@ -11,13 +10,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
11
  // See the License for the specific language governing permissions and
13
12
  // limitations under the License.
14
- import { Switch } from '@mui/material';
15
- import { FontSizeSelector, FormatControls, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, SettingsAutocomplete, ThresholdsEditor } from '@perses-dev/components';
16
- import { CalculationSelector, MetricLabelInput } from '@perses-dev/plugin-system';
17
- import { produce } from 'immer';
18
- import merge from 'lodash/merge';
19
- import { useCallback, useMemo } from 'react';
20
- import { COLOR_MODE_LABELS, SHOW_LEGEND_LABELS } from './stat-chart-model';
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Switch } from "@mui/material";
15
+ import { FontSizeSelector, FormatControls, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, SettingsAutocomplete, ThresholdsEditor } from "@perses-dev/components";
16
+ import { CalculationSelector, MetricLabelInput } from "@perses-dev/plugin-system";
17
+ import { produce } from "immer";
18
+ import merge from "lodash/merge";
19
+ import { useCallback, useMemo } from "react";
20
+ import { COLOR_MODE_LABELS, SHOW_LEGEND_LABELS } from "./stat-chart-model.js";
21
21
  const DEFAULT_FORMAT = {
22
22
  unit: 'percent-decimal'
23
23
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StatChartOptionsEditorSettings.tsx"],"sourcesContent":["// Copyright 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 { Switch, SwitchProps } from '@mui/material';\nimport {\n FontSizeOption,\n FontSizeSelector,\n FontSizeSelectorProps,\n FormatControls,\n FormatControlsProps,\n FormatOptions,\n OptionsEditorColumn,\n OptionsEditorControl,\n OptionsEditorGrid,\n OptionsEditorGroup,\n SettingsAutocomplete,\n ThresholdsEditor,\n ThresholdsEditorProps,\n} from '@perses-dev/components';\nimport {\n CalculationSelector,\n CalculationSelectorProps,\n MetricLabelInput,\n MetricLabelInputProps,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport { ReactElement, useCallback, useMemo } from 'react';\nimport {\n COLOR_MODE_LABELS,\n ColorModeLabelItem,\n SHOW_LEGEND_LABELS,\n ShowLegendLabelItem,\n StatChartOptions,\n StatChartOptionsEditorProps,\n} from './stat-chart-model';\n\nconst DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\n\nexport function StatChartOptionsEditorSettings(props: StatChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n // ensures decimalPlaces defaults to correct value\n const format = merge({}, DEFAULT_FORMAT, value.format);\n\n const handleCalculationChange: CalculationSelectorProps['onChange'] = (metricLabel) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.calculation = metricLabel;\n })\n );\n };\n\n const handleMetricLabelChange: MetricLabelInputProps['onChange'] = (newCalculation) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.metricLabel = newCalculation;\n })\n );\n };\n\n const handleShowLegendChange = useCallback(\n (_: unknown, newShowLegend: ShowLegendLabelItem): void => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.legendMode = newShowLegend.id;\n })\n );\n },\n [onChange, value]\n );\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.format = newFormat;\n })\n );\n };\n\n const handleSparklineChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n // For now, setting to an empty object when checked, so the stat chart\n // uses the default chart color and line styles. In the future, this\n // will likely be configurable in the UI.\n draft.sparkline = checked ? {} : undefined;\n })\n );\n };\n\n const handleThresholdsChange: ThresholdsEditorProps['onChange'] = (thresholds) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.thresholds = thresholds;\n })\n );\n };\n\n const handleFontSizeChange: FontSizeSelectorProps['onChange'] = (fontSize: FontSizeOption) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.valueFontSize = fontSize;\n })\n );\n };\n\n const handleColorModeChange = useCallback(\n (_: unknown, newColorMode: ColorModeLabelItem): void => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.colorMode = newColorMode.id;\n })\n );\n },\n [onChange, value]\n );\n\n const selectShowLegend = useMemo((): ReactElement => {\n return (\n <OptionsEditorControl\n label=\"Show\"\n control={\n <SettingsAutocomplete\n onChange={handleShowLegendChange}\n options={SHOW_LEGEND_LABELS}\n disableClearable\n value={\n SHOW_LEGEND_LABELS.find((i) => i.id === value.legendMode) ??\n SHOW_LEGEND_LABELS.find((i) => i.id === 'auto')!\n }\n />\n }\n />\n );\n }, [value.legendMode, handleShowLegendChange]);\n\n const selectColorMode = useMemo((): ReactElement => {\n return (\n <OptionsEditorControl\n label=\"Color mode\"\n control={\n <SettingsAutocomplete\n onChange={handleColorModeChange}\n options={COLOR_MODE_LABELS.map(({ id, label }) => ({ id, label }))}\n disableClearable\n value={\n COLOR_MODE_LABELS.find((i) => i.id === value.colorMode) ??\n COLOR_MODE_LABELS.find((i) => i.id === 'value')!\n }\n />\n }\n />\n );\n }, [value.colorMode, handleColorModeChange]);\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Legend\">{selectShowLegend}</OptionsEditorGroup>\n <OptionsEditorGroup title=\"Misc\">\n <OptionsEditorControl\n label=\"Sparkline\"\n control={<Switch checked={!!value.sparkline} onChange={handleSparklineChange} />}\n />\n <FormatControls value={format} onChange={handleUnitChange} />\n <CalculationSelector value={value.calculation} onChange={handleCalculationChange} />\n <MetricLabelInput value={value.metricLabel} onChange={handleMetricLabelChange} />\n <FontSizeSelector value={value.valueFontSize} onChange={handleFontSizeChange} />\n {selectColorMode}\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <ThresholdsEditor disablePercentMode thresholds={value.thresholds} onChange={handleThresholdsChange} />\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["Switch","FontSizeSelector","FormatControls","OptionsEditorColumn","OptionsEditorControl","OptionsEditorGrid","OptionsEditorGroup","SettingsAutocomplete","ThresholdsEditor","CalculationSelector","MetricLabelInput","produce","merge","useCallback","useMemo","COLOR_MODE_LABELS","SHOW_LEGEND_LABELS","DEFAULT_FORMAT","unit","StatChartOptionsEditorSettings","props","onChange","value","format","handleCalculationChange","metricLabel","draft","calculation","handleMetricLabelChange","newCalculation","handleShowLegendChange","_","newShowLegend","legendMode","id","handleUnitChange","newFormat","handleSparklineChange","checked","sparkline","undefined","handleThresholdsChange","thresholds","handleFontSizeChange","fontSize","valueFontSize","handleColorModeChange","newColorMode","colorMode","selectShowLegend","label","control","options","disableClearable","find","i","selectColorMode","map","title","disablePercentMode"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,QAAqB,gBAAgB;AACpD,SAEEC,gBAAgB,EAEhBC,cAAc,EAGdC,mBAAmB,EACnBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,oBAAoB,EACpBC,gBAAgB,QAEX,yBAAyB;AAChC,SACEC,mBAAmB,EAEnBC,gBAAgB,QAEX,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,WAAW,eAAe;AACjC,SAAuBC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAC3D,SACEC,iBAAiB,EAEjBC,kBAAkB,QAIb,qBAAqB;AAE5B,MAAMC,iBAAgC;IAAEC,MAAM;AAAkB;AAEhE,OAAO,SAASC,+BAA+BC,KAAkC;IAC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B;;;;;AAIrF"}
1
+ {"version":3,"sources":["../../src/StatChartOptionsEditorSettings.tsx"],"sourcesContent":["// Copyright 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 type { SwitchProps } from '@mui/material';\nimport { Switch } from '@mui/material';\nimport type {\n FontSizeOption,\n FontSizeSelectorProps,\n FormatControlsProps,\n FormatOptions,\n ThresholdsEditorProps,\n} from '@perses-dev/components';\nimport {\n FontSizeSelector,\n FormatControls,\n OptionsEditorColumn,\n OptionsEditorControl,\n OptionsEditorGrid,\n OptionsEditorGroup,\n SettingsAutocomplete,\n ThresholdsEditor,\n} from '@perses-dev/components';\nimport type { CalculationSelectorProps, MetricLabelInputProps } from '@perses-dev/plugin-system';\nimport { CalculationSelector, MetricLabelInput } from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport merge from 'lodash/merge';\nimport type { ReactElement } from 'react';\nimport { useCallback, useMemo } from 'react';\n\nimport type {\n ColorModeLabelItem,\n ShowLegendLabelItem,\n StatChartOptions,\n StatChartOptionsEditorProps,\n} from './stat-chart-model';\nimport { COLOR_MODE_LABELS, SHOW_LEGEND_LABELS } from './stat-chart-model';\n\nconst DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\n\nexport function StatChartOptionsEditorSettings(props: StatChartOptionsEditorProps): ReactElement {\n const { onChange, value } = props;\n\n // ensures decimalPlaces defaults to correct value\n const format = merge({}, DEFAULT_FORMAT, value.format);\n\n const handleCalculationChange: CalculationSelectorProps['onChange'] = (metricLabel) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.calculation = metricLabel;\n }),\n );\n };\n\n const handleMetricLabelChange: MetricLabelInputProps['onChange'] = (newCalculation) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.metricLabel = newCalculation;\n }),\n );\n };\n\n const handleShowLegendChange = useCallback(\n (_: unknown, newShowLegend: ShowLegendLabelItem): void => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.legendMode = newShowLegend.id;\n }),\n );\n },\n [onChange, value],\n );\n\n const handleUnitChange: FormatControlsProps['onChange'] = (newFormat) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.format = newFormat;\n }),\n );\n };\n\n const handleSparklineChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n // For now, setting to an empty object when checked, so the stat chart\n // uses the default chart color and line styles. In the future, this\n // will likely be configurable in the UI.\n draft.sparkline = checked ? {} : undefined;\n }),\n );\n };\n\n const handleThresholdsChange: ThresholdsEditorProps['onChange'] = (thresholds) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.thresholds = thresholds;\n }),\n );\n };\n\n const handleFontSizeChange: FontSizeSelectorProps['onChange'] = (fontSize: FontSizeOption) => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.valueFontSize = fontSize;\n }),\n );\n };\n\n const handleColorModeChange = useCallback(\n (_: unknown, newColorMode: ColorModeLabelItem): void => {\n onChange(\n produce(value, (draft: StatChartOptions) => {\n draft.colorMode = newColorMode.id;\n }),\n );\n },\n [onChange, value],\n );\n\n const selectShowLegend = useMemo((): ReactElement => {\n return (\n <OptionsEditorControl\n label=\"Show\"\n control={\n <SettingsAutocomplete\n onChange={handleShowLegendChange}\n options={SHOW_LEGEND_LABELS}\n disableClearable\n value={\n SHOW_LEGEND_LABELS.find((i) => i.id === value.legendMode) ??\n SHOW_LEGEND_LABELS.find((i) => i.id === 'auto')!\n }\n />\n }\n />\n );\n }, [value.legendMode, handleShowLegendChange]);\n\n const selectColorMode = useMemo((): ReactElement => {\n return (\n <OptionsEditorControl\n label=\"Color mode\"\n control={\n <SettingsAutocomplete\n onChange={handleColorModeChange}\n options={COLOR_MODE_LABELS.map(({ id, label }) => ({ id, label }))}\n disableClearable\n value={\n COLOR_MODE_LABELS.find((i) => i.id === value.colorMode) ??\n COLOR_MODE_LABELS.find((i) => i.id === 'value')!\n }\n />\n }\n />\n );\n }, [value.colorMode, handleColorModeChange]);\n\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Legend\">{selectShowLegend}</OptionsEditorGroup>\n <OptionsEditorGroup title=\"Misc\">\n <OptionsEditorControl\n label=\"Sparkline\"\n control={<Switch checked={!!value.sparkline} onChange={handleSparklineChange} />}\n />\n <FormatControls value={format} onChange={handleUnitChange} />\n <CalculationSelector value={value.calculation} onChange={handleCalculationChange} />\n <MetricLabelInput value={value.metricLabel} onChange={handleMetricLabelChange} />\n <FontSizeSelector value={value.valueFontSize} onChange={handleFontSizeChange} />\n {selectColorMode}\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <ThresholdsEditor disablePercentMode thresholds={value.thresholds} onChange={handleThresholdsChange} />\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["Switch","FontSizeSelector","FormatControls","OptionsEditorColumn","OptionsEditorControl","OptionsEditorGrid","OptionsEditorGroup","SettingsAutocomplete","ThresholdsEditor","CalculationSelector","MetricLabelInput","produce","merge","useCallback","useMemo","COLOR_MODE_LABELS","SHOW_LEGEND_LABELS","DEFAULT_FORMAT","unit","StatChartOptionsEditorSettings","props","onChange","value","format","handleCalculationChange","metricLabel","draft","calculation","handleMetricLabelChange","newCalculation","handleShowLegendChange","_","newShowLegend","legendMode","id","handleUnitChange","newFormat","handleSparklineChange","checked","sparkline","undefined","handleThresholdsChange","thresholds","handleFontSizeChange","fontSize","valueFontSize","handleColorModeChange","newColorMode","colorMode","selectShowLegend","label","control","options","disableClearable","find","i","selectColorMode","map","title","disablePercentMode"],"mappings":"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,EAAErB,EAAE,KAAK;;;IAMnD,GAAG;QAACZ,MAAM0B,SAAS;QAAEF;KAAsB;IAE3C,qBACE,MAACzC;;0BACC,MAACF;;kCACC,KAACG;wBAAmBoD,OAAM;kCAAUT;;kCACpC,MAAC3C;wBAAmBoD,OAAM;;0CACxB,KAACtD;gCACC8C,OAAM;gCACNC,uBAAS,KAACnD;oCAAOsC,SAAS,CAAC,CAAChB,MAAMiB,SAAS;oCAAElB,UAAUgB;;;0CAEzD,KAACnC;gCAAeoB,OAAOC;gCAAQF,UAAUc;;0CACzC,KAAC1B;gCAAoBa,OAAOA,MAAMK,WAAW;gCAAEN,UAAUG;;0CACzD,KAACd;gCAAiBY,OAAOA,MAAMG,WAAW;gCAAEJ,UAAUO;;0CACtD,KAAC3B;gCAAiBqB,OAAOA,MAAMuB,aAAa;gCAAExB,UAAUsB;;4BACvDa;;;;;0BAGL,KAACrD;0BACC,cAAA,KAACK;oBAAiBmD,kBAAkB;oBAACjB,YAAYpB,MAAMoB,UAAU;oBAAErB,UAAUoB;;;;;AAIrF"}
@@ -1,7 +1,7 @@
1
- import { FC } from 'react';
2
- import { PanelProps } from '@perses-dev/plugin-system';
3
- import { TimeSeriesData } from '@perses-dev/spec';
4
- import { StatChartOptions } from './stat-chart-model';
1
+ import type { PanelProps } from '@perses-dev/plugin-system';
2
+ import type { TimeSeriesData } from '@perses-dev/spec';
3
+ import type { FC } from 'react';
4
+ import type { StatChartOptions } from './stat-chart-model';
5
5
  export type StatChartPanelProps = PanelProps<StatChartOptions, TimeSeriesData>;
6
6
  export declare const StatChartPanel: FC<StatChartPanelProps>;
7
7
  //# sourceMappingURL=StatChartPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatChartPanel.d.ts","sourceRoot":"","sources":["../../src/StatChartPanel.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAa,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAU,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;AAE/E,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA0DlD,CAAC"}
1
+ {"version":3,"file":"StatChartPanel.d.ts","sourceRoot":"","sources":["../../src/StatChartPanel.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EAAU,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;AAE/E,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA+DlD,CAAC"}
@@ -11,23 +11,28 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { useChartsTheme, applyValueMapping, createRegexFromString } from '@perses-dev/components';
15
- import { Stack, Typography } from '@mui/material';
16
- import { useMemo } from 'react';
17
- import { convertSparkline } from './utils/data-transform';
18
- import { calculateValue } from './utils/calculate-value';
19
- import { getStatChartColor } from './utils/get-color';
20
- import { StatChartBase } from './StatChartBase';
14
+ import { Stack, Typography } from "@mui/material";
15
+ import { useChartsTheme, applyValueMapping, createRegexFromString } from "@perses-dev/components";
16
+ import { useMemo } from "react";
17
+ import { StatChartBase } from "./StatChartBase.js";
18
+ import { calculateValue } from "./utils/calculate-value.js";
19
+ import { convertSparkline } from "./utils/data-transform.js";
20
+ import { getStatChartColor } from "./utils/get-color.js";
21
21
  const MIN_WIDTH = 100;
22
22
  const SPACING = 2;
23
23
  export const StatChartPanel = (props)=>{
24
24
  const { spec, contentDimensions, queryResults } = props;
25
- const { format, sparkline, valueFontSize: valueFontSize, colorMode } = spec;
25
+ const { format, sparkline, valueFontSize, colorMode } = spec;
26
26
  const chartsTheme = useChartsTheme();
27
27
  const statChartData = useStatChartData(queryResults, spec, chartsTheme);
28
28
  const isMultiSeries = statChartData.length > 1;
29
29
  // Handle three-state showLegend: 'on' | 'off' | 'auto' (or undefined for backward compatibility)
30
- const shouldShowLegend = spec.legendMode === 'on' ? true : spec.legendMode === 'off' ? false : isMultiSeries;
30
+ let shouldShowLegend = isMultiSeries;
31
+ if (spec.legendMode === 'on') {
32
+ shouldShowLegend = true;
33
+ } else if (spec.legendMode === 'off') {
34
+ shouldShowLegend = false;
35
+ }
31
36
  if (!contentDimensions) return null;
32
37
  // Calculates chart width
33
38
  const spacing = SPACING * (statChartData.length - 1);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StatChartPanel.tsx"],"sourcesContent":["// Copyright 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 { TitleComponentOption } from 'echarts';\nimport {\n useChartsTheme,\n GraphSeries,\n PersesChartsTheme,\n ValueMapping,\n applyValueMapping,\n createRegexFromString,\n} from '@perses-dev/components';\nimport { Stack, Typography, SxProps } from '@mui/material';\nimport { FC, useMemo } from 'react';\nimport { PanelProps, PanelData } from '@perses-dev/plugin-system';\nimport { Labels, TimeSeriesData } from '@perses-dev/spec';\nimport { StatChartOptions } from './stat-chart-model';\nimport { convertSparkline } from './utils/data-transform';\nimport { calculateValue } from './utils/calculate-value';\nimport { getStatChartColor } from './utils/get-color';\nimport { StatChartBase, StatChartData } from './StatChartBase';\n\nconst MIN_WIDTH = 100;\nconst SPACING = 2;\n\nexport type StatChartPanelProps = PanelProps<StatChartOptions, TimeSeriesData>;\n\nexport const StatChartPanel: FC<StatChartPanelProps> = (props) => {\n const { spec, contentDimensions, queryResults } = props;\n\n const { format, sparkline, valueFontSize: valueFontSize, colorMode } = spec;\n const chartsTheme = useChartsTheme();\n const statChartData = useStatChartData(queryResults, spec, chartsTheme);\n\n const isMultiSeries = statChartData.length > 1;\n\n // Handle three-state showLegend: 'on' | 'off' | 'auto' (or undefined for backward compatibility)\n const shouldShowLegend = spec.legendMode === 'on' ? true : spec.legendMode === 'off' ? false : isMultiSeries;\n\n if (!contentDimensions) return null;\n\n // Calculates chart width\n const spacing = SPACING * (statChartData.length - 1);\n let chartWidth = (contentDimensions.width - spacing) / statChartData.length;\n if (isMultiSeries && chartWidth < MIN_WIDTH) {\n chartWidth = MIN_WIDTH;\n }\n\n const noDataTextStyle = (chartsTheme.noDataOption.title as TitleComponentOption).textStyle;\n\n return (\n <Stack\n height={contentDimensions.height}\n width={contentDimensions.width}\n spacing={`${SPACING}px`}\n direction=\"row\"\n justifyContent={isMultiSeries ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n overflowX: isMultiSeries ? 'scroll' : 'auto',\n }}\n >\n {statChartData.length ? (\n statChartData.map((series, index) => {\n const sparklineConfig = convertSparkline(chartsTheme, series.color, sparkline);\n\n return (\n <StatChartBase\n key={index}\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n sparkline={sparklineConfig}\n showSeriesName={shouldShowLegend}\n valueFontSize={valueFontSize}\n colorMode={colorMode}\n />\n );\n })\n ) : (\n <Typography sx={{ ...noDataTextStyle } as SxProps}>No data</Typography>\n )}\n </Stack>\n );\n};\n\nconst useStatChartData = (\n queryResults: Array<PanelData<TimeSeriesData>>,\n spec: StatChartOptions,\n chartsTheme: PersesChartsTheme\n): StatChartData[] => {\n return useMemo(() => {\n const { calculation, mappings, metricLabel } = spec;\n\n const statChartData: StatChartData[] = [];\n for (const result of queryResults) {\n for (const seriesData of result.data.series) {\n const calculatedValue = calculateValue(calculation, seriesData);\n\n // get label metric value\n const labelValue = getLabelValue(metricLabel, seriesData.labels);\n\n // get actual value to display\n const displayValue = getValueOrLabel(calculatedValue, mappings, labelValue);\n\n const color = getStatChartColor(chartsTheme, spec, calculatedValue);\n\n const series: GraphSeries = {\n name: seriesData.formattedName ?? '',\n values: seriesData.values,\n };\n\n statChartData.push({ calculatedValue: displayValue, seriesData: series, color });\n }\n }\n return statChartData;\n }, [queryResults, spec, chartsTheme]);\n};\n\nconst getValueOrLabel = (\n value?: number | null,\n mappings?: ValueMapping[],\n label?: string\n): string | number | undefined | null => {\n if (label) {\n return label;\n }\n if (mappings?.length && value !== undefined && value !== null) {\n return applyValueMapping(value, mappings).value;\n } else {\n return value;\n }\n};\n\nconst getLabelValue = (fieldLabel?: string, labels?: Labels): string | undefined => {\n if (!labels || !fieldLabel) {\n return undefined;\n }\n for (const [key, value] of Object.entries(labels)) {\n const regex = createRegexFromString(fieldLabel);\n if (regex.test(key)) {\n return value;\n }\n }\n return undefined;\n};\n"],"names":["useChartsTheme","applyValueMapping","createRegexFromString","Stack","Typography","useMemo","convertSparkline","calculateValue","getStatChartColor","StatChartBase","MIN_WIDTH","SPACING","StatChartPanel","props","spec","contentDimensions","queryResults","format","sparkline","valueFontSize","colorMode","chartsTheme","statChartData","useStatChartData","isMultiSeries","length","shouldShowLegend","legendMode","spacing","chartWidth","width","noDataTextStyle","noDataOption","title","textStyle","height","direction","justifyContent","alignItems","sx","overflowX","map","series","index","sparklineConfig","color","data","showSeriesName","calculation","mappings","metricLabel","result","seriesData","calculatedValue","labelValue","getLabelValue","labels","displayValue","getValueOrLabel","name","formattedName","values","push","value","label","undefined","fieldLabel","key","Object","entries","regex","test"],"mappings":"AAAA,+BAA+B;AAC/B,kEA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;YAChF;QACF;QACA,OAAOvB;IACT,GAAG;QAACN;QAAcF;QAAMO;KAAY;AACtC;AAEA,MAAMqC,kBAAkB,CACtBK,OACAd,UACAe;IAEA,IAAIA,OAAO;QACT,OAAOA;IACT;IACA,IAAIf,UAAUxB,UAAUsC,UAAUE,aAAaF,UAAU,MAAM;QAC7D,OAAO9D,kBAAkB8D,OAAOd,UAAUc,KAAK;IACjD,OAAO;QACL,OAAOA;IACT;AACF;AAEA,MAAMR,gBAAgB,CAACW,YAAqBV;IAC1C,IAAI,CAACA,UAAU,CAACU,YAAY;QAC1B,OAAOD;IACT;IACA,KAAK,MAAM,CAACE,KAAKJ,MAAM,IAAIK,OAAOC,OAAO,CAACb,QAAS;QACjD,MAAMc,QAAQpE,sBAAsBgE;QACpC,IAAII,MAAMC,IAAI,CAACJ,MAAM;YACnB,OAAOJ;QACT;IACF;IACA,OAAOE;AACT"}
1
+ {"version":3,"sources":["../../src/StatChartPanel.tsx"],"sourcesContent":["// Copyright 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 type { SxProps } from '@mui/material';\nimport { Stack, Typography } from '@mui/material';\nimport type { GraphSeries, PersesChartsTheme, ValueMapping } from '@perses-dev/components';\nimport { useChartsTheme, applyValueMapping, createRegexFromString } from '@perses-dev/components';\nimport type { PanelProps, PanelData } from '@perses-dev/plugin-system';\nimport type { Labels, TimeSeriesData } from '@perses-dev/spec';\nimport type { TitleComponentOption } from 'echarts';\nimport type { FC } from 'react';\nimport { useMemo } from 'react';\n\nimport type { StatChartOptions } from './stat-chart-model';\nimport type { StatChartData } from './StatChartBase';\nimport { StatChartBase } from './StatChartBase';\nimport { calculateValue } from './utils/calculate-value';\nimport { convertSparkline } from './utils/data-transform';\nimport { getStatChartColor } from './utils/get-color';\n\nconst MIN_WIDTH = 100;\nconst SPACING = 2;\n\nexport type StatChartPanelProps = PanelProps<StatChartOptions, TimeSeriesData>;\n\nexport const StatChartPanel: FC<StatChartPanelProps> = (props) => {\n const { spec, contentDimensions, queryResults } = props;\n\n const { format, sparkline, valueFontSize, colorMode } = spec;\n const chartsTheme = useChartsTheme();\n const statChartData = useStatChartData(queryResults, spec, chartsTheme);\n\n const isMultiSeries = statChartData.length > 1;\n\n // Handle three-state showLegend: 'on' | 'off' | 'auto' (or undefined for backward compatibility)\n let shouldShowLegend = isMultiSeries;\n if (spec.legendMode === 'on') {\n shouldShowLegend = true;\n } else if (spec.legendMode === 'off') {\n shouldShowLegend = false;\n }\n\n if (!contentDimensions) return null;\n\n // Calculates chart width\n const spacing = SPACING * (statChartData.length - 1);\n let chartWidth = (contentDimensions.width - spacing) / statChartData.length;\n if (isMultiSeries && chartWidth < MIN_WIDTH) {\n chartWidth = MIN_WIDTH;\n }\n\n const noDataTextStyle = (chartsTheme.noDataOption.title as TitleComponentOption).textStyle;\n\n return (\n <Stack\n height={contentDimensions.height}\n width={contentDimensions.width}\n spacing={`${SPACING}px`}\n direction=\"row\"\n justifyContent={isMultiSeries ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n overflowX: isMultiSeries ? 'scroll' : 'auto',\n }}\n >\n {statChartData.length ? (\n statChartData.map((series, index) => {\n const sparklineConfig = convertSparkline(chartsTheme, series.color, sparkline);\n\n return (\n <StatChartBase\n key={index}\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n sparkline={sparklineConfig}\n showSeriesName={shouldShowLegend}\n valueFontSize={valueFontSize}\n colorMode={colorMode}\n />\n );\n })\n ) : (\n <Typography sx={{ ...noDataTextStyle } as SxProps}>No data</Typography>\n )}\n </Stack>\n );\n};\n\nconst useStatChartData = (\n queryResults: Array<PanelData<TimeSeriesData>>,\n spec: StatChartOptions,\n chartsTheme: PersesChartsTheme,\n): StatChartData[] => {\n return useMemo(() => {\n const { calculation, mappings, metricLabel } = spec;\n\n const statChartData: StatChartData[] = [];\n for (const result of queryResults) {\n for (const seriesData of result.data.series) {\n const calculatedValue = calculateValue(calculation, seriesData);\n\n // get label metric value\n const labelValue = getLabelValue(metricLabel, seriesData.labels);\n\n // get actual value to display\n const displayValue = getValueOrLabel(calculatedValue, mappings, labelValue);\n\n const color = getStatChartColor(chartsTheme, spec, calculatedValue);\n\n const series: GraphSeries = {\n name: seriesData.formattedName ?? '',\n values: seriesData.values,\n };\n\n statChartData.push({ calculatedValue: displayValue, seriesData: series, color });\n }\n }\n return statChartData;\n }, [queryResults, spec, chartsTheme]);\n};\n\nconst getValueOrLabel = (\n value?: number | null,\n mappings?: ValueMapping[],\n label?: string,\n): string | number | undefined | null => {\n if (label) {\n return label;\n }\n if (mappings?.length && value !== undefined && value !== null) {\n return applyValueMapping(value, mappings).value;\n } else {\n return value;\n }\n};\n\nconst getLabelValue = (fieldLabel?: string, labels?: Labels): string | undefined => {\n if (!labels || !fieldLabel) {\n return undefined;\n }\n for (const [key, value] of Object.entries(labels)) {\n const regex = createRegexFromString(fieldLabel);\n if (regex.test(key)) {\n return value;\n }\n }\n return undefined;\n};\n"],"names":["Stack","Typography","useChartsTheme","applyValueMapping","createRegexFromString","useMemo","StatChartBase","calculateValue","convertSparkline","getStatChartColor","MIN_WIDTH","SPACING","StatChartPanel","props","spec","contentDimensions","queryResults","format","sparkline","valueFontSize","colorMode","chartsTheme","statChartData","useStatChartData","isMultiSeries","length","shouldShowLegend","legendMode","spacing","chartWidth","width","noDataTextStyle","noDataOption","title","textStyle","height","direction","justifyContent","alignItems","sx","overflowX","map","series","index","sparklineConfig","color","data","showSeriesName","calculation","mappings","metricLabel","result","seriesData","calculatedValue","labelValue","getLabelValue","labels","displayValue","getValueOrLabel","name","formattedName","values","push","value","label","undefined","fieldLabel","key","Object","ent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AAM;gBAC3B;gBAEAvC,cAAcwC,IAAI,CAAC;oBAAET,iBAAiBI;oBAAcL,YAAYV;oBAAQG;gBAAM;YAChF;QACF;QACA,OAAOvB;IACT,GAAG;QAACN;QAAcF;QAAMO;KAAY;AACtC;AAEA,MAAMqC,kBAAkB,CACtBK,OACAd,UACAe;IAEA,IAAIA,OAAO;QACT,OAAOA;IACT;IACA,IAAIf,UAAUxB,UAAUsC,UAAUE,aAAaF,UAAU,MAAM;QAC7D,OAAO5D,kBAAkB4D,OAAOd,UAAUc,KAAK;IACjD,OAAO;QACL,OAAOA;IACT;AACF;AAEA,MAAMR,gBAAgB,CAACW,YAAqBV;IAC1C,IAAI,CAACA,UAAU,CAACU,YAAY;QAC1B,OAAOD;IACT;IACA,KAAK,MAAM,CAACE,KAAKJ,MAAM,IAAIK,OAAOC,OAAO,CAACb,QAAS;QACjD,MAAMc,QAAQlE,sBAAsB8D;QACpC,IAAII,MAAMC,IAAI,CAACJ,MAAM;YACnB,OAAOJ;QACT;IACF;IACA,OAAOE;AACT"}
@@ -1,6 +1,6 @@
1
- import { OptionsEditorProps } from '@perses-dev/plugin-system';
2
- import { FC } from 'react';
3
- import { StatChartOptions } from './stat-chart-model';
1
+ import type { OptionsEditorProps } from '@perses-dev/plugin-system';
2
+ import type { FC } from 'react';
3
+ import type { StatChartOptions } from './stat-chart-model';
4
4
  export type StatChartValueMappingEditorProps = OptionsEditorProps<StatChartOptions>;
5
5
  export declare const StatChartValueMappingEditor: FC<StatChartValueMappingEditorProps>;
6
6
  //# sourceMappingURL=StatChartValueMappingEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StatChartValueMappingEditor.d.ts","sourceRoot":"","sources":["../../src/StatChartValueMappingEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,gCAAgC,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;AAEpF,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC,gCAAgC,CAM5E,CAAC"}
1
+ {"version":3,"file":"StatChartValueMappingEditor.d.ts","sourceRoot":"","sources":["../../src/StatChartValueMappingEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,gCAAgC,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;AAEpF,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC,gCAAgC,CAM5E,CAAC"}
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { ValueMappingsEditor } from '@perses-dev/components';
14
+ import { ValueMappingsEditor } from "@perses-dev/components";
15
15
  export const StatChartValueMappingEditor = ({ onChange, value })=>{
16
16
  function handleValueMappingChange(mappings) {
17
17
  onChange({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/StatChartValueMappingEditor.tsx"],"sourcesContent":["// Copyright 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 { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { ValueMapping, ValueMappingsEditor } from '@perses-dev/components';\nimport { FC } from 'react';\nimport { StatChartOptions } from './stat-chart-model';\n\nexport type StatChartValueMappingEditorProps = OptionsEditorProps<StatChartOptions>;\n\nexport const StatChartValueMappingEditor: FC<StatChartValueMappingEditorProps> = ({ onChange, value }) => {\n function handleValueMappingChange(mappings: ValueMapping[]): void {\n onChange({ ...value, mappings });\n }\n\n return <ValueMappingsEditor mappings={value.mappings ?? []} onChange={handleValueMappingChange} />;\n};\n"],"names":["ValueMappingsEditor","StatChartValueMappingEditor","onChange","value","handleValueMappingChange","mappings"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAAuBA,mBAAmB,QAAQ,yBAAyB;AAM3E,OAAO,MAAMC,8BAAoE,CAAC,EAAEC,QAAQ,EAAEC,KAAK,EAAE;IACnG,SAASC,yBAAyBC,QAAwB;QACxDH,SAAS;YAAE,GAAGC,KAAK;YAAEE;QAAS;IAChC;IAEA,qBAAO,KAACL;QAAoBK,UAAUF,MAAME,QAAQ,IAAI,EAAE;QAAEH,UAAUE;;AACxE,EAAE"}
1
+ {"version":3,"sources":["../../src/StatChartValueMappingEditor.tsx"],"sourcesContent":["// Copyright 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 type { ValueMapping } from '@perses-dev/components';\nimport { ValueMappingsEditor } from '@perses-dev/components';\nimport type { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport type { FC } from 'react';\n\nimport type { StatChartOptions } from './stat-chart-model';\n\nexport type StatChartValueMappingEditorProps = OptionsEditorProps<StatChartOptions>;\n\nexport const StatChartValueMappingEditor: FC<StatChartValueMappingEditorProps> = ({ onChange, value }) => {\n function handleValueMappingChange(mappings: ValueMapping[]): void {\n onChange({ ...value, mappings });\n }\n\n return <ValueMappingsEditor mappings={value.mappings ?? []} onChange={handleValueMappingChange} />;\n};\n"],"names":["ValueMappingsEditor","StatChartValueMappingEditor","onChange","value","handleValueMappingChange","mappings"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,mBAAmB,QAAQ,yBAAyB;AAQ7D,OAAO,MAAMC,8BAAoE,CAAC,EAAEC,QAAQ,EAAEC,KAAK,EAAE;IACnG,SAASC,yBAAyBC,QAAwB;QACxDH,SAAS;YAAE,GAAGC,KAAK;YAAEE;QAAS;IAChC;IAEA,qBAAO,KAACL;QAAoBK,UAAUF,MAAME,QAAQ,IAAI,EAAE;QAAEH,UAAUE;;AACxE,EAAE"}
package/lib/bootstrap.js CHANGED
@@ -11,8 +11,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import React from 'react';
15
- import ReactDOM from 'react-dom/client';
14
+ import React from "react";
15
+ import ReactDOM from "react-dom/client";
16
16
  const root = ReactDOM.createRoot(document.getElementById('root'));
17
17
  root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
18
18
 
@@ -1,4 +1,4 @@
1
- import { PluginModuleResource } from '@perses-dev/plugin-system';
1
+ import type { PluginModuleResource } from '@perses-dev/plugin-system';
2
2
  /**
3
3
  * Returns the plugin module information from package.json
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
1
+ {"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAIxF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
@@ -10,7 +10,9 @@
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 packageJson from '../package.json';
13
+ import packageJson from "../package.json" with {
14
+ type: 'json'
15
+ };
14
16
  /**
15
17
  * Returns the plugin module information from package.json
16
18
  */ export function getPluginModule() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["// Copyright 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 { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAOA,iBAAiB,kBAAkB;AAE1C;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAClC,OAAO;QACLK,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
1
+ {"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["// Copyright 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 type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\n\nimport packageJson from '../package.json' with { type: 'json' };\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","type","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAOA,iBAAiB,uBAAuB;IAAEC,MAAM;AAAO,EAAE;AAEhE;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGL;IAClC,OAAO;QACLM,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
@@ -10,6 +10,6 @@
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('./bootstrap');
13
+ import("./bootstrap.js");
14
14
 
15
15
  //# sourceMappingURL=index-federation.js.map
package/lib/index.js CHANGED
@@ -10,12 +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
- export { getPluginModule } from './getPluginModule';
14
- export * from './stat-chart-model';
15
- export * from './StatChart';
16
- export * from './StatChartOptionsEditorSettings';
17
- export * from './StatChartPanel';
18
- export * from './StatChartValueMappingEditor';
19
- export * from './StatChartBase';
13
+ export { getPluginModule } from "./getPluginModule.js";
14
+ export * from "./stat-chart-model.js";
15
+ export * from "./StatChart.js";
16
+ export * from "./StatChartOptionsEditorSettings.js";
17
+ export * from "./StatChartPanel.js";
18
+ export * from "./StatChartValueMappingEditor.js";
19
+ export * from "./StatChartBase.js";
20
20
 
21
21
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright 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\nexport { getPluginModule } from './getPluginModule';\nexport * from './stat-chart-model';\nexport * from './StatChart';\nexport * from './StatChartOptionsEditorSettings';\nexport * from './StatChartPanel';\nexport * from './StatChartValueMappingEditor';\nexport * from './StatChartBase';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,mCAAmC;AACjD,cAAc,mBAAmB;AACjC,cAAc,gCAAgC;AAC9C,cAAc,kBAAkB"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright 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\nexport { getPluginModule } from './getPluginModule';\nexport * from './stat-chart-model';\nexport * from './StatChart';\nexport * from './StatChartOptionsEditorSettings';\nexport * from './StatChartPanel';\nexport * from './StatChartValueMappingEditor';\nexport * from './StatChartBase';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,eAAe,QAAQ,uBAAoB;AACpD,cAAc,wBAAqB;AACnC,cAAc,iBAAc;AAC5B,cAAc,sCAAmC;AACjD,cAAc,sBAAmB;AACjC,cAAc,mCAAgC;AAC9C,cAAc,qBAAkB"}
@@ -1,2 +1,2 @@
1
- import '@testing-library/jest-dom';
1
+ import '@testing-library/jest-dom/vitest';
2
2
  //# sourceMappingURL=setup-tests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,2BAA2B,CAAC"}
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,kCAAkC,CAAC"}
@@ -10,8 +10,8 @@
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 '@testing-library/jest-dom';
13
+ import "@testing-library/jest-dom/vitest";
14
14
  // Always mock e-charts during tests since we don't have a proper canvas in jsdom
15
- jest.mock('echarts/core');
15
+ vi.mock('echarts/core');
16
16
 
17
17
  //# sourceMappingURL=setup-tests.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright 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 '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
1
+ {"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright 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 '@testing-library/jest-dom/vitest';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\nvi.mock('echarts/core');\n"],"names":["vi","mock"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,mCAAmC;AAE1C,iFAAiF;AACjFA,GAAGC,IAAI,CAAC"}
@@ -1,6 +1,6 @@
1
- import { FontSizeOption, FormatOptions, ThresholdOptions, ValueMapping } from '@perses-dev/components';
2
- import { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';
3
- import { Definition } from '@perses-dev/spec';
1
+ import type { FontSizeOption, FormatOptions, ThresholdOptions, ValueMapping } from '@perses-dev/components';
2
+ import type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';
3
+ import type { Definition } from '@perses-dev/spec';
4
4
  /**
5
5
  * The schema for a StatChart panel.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"stat-chart-model.d.ts","sourceRoot":"","sources":["../../src/stat-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,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