@perses-dev/components 0.36.1 → 0.37.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 (111) hide show
  1. package/dist/FontSizeSelector/FontSizeSelector.d.ts +8 -0
  2. package/dist/FontSizeSelector/FontSizeSelector.d.ts.map +1 -0
  3. package/dist/FontSizeSelector/FontSizeSelector.js +124 -0
  4. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -0
  5. package/dist/FontSizeSelector/index.d.ts +2 -0
  6. package/dist/FontSizeSelector/index.d.ts.map +1 -0
  7. package/dist/FontSizeSelector/index.js +15 -0
  8. package/dist/FontSizeSelector/index.js.map +1 -0
  9. package/dist/LineChart/LineChart.d.ts +5 -25
  10. package/dist/LineChart/LineChart.d.ts.map +1 -1
  11. package/dist/LineChart/LineChart.js +6 -6
  12. package/dist/LineChart/LineChart.js.map +1 -1
  13. package/dist/LineChart/index.d.ts +0 -1
  14. package/dist/LineChart/index.d.ts.map +1 -1
  15. package/dist/LineChart/index.js +0 -1
  16. package/dist/LineChart/index.js.map +1 -1
  17. package/dist/StatChart/StatChart.d.ts +2 -0
  18. package/dist/StatChart/StatChart.d.ts.map +1 -1
  19. package/dist/StatChart/StatChart.js +7 -5
  20. package/dist/StatChart/StatChart.js.map +1 -1
  21. package/dist/StatChart/calculateFontSize.d.ts +3 -1
  22. package/dist/StatChart/calculateFontSize.d.ts.map +1 -1
  23. package/dist/StatChart/calculateFontSize.js +5 -1
  24. package/dist/StatChart/calculateFontSize.js.map +1 -1
  25. package/dist/TimeChart/TimeChart.d.ts +23 -0
  26. package/dist/TimeChart/TimeChart.d.ts.map +1 -0
  27. package/dist/TimeChart/TimeChart.js +313 -0
  28. package/dist/TimeChart/TimeChart.js.map +1 -0
  29. package/dist/TimeChart/index.d.ts +2 -0
  30. package/dist/TimeChart/index.d.ts.map +1 -0
  31. package/dist/TimeChart/index.js +15 -0
  32. package/dist/TimeChart/index.js.map +1 -0
  33. package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.d.ts → LineChartTooltip.d.ts} +2 -2
  34. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -0
  35. package/dist/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +4 -4
  36. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -0
  37. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +16 -0
  38. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -0
  39. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +76 -0
  40. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -0
  41. package/dist/TimeSeriesTooltip/TooltipHeader.d.ts.map +1 -1
  42. package/dist/TimeSeriesTooltip/TooltipHeader.js +3 -4
  43. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  44. package/dist/TimeSeriesTooltip/index.d.ts +2 -1
  45. package/dist/TimeSeriesTooltip/index.d.ts.map +1 -1
  46. package/dist/TimeSeriesTooltip/index.js +2 -1
  47. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  48. package/dist/TimeSeriesTooltip/nearby-series.d.ts +23 -5
  49. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  50. package/dist/TimeSeriesTooltip/nearby-series.js +166 -4
  51. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  52. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +4 -0
  53. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  54. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  55. package/dist/TimeSeriesTooltip/utils.d.ts +25 -0
  56. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  57. package/dist/TimeSeriesTooltip/utils.js +29 -1
  58. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  59. package/dist/cjs/FontSizeSelector/FontSizeSelector.js +130 -0
  60. package/dist/cjs/FontSizeSelector/index.js +28 -0
  61. package/dist/cjs/LineChart/LineChart.js +5 -44
  62. package/dist/cjs/LineChart/index.js +0 -1
  63. package/dist/cjs/StatChart/StatChart.js +7 -5
  64. package/dist/cjs/StatChart/calculateFontSize.js +5 -1
  65. package/dist/cjs/TimeChart/TimeChart.js +319 -0
  66. package/dist/cjs/TimeChart/index.js +28 -0
  67. package/dist/cjs/TimeSeriesTooltip/{TimeSeriesTooltip.js → LineChartTooltip.js} +4 -4
  68. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +87 -0
  69. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +3 -4
  70. package/dist/cjs/TimeSeriesTooltip/index.js +2 -1
  71. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +162 -4
  72. package/dist/cjs/TimeSeriesTooltip/utils.js +35 -3
  73. package/dist/cjs/index.js +2 -0
  74. package/dist/cjs/utils/axis.js +58 -0
  75. package/dist/cjs/{LineChart/utils.js → utils/chart-actions.js} +0 -54
  76. package/dist/cjs/utils/format.js +47 -1
  77. package/dist/cjs/utils/index.js +3 -1
  78. package/dist/cjs/utils/theme-gen.js +37 -0
  79. package/dist/index.d.ts +2 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +2 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/model/graph.d.ts +19 -2
  84. package/dist/model/graph.d.ts.map +1 -1
  85. package/dist/model/graph.js.map +1 -1
  86. package/dist/utils/axis.d.ts +14 -0
  87. package/dist/utils/axis.d.ts.map +1 -0
  88. package/dist/utils/axis.js +45 -0
  89. package/dist/utils/axis.js.map +1 -0
  90. package/dist/utils/chart-actions.d.ts +18 -0
  91. package/dist/utils/chart-actions.d.ts.map +1 -0
  92. package/dist/utils/chart-actions.js +52 -0
  93. package/dist/utils/chart-actions.js.map +1 -0
  94. package/dist/utils/format.d.ts +6 -0
  95. package/dist/utils/format.d.ts.map +1 -1
  96. package/dist/utils/format.js +47 -0
  97. package/dist/utils/format.js.map +1 -1
  98. package/dist/utils/index.d.ts +3 -1
  99. package/dist/utils/index.d.ts.map +1 -1
  100. package/dist/utils/index.js +3 -1
  101. package/dist/utils/index.js.map +1 -1
  102. package/dist/utils/theme-gen.d.ts.map +1 -1
  103. package/dist/utils/theme-gen.js +37 -0
  104. package/dist/utils/theme-gen.js.map +1 -1
  105. package/package.json +3 -3
  106. package/dist/LineChart/utils.d.ts +0 -31
  107. package/dist/LineChart/utils.d.ts.map +0 -1
  108. package/dist/LineChart/utils.js +0 -103
  109. package/dist/LineChart/utils.js.map +0 -1
  110. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.d.ts.map +0 -1
  111. package/dist/TimeSeriesTooltip/TimeSeriesTooltip.js.map +0 -1
@@ -10,7 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { TOOLTIP_MAX_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER } from './tooltip-model';
13
+ import { TOOLTIP_MAX_WIDTH, TOOLTIP_MAX_HEIGHT, TOOLTIP_MIN_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER, TOOLTIP_BG_COLOR_FALLBACK } from './tooltip-model';
14
14
  /**
15
15
  * Determine position of tooltip depending on chart dimensions and the number of focused series
16
16
  */ export function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth) {
@@ -37,5 +37,33 @@ import { TOOLTIP_MAX_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER } from './tooltip-mo
37
37
  // reposition so tooltip is never too close to right side of chart or left side of browser window
38
38
  return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)` : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
39
39
  }
40
+ /**
41
+ * Helper for tooltip positioning styles
42
+ */ export function getTooltipStyles(theme, pinnedPos) {
43
+ var ref;
44
+ var ref1;
45
+ return {
46
+ minWidth: TOOLTIP_MIN_WIDTH,
47
+ maxWidth: TOOLTIP_MAX_WIDTH,
48
+ maxHeight: TOOLTIP_MAX_HEIGHT,
49
+ padding: 0,
50
+ position: 'absolute',
51
+ top: 0,
52
+ left: 0,
53
+ backgroundColor: (ref1 = (ref = theme.palette.designSystem) === null || ref === void 0 ? void 0 : ref.grey[800]) !== null && ref1 !== void 0 ? ref1 : TOOLTIP_BG_COLOR_FALLBACK,
54
+ borderRadius: '6px',
55
+ color: '#fff',
56
+ fontSize: '11px',
57
+ visibility: 'visible',
58
+ opacity: 1,
59
+ transition: 'all 0.1s ease-out',
60
+ // Ensure pinned tooltip shows behind edit panel drawer and sticky header
61
+ zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,
62
+ overflow: 'hidden',
63
+ '&:hover': {
64
+ overflowY: 'auto'
65
+ }
66
+ };
67
+ }
40
68
 
41
69
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/utils.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { CursorCoordinates, CursorData, TOOLTIP_MAX_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER } from './tooltip-model';\n\n/**\n * Determine position of tooltip depending on chart dimensions and the number of focused series\n */\nexport function assembleTransform(\n mousePos: CursorData['coords'],\n chartWidth: number,\n pinnedPos: CursorCoordinates | null,\n tooltipHeight: number,\n tooltipWidth: number\n) {\n if (mousePos === null) {\n return 'translate3d(0, 0)';\n }\n\n const cursorPaddingX = 32;\n const cursorPaddingY = 16;\n\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n }\n\n // Tooltip is located in a Portal attached to the body.\n // Using page coordinates instead of viewport ensures the tooltip is\n // absolutely positioned correctly as the user scrolls\n const x = mousePos.page.x;\n let y = mousePos.page.y + cursorPaddingY;\n\n // adjust so tooltip does not get cut off at bottom of chart\n if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {\n // multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport\n y = mousePos.page.y - tooltipHeight * TOOLTIP_ADJUST_Y_POS_MULTIPLIER;\n }\n\n // use tooltip width to determine when to repos from right to left\n const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;\n\n // reposition so tooltip is never too close to right side of chart or left side of browser window\n return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH\n ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)`\n : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;\n}\n"],"names":["TOOLTIP_MAX_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","assembleTransform","mousePos","chartWidth","pinnedPos","tooltipHeight","tooltipWidth","cursorPaddingX","cursorPaddingY","x","page","y","client","window","innerHeight","xPosAdjustThreshold","plotCanvas"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAwCA,iBAAiB,EAAEC,+BAA+B,QAAQ,iBAAiB,CAAC;AAEpH;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAC/BC,QAA8B,EAC9BC,UAAkB,EAClBC,SAAmC,EACnCC,aAAqB,EACrBC,YAAoB,EACpB;IACA,IAAIJ,QAAQ,KAAK,IAAI,EAAE;QACrB,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,MAAMK,cAAc,GAAG,EAAE,AAAC;IAC1B,MAAMC,cAAc,GAAG,EAAE,AAAC;IAE1B,IAAIJ,SAAS,KAAK,IAAI,EAAE;QACtBF,QAAQ,GAAGE,SAAS,CAAC;IACvB,CAAC;IAED,uDAAuD;IACvD,oEAAoE;IACpE,sDAAsD;IACtD,MAAMK,CAAC,GAAGP,QAAQ,CAACQ,IAAI,CAACD,CAAC,AAAC;IAC1B,IAAIE,CAAC,GAAGT,QAAQ,CAACQ,IAAI,CAACC,CAAC,GAAGH,cAAc,AAAC;IAEzC,4DAA4D;IAC5D,IAAIN,QAAQ,CAACU,MAAM,CAACD,CAAC,GAAGN,aAAa,GAAGG,cAAc,GAAGK,MAAM,CAACC,WAAW,EAAE;QAC3E,+FAA+F;QAC/FH,CAAC,GAAGT,QAAQ,CAACQ,IAAI,CAACC,CAAC,GAAGN,aAAa,GAAGL,+BAA+B,CAAC;IACxE,CAAC;IAED,kEAAkE;IAClE,MAAMe,mBAAmB,GAAGZ,UAAU,GAAGG,YAAY,GAAG,GAAG,AAAC;IAE5D,iGAAiG;IACjG,OAAOJ,QAAQ,CAACc,UAAU,CAACP,CAAC,GAAGM,mBAAmB,IAAIN,CAAC,GAAGV,iBAAiB,GACvE,CAAC,YAAY,EAAEU,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,wBAAwB,CAAC,GACnE,CAAC,YAAY,EAAEF,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/utils.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport {\n CursorCoordinates,\n CursorData,\n TOOLTIP_MAX_WIDTH,\n TOOLTIP_MAX_HEIGHT,\n TOOLTIP_MIN_WIDTH,\n TOOLTIP_ADJUST_Y_POS_MULTIPLIER,\n TOOLTIP_BG_COLOR_FALLBACK,\n} from './tooltip-model';\n\n/**\n * Determine position of tooltip depending on chart dimensions and the number of focused series\n */\nexport function assembleTransform(\n mousePos: CursorData['coords'],\n chartWidth: number,\n pinnedPos: CursorCoordinates | null,\n tooltipHeight: number,\n tooltipWidth: number\n) {\n if (mousePos === null) {\n return 'translate3d(0, 0)';\n }\n\n const cursorPaddingX = 32;\n const cursorPaddingY = 16;\n\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n }\n\n // Tooltip is located in a Portal attached to the body.\n // Using page coordinates instead of viewport ensures the tooltip is\n // absolutely positioned correctly as the user scrolls\n const x = mousePos.page.x;\n let y = mousePos.page.y + cursorPaddingY;\n\n // adjust so tooltip does not get cut off at bottom of chart\n if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {\n // multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport\n y = mousePos.page.y - tooltipHeight * TOOLTIP_ADJUST_Y_POS_MULTIPLIER;\n }\n\n // use tooltip width to determine when to repos from right to left\n const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;\n\n // reposition so tooltip is never too close to right side of chart or left side of browser window\n return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH\n ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)`\n : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;\n}\n\n/**\n * Helper for tooltip positioning styles\n */\nexport function getTooltipStyles(theme: Theme, pinnedPos: CursorCoordinates | null) {\n return {\n minWidth: TOOLTIP_MIN_WIDTH,\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: TOOLTIP_MAX_HEIGHT,\n padding: 0,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n // Ensure pinned tooltip shows behind edit panel drawer and sticky header\n zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n };\n}\n"],"names":["TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_MIN_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","TOOLTIP_BG_COLOR_FALLBACK","assembleTransform","mousePos","chartWidth","pinnedPos","tooltipHeight","tooltipWidth","cursorPaddingX","cursorPaddingY","x","page","y","client","window","innerHeight","xPosAdjustThreshold","plotCanvas","getTooltipStyles","theme","minWidth","maxWidth","maxHeight","padding","position","top","left","backgroundColor","palette","designSystem","grey","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY"],"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,SAGEA,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,+BAA+B,EAC/BC,yBAAyB,QACpB,iBAAiB,CAAC;AAEzB;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAC/BC,QAA8B,EAC9BC,UAAkB,EAClBC,SAAmC,EACnCC,aAAqB,EACrBC,YAAoB,EACpB;IACA,IAAIJ,QAAQ,KAAK,IAAI,EAAE;QACrB,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,MAAMK,cAAc,GAAG,EAAE,AAAC;IAC1B,MAAMC,cAAc,GAAG,EAAE,AAAC;IAE1B,IAAIJ,SAAS,KAAK,IAAI,EAAE;QACtBF,QAAQ,GAAGE,SAAS,CAAC;IACvB,CAAC;IAED,uDAAuD;IACvD,oEAAoE;IACpE,sDAAsD;IACtD,MAAMK,CAAC,GAAGP,QAAQ,CAACQ,IAAI,CAACD,CAAC,AAAC;IAC1B,IAAIE,CAAC,GAAGT,QAAQ,CAACQ,IAAI,CAACC,CAAC,GAAGH,cAAc,AAAC;IAEzC,4DAA4D;IAC5D,IAAIN,QAAQ,CAACU,MAAM,CAACD,CAAC,GAAGN,aAAa,GAAGG,cAAc,GAAGK,MAAM,CAACC,WAAW,EAAE;QAC3E,+FAA+F;QAC/FH,CAAC,GAAGT,QAAQ,CAACQ,IAAI,CAACC,CAAC,GAAGN,aAAa,GAAGN,+BAA+B,CAAC;IACxE,CAAC;IAED,kEAAkE;IAClE,MAAMgB,mBAAmB,GAAGZ,UAAU,GAAGG,YAAY,GAAG,GAAG,AAAC;IAE5D,iGAAiG;IACjG,OAAOJ,QAAQ,CAACc,UAAU,CAACP,CAAC,GAAGM,mBAAmB,IAAIN,CAAC,GAAGb,iBAAiB,GACvE,CAAC,YAAY,EAAEa,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,wBAAwB,CAAC,GACnE,CAAC,YAAY,EAAEF,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC;AAED;;CAEC,GACD,OAAO,SAASM,gBAAgB,CAACC,KAAY,EAAEd,SAAmC,EAAE;QAS/Dc,GAA0B;QAA1BA,IAAqC;IARxD,OAAO;QACLC,QAAQ,EAAErB,iBAAiB;QAC3BsB,QAAQ,EAAExB,iBAAiB;QAC3ByB,SAAS,EAAExB,kBAAkB;QAC7ByB,OAAO,EAAE,CAAC;QACVC,QAAQ,EAAE,UAAU;QACpBC,GAAG,EAAE,CAAC;QACNC,IAAI,EAAE,CAAC;QACPC,eAAe,EAAER,CAAAA,IAAqC,GAArCA,CAAAA,GAA0B,GAA1BA,KAAK,CAACS,OAAO,CAACC,YAAY,cAA1BV,GAA0B,WAAM,GAAhCA,KAAAA,CAAgC,GAAhCA,GAA0B,CAAEW,IAAI,CAAC,GAAG,CAAC,cAArCX,IAAqC,cAArCA,IAAqC,GAAIlB,yBAAyB;QACnF8B,YAAY,EAAE,KAAK;QACnBC,KAAK,EAAE,MAAM;QACbC,QAAQ,EAAE,MAAM;QAChBC,UAAU,EAAE,SAAS;QACrBC,OAAO,EAAE,CAAC;QACVC,UAAU,EAAE,mBAAmB;QAC/B,yEAAyE;QACzEC,MAAM,EAAEhC,SAAS,KAAK,IAAI,GAAG,MAAM,GAAGc,KAAK,CAACkB,MAAM,CAACC,OAAO;QAC1DC,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE;YACTC,SAAS,EAAE,MAAM;SAClB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,130 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License | Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing | software
9
+ // distributed under the License is distributed on an "AS IS" BASIS |
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND | either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "FontSizeSelector", {
18
+ enumerable: true,
19
+ get: ()=>FontSizeSelector
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _optionsEditorLayout = require("../OptionsEditorLayout");
23
+ const _settingsAutocomplete = require("../SettingsAutocomplete");
24
+ const FONT_SIZE_OPTIONS = [
25
+ {
26
+ id: 'default',
27
+ label: 'Default',
28
+ value: undefined
29
+ },
30
+ {
31
+ id: '12',
32
+ label: '12',
33
+ value: 12
34
+ },
35
+ {
36
+ id: '14',
37
+ label: '14',
38
+ value: 14
39
+ },
40
+ {
41
+ id: '16',
42
+ label: '16',
43
+ value: 16
44
+ },
45
+ {
46
+ id: '20',
47
+ label: '20',
48
+ value: 20
49
+ },
50
+ {
51
+ id: '24',
52
+ label: '24',
53
+ value: 24
54
+ },
55
+ {
56
+ id: '28',
57
+ label: '28',
58
+ value: 28
59
+ },
60
+ {
61
+ id: '32',
62
+ label: '32',
63
+ value: 32
64
+ },
65
+ {
66
+ id: '36',
67
+ label: '36',
68
+ value: 36
69
+ },
70
+ {
71
+ id: '40',
72
+ label: '40',
73
+ value: 40
74
+ },
75
+ {
76
+ id: '48',
77
+ label: '48',
78
+ value: 48
79
+ },
80
+ {
81
+ id: '56',
82
+ label: '56',
83
+ value: 56
84
+ },
85
+ {
86
+ id: '64',
87
+ label: '64',
88
+ value: 64
89
+ },
90
+ {
91
+ id: '72',
92
+ label: '72',
93
+ value: 72
94
+ },
95
+ {
96
+ id: '96',
97
+ label: '96',
98
+ value: 96
99
+ },
100
+ {
101
+ id: '128',
102
+ label: '128',
103
+ value: 128
104
+ },
105
+ {
106
+ id: '160',
107
+ label: '160',
108
+ value: 160
109
+ },
110
+ {
111
+ id: '192',
112
+ label: '192',
113
+ value: 192
114
+ }
115
+ ];
116
+ function FontSizeSelector({ value , onChange }) {
117
+ const handleFontSizeChange = (_, { value })=>{
118
+ onChange(value);
119
+ };
120
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorLayout.OptionsEditorControl, {
121
+ label: "Font Size",
122
+ control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_settingsAutocomplete.SettingsAutocomplete, {
123
+ value: FONT_SIZE_OPTIONS.find((o)=>o.value === value),
124
+ options: FONT_SIZE_OPTIONS,
125
+ getOptionLabel: (o)=>o.label,
126
+ onChange: handleFontSizeChange,
127
+ disableClearable: true
128
+ })
129
+ });
130
+ }
@@ -0,0 +1,28 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./FontSizeSelector"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "LineChart", {
19
19
  get: ()=>LineChart
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
22
+ const _react = require("react");
23
23
  const _material = require("@mui/material");
24
24
  const _core = require("echarts/core");
25
25
  const _charts = require("echarts/charts");
@@ -29,46 +29,7 @@ const _echart = require("../EChart");
29
29
  const _chartsThemeProvider = require("../context/ChartsThemeProvider");
30
30
  const _timeSeriesTooltip = require("../TimeSeriesTooltip");
31
31
  const _timeZoneProvider = require("../context/TimeZoneProvider");
32
- const _utils = require("./utils");
33
- function _getRequireWildcardCache(nodeInterop) {
34
- if (typeof WeakMap !== "function") return null;
35
- var cacheBabelInterop = new WeakMap();
36
- var cacheNodeInterop = new WeakMap();
37
- return (_getRequireWildcardCache = function(nodeInterop) {
38
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
39
- })(nodeInterop);
40
- }
41
- function _interopRequireWildcard(obj, nodeInterop) {
42
- if (!nodeInterop && obj && obj.__esModule) {
43
- return obj;
44
- }
45
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
46
- return {
47
- default: obj
48
- };
49
- }
50
- var cache = _getRequireWildcardCache(nodeInterop);
51
- if (cache && cache.has(obj)) {
52
- return cache.get(obj);
53
- }
54
- var newObj = {};
55
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
56
- for(var key in obj){
57
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
58
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
59
- if (desc && (desc.get || desc.set)) {
60
- Object.defineProperty(newObj, key, desc);
61
- } else {
62
- newObj[key] = obj[key];
63
- }
64
- }
65
- }
66
- newObj.default = obj;
67
- if (cache) {
68
- cache.set(obj, newObj);
69
- }
70
- return newObj;
71
- }
32
+ const _utils = require("../utils");
72
33
  (0, _core.use)([
73
34
  _charts.LineChart,
74
35
  _components.GridComponent,
@@ -97,7 +58,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
97
58
  return {
98
59
  highlightSeries ({ id }) {
99
60
  if (!chartRef.current) {
100
- // No chart. Do nothing.
61
+ // when chart undef, do not highlight series when hovering over legend
101
62
  return;
102
63
  }
103
64
  chartRef.current.dispatchAction({
@@ -107,7 +68,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
107
68
  },
108
69
  clearHighlightedSeries: ()=>{
109
70
  if (!chartRef.current) {
110
- // No chart. Do nothing.
71
+ // when chart undef, do not clear highlight series
111
72
  return;
112
73
  }
113
74
  (0, _utils.clearHighlightedSeries)(chartRef.current, data.timeSeries.length);
@@ -292,7 +253,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
292
253
  }
293
254
  },
294
255
  children: [
295
- showTooltip === true && ((ref1 = option.tooltip) === null || ref1 === void 0 ? void 0 : ref1.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeSeriesTooltip.TimeSeriesTooltip, {
256
+ showTooltip === true && ((ref1 = option.tooltip) === null || ref1 === void 0 ? void 0 : ref1.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeSeriesTooltip.LineChartTooltip, {
296
257
  chartRef: chartRef,
297
258
  chartData: data,
298
259
  wrapLabels: tooltipConfig.wrapLabels,
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _exportStar(require("./LineChart"), exports);
18
- _exportStar(require("./utils"), exports);
19
18
  function _exportStar(from, to) {
20
19
  Object.keys(from).forEach(function(k) {
21
20
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -49,7 +49,7 @@ const SERIES_NAME_FONT_WEIGHT = 400;
49
49
  const VALUE_FONT_WEIGHT = 700;
50
50
  function StatChart(props) {
51
51
  var ref, ref1;
52
- const { width , height , data , unit , color , sparkline , showSeriesName } = props;
52
+ const { width , height , data , unit , color , sparkline , showSeriesName , valueFontSize } = props;
53
53
  const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
54
54
  let formattedValue = '';
55
55
  if (data.calculatedValue === null) {
@@ -72,8 +72,10 @@ function StatChart(props) {
72
72
  // calculate value font size and height
73
73
  const availableWidth = width - containerPadding * 2;
74
74
  const availableHeight = height - seriesNameHeight;
75
- const valueFontSize = (0, _calculateFontSize.useOptimalFontSize)({
75
+ const optimalValueFontSize = (0, _calculateFontSize.useOptimalFontSize)({
76
76
  text: formattedValue,
77
+ // override the font size if user selects it in the settings
78
+ fontSizeOverride: valueFontSize,
77
79
  fontWeight: VALUE_FONT_WEIGHT,
78
80
  // without sparkline, use only 50% of the available width so it looks better for multiseries
79
81
  width: sparkline ? availableWidth : availableWidth * 0.5,
@@ -82,9 +84,9 @@ function StatChart(props) {
82
84
  height: sparkline ? availableHeight * 0.25 : availableHeight * 0.9,
83
85
  lineHeight: LINE_HEIGHT
84
86
  });
85
- const valueFontHeight = valueFontSize * LINE_HEIGHT;
87
+ const valueFontHeight = optimalValueFontSize * LINE_HEIGHT;
86
88
  // make sure the series name font size is slightly smaller than value font size
87
- seriesNameFontSize = Math.min(valueFontSize * 0.7, seriesNameFontSize);
89
+ seriesNameFontSize = Math.min(optimalValueFontSize * 0.7, seriesNameFontSize);
88
90
  const option = (0, _react.useMemo)(()=>{
89
91
  if (data.seriesData === undefined) return chartsTheme.noDataOption;
90
92
  const series = data.seriesData;
@@ -163,7 +165,7 @@ function StatChart(props) {
163
165
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(Value, {
164
166
  variant: "h3",
165
167
  color: color,
166
- fontSize: valueFontSize,
168
+ fontSize: optimalValueFontSize,
167
169
  padding: containerPadding,
168
170
  children: formattedValue
169
171
  }),
@@ -29,9 +29,13 @@ function getGlobalCanvasContext() {
29
29
  }
30
30
  return canvasContext;
31
31
  }
32
- function useOptimalFontSize({ text , fontWeight , width , height , lineHeight , maxSize }) {
32
+ function useOptimalFontSize({ text , fontWeight , width , height , lineHeight , maxSize , fontSizeOverride }) {
33
33
  const ctx = getGlobalCanvasContext();
34
34
  const chartsTheme = (0, _chartsThemeProvider.useChartsTheme)();
35
+ // if user has selected a font size in the settings, use it instead of calculating the optimal size
36
+ if (fontSizeOverride !== undefined) {
37
+ return Number(fontSizeOverride);
38
+ }
35
39
  const textStyle = chartsTheme.echartsTheme.textStyle;
36
40
  var ref;
37
41
  const fontSize = (ref = Number(textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontSize)) !== null && ref !== void 0 ? ref : 12;