@perses-dev/components 0.4.0 → 0.5.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 (139) hide show
  1. package/README.md +18 -0
  2. package/dist/EChart.d.ts +4 -1
  3. package/dist/EChart.d.ts.map +1 -1
  4. package/dist/EChart.js +1 -1
  5. package/dist/{GaugeChart.d.ts → GaugeChart/GaugeChart.d.ts} +2 -1
  6. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -0
  7. package/dist/GaugeChart/GaugeChart.js +1 -0
  8. package/dist/GaugeChart/index.d.ts +2 -0
  9. package/dist/GaugeChart/index.d.ts.map +1 -0
  10. package/dist/GaugeChart/index.js +1 -0
  11. package/dist/InfoTooltip/InfoTooltip.d.ts +17 -0
  12. package/dist/InfoTooltip/InfoTooltip.d.ts.map +1 -0
  13. package/dist/InfoTooltip/InfoTooltip.js +1 -0
  14. package/dist/InfoTooltip/InfoTooltip.test.d.ts +2 -0
  15. package/dist/InfoTooltip/InfoTooltip.test.d.ts.map +1 -0
  16. package/dist/InfoTooltip/InfoTooltip.test.js +1 -0
  17. package/dist/InfoTooltip/index.d.ts +2 -0
  18. package/dist/InfoTooltip/index.d.ts.map +1 -0
  19. package/dist/InfoTooltip/index.js +1 -0
  20. package/dist/LineChart/LineChart.d.ts +17 -0
  21. package/dist/LineChart/LineChart.d.ts.map +1 -0
  22. package/dist/LineChart/LineChart.js +1 -0
  23. package/dist/LineChart/index.d.ts +3 -0
  24. package/dist/LineChart/index.d.ts.map +1 -0
  25. package/dist/LineChart/index.js +1 -0
  26. package/dist/LineChart/utils.d.ts +12 -0
  27. package/dist/LineChart/utils.d.ts.map +1 -0
  28. package/dist/LineChart/utils.js +1 -0
  29. package/dist/{StatChart.d.ts → StatChart/StatChart.d.ts} +4 -9
  30. package/dist/StatChart/StatChart.d.ts.map +1 -0
  31. package/dist/StatChart/StatChart.js +1 -0
  32. package/dist/StatChart/StatChart.test.d.ts +2 -0
  33. package/dist/StatChart/StatChart.test.d.ts.map +1 -0
  34. package/dist/StatChart/StatChart.test.js +1 -0
  35. package/dist/StatChart/index.d.ts +2 -0
  36. package/dist/StatChart/index.d.ts.map +1 -0
  37. package/dist/StatChart/index.js +1 -0
  38. package/dist/{tooltip → Tooltip}/SeriesInfo.d.ts +0 -0
  39. package/dist/{tooltip → Tooltip}/SeriesInfo.d.ts.map +1 -1
  40. package/dist/{tooltip → Tooltip}/SeriesInfo.js +1 -1
  41. package/dist/{tooltip → Tooltip}/SeriesMarker.d.ts +0 -0
  42. package/dist/{tooltip → Tooltip}/SeriesMarker.d.ts.map +1 -1
  43. package/dist/{tooltip → Tooltip}/SeriesMarker.js +0 -0
  44. package/dist/{tooltip → Tooltip}/Tooltip.d.ts +1 -1
  45. package/dist/{tooltip → Tooltip}/Tooltip.d.ts.map +1 -1
  46. package/dist/{tooltip → Tooltip}/Tooltip.js +0 -0
  47. package/dist/{tooltip → Tooltip}/TooltipContent.d.ts +0 -0
  48. package/dist/{tooltip → Tooltip}/TooltipContent.d.ts.map +1 -1
  49. package/dist/{tooltip → Tooltip}/TooltipContent.js +0 -0
  50. package/dist/{tooltip → Tooltip}/focused-series.d.ts +1 -1
  51. package/dist/{tooltip → Tooltip}/focused-series.d.ts.map +1 -1
  52. package/dist/{tooltip → Tooltip}/focused-series.js +0 -0
  53. package/dist/Tooltip/focused-series.test.d.ts +2 -0
  54. package/dist/Tooltip/focused-series.test.d.ts.map +1 -0
  55. package/dist/Tooltip/focused-series.test.js +1 -0
  56. package/dist/Tooltip/index.d.ts +3 -0
  57. package/dist/Tooltip/index.d.ts.map +1 -0
  58. package/dist/Tooltip/index.js +1 -0
  59. package/dist/{tooltip → Tooltip}/tooltip-model.d.ts +0 -0
  60. package/dist/{tooltip → Tooltip}/tooltip-model.d.ts.map +1 -1
  61. package/dist/{tooltip → Tooltip}/tooltip-model.js +0 -0
  62. package/dist/cjs/EChart.js +3 -3
  63. package/dist/cjs/{GaugeChart.js → GaugeChart/GaugeChart.js} +12 -45
  64. package/dist/cjs/GaugeChart/index.js +29 -0
  65. package/dist/cjs/InfoTooltip/InfoTooltip.js +39 -0
  66. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +33 -0
  67. package/dist/cjs/InfoTooltip/index.js +29 -0
  68. package/dist/cjs/{LineChart.js → LineChart/LineChart.js} +36 -109
  69. package/dist/cjs/LineChart/index.js +29 -0
  70. package/dist/cjs/LineChart/utils.js +72 -0
  71. package/dist/cjs/StatChart/StatChart.js +104 -0
  72. package/dist/cjs/StatChart/StatChart.test.js +45 -0
  73. package/dist/cjs/StatChart/index.js +29 -0
  74. package/dist/cjs/{tooltip → Tooltip}/SeriesInfo.js +2 -1
  75. package/dist/cjs/{tooltip → Tooltip}/SeriesMarker.js +0 -0
  76. package/dist/cjs/{tooltip → Tooltip}/Tooltip.js +0 -0
  77. package/dist/cjs/{tooltip → Tooltip}/TooltipContent.js +0 -0
  78. package/dist/cjs/{tooltip → Tooltip}/focused-series.js +0 -0
  79. package/dist/cjs/Tooltip/focused-series.test.js +57 -0
  80. package/dist/cjs/Tooltip/index.js +30 -0
  81. package/dist/cjs/{tooltip → Tooltip}/tooltip-model.js +0 -0
  82. package/dist/cjs/context/ChartsThemeProvider.js +36 -0
  83. package/dist/cjs/index.js +5 -4
  84. package/dist/cjs/model/{graph-model.js → graph.js} +0 -0
  85. package/dist/cjs/model/index.js +31 -0
  86. package/dist/cjs/model/theme.js +14 -0
  87. package/dist/cjs/model/units.js +58 -85
  88. package/dist/cjs/test/index.js +29 -0
  89. package/dist/cjs/test/render.js +26 -0
  90. package/dist/cjs/test/setup-tests.js +18 -0
  91. package/dist/cjs/utils/index.js +30 -0
  92. package/dist/cjs/utils/theme-gen.js +180 -0
  93. package/dist/cjs/utils/theme-gen.test.js +196 -0
  94. package/dist/context/ChartsThemeProvider.d.ts +11 -0
  95. package/dist/context/ChartsThemeProvider.d.ts.map +1 -0
  96. package/dist/context/ChartsThemeProvider.js +1 -0
  97. package/dist/index.d.ts +5 -4
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +1 -1
  100. package/dist/model/{graph-model.d.ts → graph.d.ts} +7 -1
  101. package/dist/model/graph.d.ts.map +1 -0
  102. package/dist/model/{graph-model.js → graph.js} +0 -0
  103. package/dist/model/index.d.ts +4 -0
  104. package/dist/model/index.d.ts.map +1 -0
  105. package/dist/model/index.js +1 -0
  106. package/dist/model/theme.d.ts +16 -0
  107. package/dist/model/theme.d.ts.map +1 -0
  108. package/dist/model/theme.js +1 -0
  109. package/dist/model/units.d.ts +22 -11
  110. package/dist/model/units.d.ts.map +1 -1
  111. package/dist/model/units.js +1 -1
  112. package/dist/test/index.d.ts +2 -0
  113. package/dist/test/index.d.ts.map +1 -0
  114. package/dist/test/index.js +1 -0
  115. package/dist/test/render.d.ts +7 -0
  116. package/dist/test/render.d.ts.map +1 -0
  117. package/dist/test/render.js +1 -0
  118. package/dist/test/setup-tests.d.ts +2 -0
  119. package/dist/test/setup-tests.d.ts.map +1 -0
  120. package/dist/test/setup-tests.js +1 -0
  121. package/dist/utils/index.d.ts +3 -0
  122. package/dist/utils/index.d.ts.map +1 -0
  123. package/dist/utils/index.js +1 -0
  124. package/dist/utils/theme-gen.d.ts +6 -0
  125. package/dist/utils/theme-gen.d.ts.map +1 -0
  126. package/dist/utils/theme-gen.js +1 -0
  127. package/dist/utils/theme-gen.test.d.ts +2 -0
  128. package/dist/utils/theme-gen.test.d.ts.map +1 -0
  129. package/dist/utils/theme-gen.test.js +1 -0
  130. package/package.json +5 -3
  131. package/dist/GaugeChart.d.ts.map +0 -1
  132. package/dist/GaugeChart.js +0 -1
  133. package/dist/LineChart.d.ts +0 -22
  134. package/dist/LineChart.d.ts.map +0 -1
  135. package/dist/LineChart.js +0 -1
  136. package/dist/StatChart.d.ts.map +0 -1
  137. package/dist/StatChart.js +0 -1
  138. package/dist/cjs/StatChart.js +0 -207
  139. package/dist/model/graph-model.d.ts.map +0 -1
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # Perses Components Package
2
+
3
+ This [package](https://www.npmjs.com/package/@perses-dev/components) includes individual components used in the Perses app and plugins. These components are broken up in a way that allows embedding in separate applications outside of Perses. For more info about corresponding packages see the [general UI README here](https://github.com/perses/perses/blob/main/ui/README.md) and markdown files in each component folder.
4
+
5
+
6
+ ## Usage
7
+
8
+ To import components from the components package use the syntax below:
9
+
10
+ ```typescript
11
+ import { LineChart } from "@perses-dev/components";
12
+ ```
13
+
14
+ For detailed examples of how to use certain components, see individual docs for:
15
+
16
+ - [LineChart.md](./src/LineChart/LineChart.md)
17
+ - [GaugeChart.md](./src/GaugeChart/GaugeChart.md)
18
+ - [StatChart.md](./src/StatChart/StatChart.md)
package/dist/EChart.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ECharts, EChartsCoreOption } from 'echarts/core';
3
3
  import { SxProps, Theme } from '@mui/material';
4
+ import { EChartsTheme } from './model';
4
5
  export interface MouseEventsParameters<T> {
5
6
  componentType: string;
6
7
  seriesType: string;
@@ -48,11 +49,13 @@ export declare type OnEventsType<T> = {
48
49
  };
49
50
  export interface EChartsProps<T> {
50
51
  option: EChartsCoreOption;
52
+ theme?: string | EChartsTheme;
53
+ renderer?: 'canvas' | 'svg';
51
54
  sx?: SxProps<Theme>;
52
55
  onEvents?: OnEventsType<T>;
53
56
  _instance?: React.MutableRefObject<ECharts | undefined>;
54
57
  onChartInitialized?: (instance: ECharts) => void;
55
58
  }
56
- export declare const EChart: React.MemoExoticComponent<(<T>({ option, sx, onEvents, _instance, onChartInitialized, }: EChartsProps<T>) => JSX.Element)>;
59
+ export declare const EChart: React.MemoExoticComponent<(<T>({ option, theme, renderer, sx, onEvents, _instance, onChartInitialized, }: EChartsProps<T>) => JSX.Element)>;
57
60
  export {};
58
61
  //# sourceMappingURL=EChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EChart.d.ts","sourceRoot":"","sources":["../src/EChart.tsx"],"names":[],"mappings":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,EAAE,CAAC;CACjE;AAED,aAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;AAEpE,QAAA,MAAM,WAAW,gDAAiD,CAAC;AAEnE,oBAAY,cAAc,GAAG,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAExD,aAAK,cAAc,GAAG,UAAU,CAAC;AAIjC,oBAAY,YAAY,CAAC,CAAC,IAAI;KAC3B,cAAc,IAAI,cAAc,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;CACxD,GAAG;KACD,cAAc,IAAI,cAAc,CAAC,CAAC,EAAE,oBAAoB;CAC1D,GAAG;KACD,SAAS,IAAI,cAAc,CAAC,CAAC,EAAE,MAAM,IAAI;CAC3C,CAAC;AAEF,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IACxD,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,MAAM,6IAkEjB,CAAC"}
package/dist/EChart.js CHANGED
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import React,{useEffect,useLayoutEffect,useRef}from"react";import debounce from"lodash/debounce";import{init}from"echarts/core";import{Box}from"@mui/material";import{isEqual}from"lodash-es";const mouseEvents=["click","dblclick","mousedown","mousemove","mouseup","mouseover","mouseout","globalout","contextmenu"],batchEvents=["datazoom","downplay","highlight"];export const EChart=React.memo((function({option:e,sx:n,onEvents:t,_instance:r,onChartInitialized:o}){const u=useRef(e),s=useRef(e),c=useRef(null),i=useRef(null);return useLayoutEffect((()=>{if(null!==c.current&&null===i.current)return i.current=init(c.current),i.current.setOption(u.current,!0),null==o||o(i.current),void 0!==r&&(r.current=i.current),()=>{null!==i.current&&(i.current.dispose(),i.current=null)}}),[r,o]),useEffect((()=>{void 0===s.current||isEqual(s.current,e)||null!==i.current&&(i.current.setOption(e,!0),s.current=e)}),[e]),useLayoutEffect((()=>{const e=debounce((()=>{null!==i.current&&i.current.resize()}),200);return window.addEventListener("resize",e),e(),()=>{window.removeEventListener("resize",e)}}),[]),useEffect((()=>{const e=i.current;if(null!==e&&void 0!==t)return bindEvents(e,t),()=>{if(void 0!==e&&!0!==e.isDisposed())for(const n in t)e.off(n)}}),[t]),_jsx(Box,{ref:c,sx:n})}));function bindEvents(e,n){var t;if(void 0!==n)for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)){const o=null!==(t=n[e])&&void 0!==t?t:null;o&&r(e,o)}function r(n,t){"function"==typeof t&&(isMouseEvent(n)?e.on(n,(n=>t(n,e))):isBatchEvent(n)?e.on(n,(e=>t(e))):e.on(n,(()=>t(null,e))))}}function isMouseEvent(e){return mouseEvents.includes(e)}function isBatchEvent(e){return batchEvents.includes(e)}
1
+ import{jsx as _jsx}from"react/jsx-runtime";import React,{useEffect,useLayoutEffect,useRef}from"react";import debounce from"lodash/debounce";import{init}from"echarts/core";import{Box}from"@mui/material";import{isEqual}from"lodash-es";const mouseEvents=["click","dblclick","mousedown","mousemove","mouseup","mouseover","mouseout","globalout","contextmenu"],batchEvents=["datazoom","downplay","highlight"];export const EChart=React.memo((function({option:e,theme:n,renderer:t,sx:r,onEvents:o,_instance:u,onChartInitialized:s}){const c=useRef(e),i=useRef(e),l=useRef(null),f=useRef(null);return useLayoutEffect((()=>{if(null!==l.current&&null===f.current)return f.current=init(l.current,n,{renderer:null!=t?t:"canvas"}),f.current.setOption(c.current,!0),null==s||s(f.current),void 0!==u&&(u.current=f.current),()=>{null!==f.current&&(f.current.dispose(),f.current=null)}}),[u,s,n,t]),useEffect((()=>{void 0===i.current||isEqual(i.current,e)||null!==f.current&&(f.current.setOption(e,!0),i.current=e)}),[e]),useLayoutEffect((()=>{const e=debounce((()=>{null!==f.current&&f.current.resize()}),200);return window.addEventListener("resize",e),e(),()=>{window.removeEventListener("resize",e)}}),[]),useEffect((()=>{const e=f.current;if(null!==e&&void 0!==o)return bindEvents(e,o),()=>{if(void 0!==e&&!0!==e.isDisposed())for(const n in o)e.off(n)}}),[o]),_jsx(Box,{ref:l,sx:r})}));function bindEvents(e,n){var t;if(void 0!==n)for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)){const o=null!==(t=n[e])&&void 0!==t?t:null;o&&r(e,o)}function r(n,t){"function"==typeof t&&(isMouseEvent(n)?e.on(n,(n=>t(n,e))):isBatchEvent(n)?e.on(n,(e=>t(e))):e.on(n,(()=>t(null,e))))}}function isMouseEvent(e){return mouseEvents.includes(e)}function isBatchEvent(e){return batchEvents.includes(e)}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { GaugeSeriesOption } from 'echarts/charts';
3
- import { UnitOptions } from './model/units';
3
+ import { UnitOptions } from '../model/units';
4
4
  export declare type GaugeChartData = number | null | undefined;
5
5
  interface GaugeChartProps {
6
6
  width: number;
@@ -8,6 +8,7 @@ interface GaugeChartProps {
8
8
  data: GaugeChartData;
9
9
  unit: UnitOptions;
10
10
  axisLine: GaugeSeriesOption['axisLine'];
11
+ max?: number;
11
12
  }
12
13
  export declare function GaugeChart(props: GaugeChartProps): JSX.Element;
13
14
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GaugeChart.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/GaugeChart.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIpF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK1D,oBAAY,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEvD,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA+HhD"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{useMemo}from"react";import{use}from"echarts/core";import{GaugeChart as EChartsGaugeChart}from"echarts/charts";import{GridComponent,TitleComponent,TooltipComponent}from"echarts/components";import{CanvasRenderer}from"echarts/renderers";import{useChartsTheme}from"../context/ChartsThemeProvider";import{formatValue}from"../model/units";import{EChart}from"../EChart";use([EChartsGaugeChart,GridComponent,TitleComponent,TooltipComponent,CanvasRenderer]);export function GaugeChart(e){const{width:t,height:o,data:r,unit:a,axisLine:i,max:s}=e,n=useChartsTheme(),h=useMemo((()=>null==r?n.noDataOption:{title:{show:!1},tooltip:{show:!1},series:[{type:"gauge",center:["50%","65%"],radius:"100%",startAngle:200,endAngle:-20,min:0,max:s,silent:!0,progress:{show:!0,width:22,itemStyle:{color:"auto"}},pointer:{show:!1},axisLine:{lineStyle:{color:[[1,"#e1e5e9"]],width:22}},axisTick:{show:!1,distance:0},splitLine:{show:!0},axisLabel:{show:!1,distance:-18,color:"#999",fontSize:12},anchor:{show:!1},title:{show:!1},detail:{show:!1},data:[{value:r}]},{type:"gauge",center:["50%","65%"],radius:"114%",startAngle:200,endAngle:-20,min:0,max:s,pointer:{show:!1,itemStyle:{color:"auto"}},axisLine:i,axisTick:{show:!1},splitLine:{show:!1},axisLabel:{show:!1},detail:{show:!0,width:"60%",borderRadius:8,offsetCenter:[0,"-9%"],color:"inherit",formatter:e=>formatValue(e,{kind:a.kind,decimal_places:0})},data:[{value:r}]}]}),[r,n,a,i,s]);return _jsx(EChart,{sx:{width:t,height:o},option:h,theme:n.themeName})}
@@ -0,0 +1,2 @@
1
+ export * from './GaugeChart';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/GaugeChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./GaugeChart";
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ export declare enum TooltipPlacement {
3
+ Top = "top",
4
+ Left = "left",
5
+ Right = "right",
6
+ Bottom = "bottom"
7
+ }
8
+ interface InfoTooltipProps {
9
+ description: string;
10
+ children: React.ReactNode;
11
+ id?: string;
12
+ title?: string;
13
+ placement?: TooltipPlacement;
14
+ }
15
+ export declare const InfoTooltip: ({ id, title, description, placement, children }: InfoTooltipProps) => JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=InfoTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoTooltip.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/InfoTooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,oBAAY,gBAAgB;IAC1B,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,oDAAqD,gBAAgB,gBAW5F,CAAC"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{styled,Tooltip as MuiTooltip,tooltipClasses,Typography}from"@mui/material";export var TooltipPlacement;!function(t){t.Top="top",t.Left="left",t.Right="right",t.Bottom="bottom"}(TooltipPlacement||(TooltipPlacement={}));export const InfoTooltip=({id:t,title:o,description:e,placement:i,children:a})=>_jsx(StyledTooltip,{arrow:!0,id:t,placement:i,title:_jsx(TooltipContent,{title:o,description:e}),children:_jsx("div",{children:a})});const TooltipContent=({title:t,description:o})=>_jsxs(_Fragment,{children:[t&&_jsx(Typography,{variant:"body2",sx:t=>({color:t.palette.text.primary,fontWeight:t.typography.fontWeightMedium}),children:t}),_jsx(Typography,{variant:"caption",sx:t=>({color:t.palette.text.primary}),children:o})]}),StyledTooltip=styled((({className:t,...o})=>_jsx(MuiTooltip,{...o,classes:{popper:t}})))((({theme:t})=>({[`& .${tooltipClasses.tooltip}`]:{backgroundColor:t.palette.secondary.main,color:t.palette.grey[900],maxWidth:"300px",padding:t.spacing(1),boxShadow:t.shadows[1]},[`& .${tooltipClasses.arrow}`]:{color:t.palette.background.paper,"&::before":{backgroundColor:t.palette.secondary.main}}})));
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=InfoTooltip.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoTooltip.test.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/InfoTooltip.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{render}from"@testing-library/react";import userEvent from"@testing-library/user-event";import{screen}from"@testing-library/dom";import{InfoTooltip}from"./InfoTooltip";describe("InfoTooltip",(()=>{const t="Tooltip Title",e="this is a tooltip";it("should render title and description",(async()=>{render(_jsx(InfoTooltip,{title:t,description:e,children:_jsx("div",{children:"tooltipAnchor"})}));const r=screen.getByText("tooltipAnchor");userEvent.hover(r),await screen.findByText(t),screen.findByText(e)}))}));
@@ -0,0 +1,2 @@
1
+ export * from './InfoTooltip';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/InfoTooltip/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./InfoTooltip";
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import type { GridComponentOption, LegendComponentOption, VisualMapComponentOption } from 'echarts';
3
+ import { EChartsDataFormat } from '../model/graph';
4
+ import { UnitOptions } from '../model/units';
5
+ import { ZoomEventData } from './utils';
6
+ interface LineChartProps {
7
+ height: number;
8
+ data: EChartsDataFormat;
9
+ unit?: UnitOptions;
10
+ grid?: GridComponentOption;
11
+ legend?: LegendComponentOption;
12
+ visualMap?: VisualMapComponentOption[];
13
+ onDataZoom?: (e: ZoomEventData) => void;
14
+ }
15
+ export declare function LineChart({ height, data, unit, grid, legend, visualMap, onDataZoom }: LineChartProps): JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=LineChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../src/LineChart/LineChart.tsx"],"names":[],"mappings":";AAgBA,OAAO,KAAK,EAEV,mBAAmB,EAEnB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAiBjB,OAAO,EAAiC,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EAAgE,aAAa,EAAE,MAAM,SAAS,CAAC;AAiBtG,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,SAAS,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;CACzC;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,cAAc,eA0IpG"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useMemo,useRef,useState}from"react";import{useDeepMemo}from"@perses-dev/core";import{Box}from"@mui/material";import{use}from"echarts/core";import{LineChart as EChartsLineChart}from"echarts/charts";import{GridComponent,DataZoomComponent,MarkAreaComponent,MarkLineComponent,MarkPointComponent,TitleComponent,ToolboxComponent,TooltipComponent,LegendComponent,VisualMapComponent}from"echarts/components";import{CanvasRenderer}from"echarts/renderers";import{EChart}from"../EChart";import{PROGRESSIVE_MODE_SERIES_LIMIT}from"../model/graph";import{formatValue}from"../model/units";import{useChartsTheme}from"../context/ChartsThemeProvider";import{emptyTooltipData}from"../Tooltip/tooltip-model";import{Tooltip}from"../Tooltip/Tooltip";import{enableDataZoom,restoreChart,getDateRange,getFormattedDate}from"./utils";use([EChartsLineChart,GridComponent,DataZoomComponent,MarkAreaComponent,MarkLineComponent,MarkPointComponent,TitleComponent,ToolboxComponent,TooltipComponent,LegendComponent,VisualMapComponent,CanvasRenderer]);export function LineChart({height:e,data:o,unit:t,grid:r,legend:a,visualMap:n,onDataZoom:i}){const s=useChartsTheme(),m=useRef(),[p,l]=useState(!0),u=useMemo((()=>({datazoom:e=>{var t,r;if(void 0===i||void 0===e.batch[0])return;const a=null!==(t=e.batch[0].startValue)&&void 0!==t?t:0,n=null!==(r=e.batch[0].endValue)&&void 0!==r?r:o.xAxis.length-1,s=o.xAxis[a],m=o.xAxis[n];void 0!==s&&void 0!==m&&i({start:s,end:m,startIndex:a,endIndex:n})}})),[o,i]);void 0!==m.current&&enableDataZoom(m.current);const h=useDeepMemo((()=>{var e;if(void 0===o.timeSeries)return{};if(null===o.timeSeries||0===o.timeSeries.length)return s.noDataOption;const i=o.timeSeries.length<PROGRESSIVE_MODE_SERIES_LIMIT,m=null!==(e=o.rangeMs)&&void 0!==e?e:getDateRange(o.xAxis);return{series:o.timeSeries,xAxis:{type:"category",data:o.xAxis,max:o.xAxisMax,axisLabel:{formatter:e=>getFormattedDate(e,m)}},yAxis:{type:"value",boundaryGap:[0,"10%"],axisLabel:{formatter:e=>formatValue(e,t)}},animation:!1,tooltip:{show:i,trigger:"axis",showContent:!1,axisPointer:{type:"none"}},toolbox:{feature:{dataZoom:{icon:null,yAxisIndex:"none"}}},grid:r,legend:a,visualMap:n}}),[o,r,a,n]);return _jsxs(Box,{sx:{height:e},onDoubleClick:()=>{void 0!==m.current&&restoreChart(m.current)},onMouseDown:e=>{e.target instanceof HTMLCanvasElement&&l(!1)},onMouseUp:()=>{l(!0)},onMouseLeave:()=>{l(!1)},onMouseEnter:()=>{l(!0)},children:[!0===p&&_jsx(Tooltip,{chartRef:m,tooltipData:emptyTooltipData,chartData:o,wrapLabels:!0}),_jsx(EChart,{sx:{width:"100%",height:"100%"},option:h,theme:s.themeName,onEvents:u,_instance:m})]})}
@@ -0,0 +1,3 @@
1
+ export * from './LineChart';
2
+ export type { ZoomEventData } from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/LineChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./LineChart";
@@ -0,0 +1,12 @@
1
+ import { ECharts as EChartsInstance } from 'echarts/core';
2
+ export interface ZoomEventData {
3
+ start: number;
4
+ end: number;
5
+ startIndex: number;
6
+ endIndex: number;
7
+ }
8
+ export declare function enableDataZoom(chart: EChartsInstance): void;
9
+ export declare function restoreChart(chart: EChartsInstance): void;
10
+ export declare function getDateRange(data: number[]): number;
11
+ export declare function getFormattedDate(value: number, rangeMs: number): string;
12
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/LineChart/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,QAapD;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,QAIlD;AAGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAM1C;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAiB9D"}
@@ -0,0 +1 @@
1
+ export function enableDataZoom(o){const t=o._model;void 0!==t&&void 0!==t.option.toolbox&&t.option.toolbox.length>0&&"normal"===t.option.toolbox[0].feature.dataZoom.iconStatus.zoom&&o.dispatchAction({type:"takeGlobalCursor",key:"dataZoomSelect",dataZoomSelectActive:!0})}export function restoreChart(o){o.dispatchAction({type:"restore"})}export function getDateRange(o){const t=36e5;if(0===o.length)return t;const e=o[o.length-1];return void 0===o[0]||void 0===e?t:e-o[0]}export function getFormattedDate(o,t){const e={hour:"numeric",minute:"numeric",hourCycle:"h23"};return t<=18e5?e.second="numeric":t>=864e5&&(e.month="numeric",e.day="numeric"),new Intl.DateTimeFormat(void 0,e).format(o).replace(/, /g," ")}
@@ -1,14 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { LineSeriesOption } from 'echarts/charts';
3
- import { UnitOptions } from './model/units';
4
- import { GraphSeriesValueTuple } from './model/graph-model';
5
- export interface GraphSeries {
6
- name: string;
7
- values: Iterable<GraphSeriesValueTuple>;
8
- }
3
+ import { UnitOptions } from '../model/units';
4
+ import { GraphSeries } from '../model/graph';
9
5
  export interface StatChartData {
10
- calculatedValue: number | null | undefined;
11
- seriesData: GraphSeries | null | undefined;
6
+ calculatedValue?: number;
7
+ seriesData?: GraphSeries;
12
8
  name?: string;
13
9
  }
14
10
  interface StatChartProps {
@@ -16,7 +12,6 @@ interface StatChartProps {
16
12
  height: number;
17
13
  data: StatChartData;
18
14
  unit: UnitOptions;
19
- backgroundColor?: string;
20
15
  sparkline?: LineSeriesOption;
21
16
  }
22
17
  export declare function StatChart(props: StatChartProps): JSX.Element;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatChart.d.ts","sourceRoot":"","sources":["../../src/StatChart/StatChart.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAiC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIjF,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAgB7C,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAwF9C"}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useMemo}from"react";import{Box,Typography}from"@mui/material";import{merge}from"lodash-es";import{use}from"echarts/core";import{GaugeChart as EChartsGaugeChart}from"echarts/charts";import{LineChart as EChartsLineChart}from"echarts/charts";import{GridComponent,DatasetComponent,TitleComponent,TooltipComponent}from"echarts/components";import{CanvasRenderer}from"echarts/renderers";import{useChartsTheme}from"../context/ChartsThemeProvider";import{formatValue}from"../model/units";import{EChart}from"../EChart";use([EChartsGaugeChart,EChartsLineChart,GridComponent,DatasetComponent,TitleComponent,TooltipComponent,CanvasRenderer]);const PANEL_PADDING=32,MIN_VALUE_SIZE=12,MAX_VALUE_SIZE=36;export function StatChart(t){const{width:e,height:o,data:r,unit:a,sparkline:s}=t,i=useChartsTheme(),n=void 0===r.calculatedValue?"No data":formatValue(r.calculatedValue,a),m=useMemo((()=>{if(void 0===r.seriesData)return i.noDataOption;const t=r.seriesData,e=[];if(void 0!==s){const o={type:"line",data:[...t.values],zlevel:1,symbol:"none",animation:!1,silent:!0},r=merge(o,s);e.push(r)}return{title:{show:!1},grid:{show:!1,top:"35%",right:0,bottom:0,left:0,containLabel:!1},xAxis:{type:"time",show:!1,boundaryGap:!1},yAxis:{type:"value",show:!1},tooltip:{show:!1},series:e}}),[r,i,s]),h=e>250&&o>180,p=n.length,l=!0===h?36:Math.min(e,o)/p;return _jsxs(Box,{children:[_jsx(Typography,{variant:"h3",sx:t=>({color:t.palette.text.primary,fontSize:`clamp(12px, ${l}px, 36px)`}),children:n}),void 0!==s&&_jsx(EChart,{sx:{width:e+32,height:o,position:"absolute",bottom:0,left:0},option:m,theme:i.themeName,renderer:"svg"})]})}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StatChart.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatChart.test.d.ts","sourceRoot":"","sources":["../../src/StatChart/StatChart.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{render,screen}from"@testing-library/react";import{ChartsThemeProvider}from"../context/ChartsThemeProvider";import{StatChart}from"./StatChart";describe("StatChart",(()=>{const e={kind:"Decimal",decimal_places:2},t={calculatedValue:7.72931659687181,name:"Example Stat Chart",seriesData:{name:'(((count(count(node_cpu_seconds_total{job="example"}) by (cpu))',values:[[165400617e4,7.736401673473903],[1654006185e3,7.733891213538757],[16540062e5,7.731101813010433],[1654006215e3,7.722454672079215],[165400623e4,7.722733612256738]]}},r={themeName:"perses",echartsTheme:{},noDataOption:{},sparkline:{width:1,color:"#000000"}};describe("Render default options (no sparkline)",(()=>{it("should render",(()=>{render(_jsx(ChartsThemeProvider,{themeName:"perses",chartsTheme:r,children:_jsx(StatChart,{width:200,height:200,data:t,unit:e})})),expect(screen.getByText("7.73")).toBeInTheDocument()}))}))}));
@@ -0,0 +1,2 @@
1
+ export * from './StatChart';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/StatChart/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./StatChart";
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"SeriesInfo.d.ts","sourceRoot":"","sources":["../../src/tooltip/SeriesInfo.tsx"],"names":[],"mappings":";AAiBA,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAiHhD"}
1
+ {"version":3,"file":"SeriesInfo.d.ts","sourceRoot":"","sources":["../../src/Tooltip/SeriesInfo.tsx"],"names":[],"mappings":";AAiBA,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAkHhD"}
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Box,Divider,Stack,Typography}from"@mui/material";import{SeriesMarker}from"./SeriesMarker";import{TOOLTIP_LABELS_MAX_WIDTH}from"./tooltip-model";export function SeriesInfo(e){const{seriesName:o,y:r,markerColor:t,totalSeries:i,wrapLabels:s}=e,l=o.replace(/[{}"]/g,"");if(1===i){const e="{"===o[0];return _jsxs(Stack,{spacing:.5,children:[_jsxs(Box,{sx:e=>({height:"16px",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"left",color:e.palette.common.white,fontSize:"11px"}),children:[_jsx(SeriesMarker,{markerColor:t}),_jsxs(Box,{component:"span",children:["value:",_jsx(Box,{component:"span",sx:e=>({color:e.palette.common.white,fontWeight:700,paddingLeft:"2px"}),children:r})]})]}),_jsx(Divider,{sx:e=>({borderColor:e.palette.grey[500]})}),_jsx(Box,{sx:e=>({color:e.palette.common.white}),children:l.split(",").map((o=>{if(o){const[r,t]=e?o.split(":"):o.split("=");return _jsxs(Box,{sx:{display:"flex",gap:"4px"},children:[_jsxs(Typography,{sx:{fontSize:"11px"},children:[r,":"]}),_jsx(Typography,{sx:e=>({color:e.palette.common.white,fontWeight:700,fontSize:"11px"}),children:t})]},o)}}))})]})}const n=l.replace(/[,]/g,", ").replace(/[:=]/g,": ");return _jsxs(Box,{sx:{display:"table-row",paddingTop:.5},children:[_jsxs(Box,{sx:{display:"table-cell",maxWidth:"520px"},children:[_jsx(SeriesMarker,{markerColor:t}),_jsx(Box,{component:"span",sx:e=>({color:e.palette.common.white,display:"inline-block",maxWidth:TOOLTIP_LABELS_MAX_WIDTH,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:s?"normal":"nowrap",width:"calc(100% - 20px)"}),children:n})]}),_jsx(Box,{sx:{display:"table-cell",fontWeight:"700",paddingLeft:1.5,textAlign:"right",verticalAlign:"top"},children:r})]})}
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Box,Divider,Stack,Typography}from"@mui/material";import{SeriesMarker}from"./SeriesMarker";import{TOOLTIP_LABELS_MAX_WIDTH}from"./tooltip-model";export function SeriesInfo(e){const{seriesName:o,y:r,markerColor:t,totalSeries:i,wrapLabels:s}=e,l=o.replace(/[{}"]/g,"");if(1===i){const e="{"===o[0];return _jsxs(Stack,{spacing:.5,children:[_jsxs(Box,{sx:e=>({height:"16px",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"left",color:e.palette.common.white,fontSize:"11px"}),children:[_jsx(SeriesMarker,{markerColor:t}),_jsxs(Box,{component:"span",children:["value:",_jsx(Box,{component:"span",sx:e=>({color:e.palette.common.white,fontWeight:700,paddingLeft:"2px"}),children:r})]})]}),_jsx(Divider,{sx:e=>({borderColor:e.palette.grey[500]})}),_jsx(Box,{sx:e=>({color:e.palette.common.white}),children:l.split(",").map((o=>{if(o){const[r,t]=e?o.split(":"):o.split("=");return _jsxs(Box,{sx:{display:"flex",gap:"4px"},children:[_jsx(Typography,{sx:{fontSize:"11px"},children:void 0!==t?`${r}: `:r}),_jsx(Typography,{sx:e=>({color:e.palette.common.white,fontWeight:700,fontSize:"11px"}),children:t})]},o)}}))})]})}const n=l.replace(/[,]/g,", ").replace(/[:=]/g,": ");return _jsxs(Box,{sx:{display:"table-row",paddingTop:.5},children:[_jsxs(Box,{sx:{display:"table-cell",maxWidth:"520px"},children:[_jsx(SeriesMarker,{markerColor:t}),_jsx(Box,{component:"span",sx:e=>({color:e.palette.common.white,display:"inline-block",maxWidth:TOOLTIP_LABELS_MAX_WIDTH,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:s?"normal":"nowrap",width:"calc(100% - 20px)"}),children:n})]}),_jsx(Box,{sx:{display:"table-cell",fontWeight:"700",paddingLeft:1.5,textAlign:"right",verticalAlign:"top"},children:r})]})}
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"SeriesMarker.d.ts","sourceRoot":"","sources":["../../src/tooltip/SeriesMarker.tsx"],"names":[],"mappings":";AAeA,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAgBpD"}
1
+ {"version":3,"file":"SeriesMarker.d.ts","sourceRoot":"","sources":["../../src/Tooltip/SeriesMarker.tsx"],"names":[],"mappings":";AAeA,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAgBpD"}
File without changes
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ECharts as EChartsInstance } from 'echarts/core';
3
- import { EChartsDataFormat } from '../model/graph-model';
3
+ import { EChartsDataFormat } from '../model/graph';
4
4
  import { TooltipData } from './tooltip-model';
5
5
  interface TooltipProps {
6
6
  chartRef: React.MutableRefObject<EChartsInstance | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAGL,WAAW,EAIZ,MAAM,iBAAiB,CAAC;AAGzB,UAAU,YAAY;IACpB,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,sBA4D1C"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAGL,WAAW,EAIZ,MAAM,iBAAiB,CAAC;AAGzB,UAAU,YAAY;IACpB,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,sBA4D1C"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../src/tooltip/TooltipContent.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,UAAU,mBAAmB;IAC3B,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAgExD"}
1
+ {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../src/Tooltip/TooltipContent.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,UAAU,mBAAmB;IAC3B,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAgExD"}
File without changes
@@ -1,5 +1,5 @@
1
1
  import { ECharts as EChartsInstance } from 'echarts/core';
2
- import { EChartsDataFormat } from '../model/graph-model';
2
+ import { EChartsDataFormat } from '../model/graph';
3
3
  import { CursorData } from './tooltip-model';
4
4
  export interface FocusedSeriesInfo {
5
5
  seriesIdx: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"focused-series.d.ts","sourceRoot":"","sources":["../../src/tooltip/focused-series.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAA0C,MAAM,iBAAiB,CAAC;AAErF,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,oBAAY,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;AAErD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,CA0CnH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC9B,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC/B,KAAK,CAAC,EAAE,eAAe,sBA2CxB"}
1
+ {"version":3,"file":"focused-series.d.ts","sourceRoot":"","sources":["../../src/Tooltip/focused-series.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,UAAU,EAA0C,MAAM,iBAAiB,CAAC;AAErF,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,oBAAY,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;AAErD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,CA0CnH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC9B,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC/B,KAAK,CAAC,EAAE,eAAe,sBA2CxB"}
File without changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=focused-series.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focused-series.test.d.ts","sourceRoot":"","sources":["../../src/Tooltip/focused-series.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ import{getNearbySeries}from"./focused-series";describe("getNearbySeries",(()=>{const e={timeSeries:[{type:"line",name:'env="demo", instance="demo.do.prometheus", job="node", mode="test"',color:"hsla(-1365438424,50%,50%,0.8)",data:[.0002315202231525094,.00022873082287300112,.00023152022315149463,.00023152022315149463,.00022873082287300112],symbol:"circle"},{type:"line",name:'env="demo", instance="demo.do.prometheus", job="node", mode="test alt"',color:"hsla(286664040,50%,50%,0.8)",data:[.05245188284519867,.0524463040446356,.0524463040446356,.05247140864723438,.052482566248230646],symbol:"circle"}],xAxis:[1654007865e3,165400788e4,1654007895e3,165400791e4,1654007925e3],rangeMs:6e4},o=[2,.0560655737704918],s=[{date:"May 31, 2022, 2:38:15 PM",datumIdx:2,markerColor:"hsla(286664040,50%,50%,0.8)",seriesName:'env="demo", instance="demo.do.prometheus", job="node", mode="test alt"',seriesIdx:1,x:1654007895e3,y:.0524463040446356}];it("should return focused series data for points nearby the cursor",(()=>{expect(getNearbySeries(e,o,.02)).toEqual(s)}))}));
@@ -0,0 +1,3 @@
1
+ export * from './Tooltip';
2
+ export * from './SeriesMarker';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Tooltip/index.ts"],"names":[],"mappings":"AAaA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./Tooltip";export*from"./SeriesMarker";
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-model.d.ts","sourceRoot":"","sources":["../../src/tooltip/tooltip-model.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,wBAAwB,QAA0B,CAAC;AAEhE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,mBAAmB,qBAQ9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAiB7B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;CAG5B,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE;QACR,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,UAAU,EAAE;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF,OAAO,EAAE;QACP,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,MAAM,EAAE,WAAW,GAAG,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AC;KACX,CAAC;IACF,OAAO,EAAE;QACP,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,aAAK,iBAAiB,GAAG;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,oBAAY,eAAe,GAAG,UAAU,GAAG,iBAAiB,CAAC;AAE7D,eAAO,MAAM,gBAAgB,QAAO,UAAU,CAAC,QAAQ,CAgCtD,CAAC"}
File without changes
@@ -57,7 +57,7 @@ const mouseEvents = [
57
57
  'contextmenu',
58
58
  ];
59
59
  const batchEvents = ['datazoom', 'downplay', 'highlight'];
60
- exports.EChart = react_1.default.memo(function EChart({ option, sx, onEvents, _instance, onChartInitialized, }) {
60
+ exports.EChart = react_1.default.memo(function EChart({ option, theme, renderer, sx, onEvents, _instance, onChartInitialized, }) {
61
61
  const initialOption = (0, react_1.useRef)(option);
62
62
  const prevOption = (0, react_1.useRef)(option);
63
63
  const containerRef = (0, react_1.useRef)(null);
@@ -66,7 +66,7 @@ exports.EChart = react_1.default.memo(function EChart({ option, sx, onEvents, _i
66
66
  (0, react_1.useLayoutEffect)(() => {
67
67
  if (containerRef.current === null || chartElement.current !== null)
68
68
  return;
69
- chartElement.current = (0, core_1.init)(containerRef.current);
69
+ chartElement.current = (0, core_1.init)(containerRef.current, theme, { renderer: renderer !== null && renderer !== void 0 ? renderer : 'canvas' });
70
70
  chartElement.current.setOption(initialOption.current, true);
71
71
  onChartInitialized === null || onChartInitialized === void 0 ? void 0 : onChartInitialized(chartElement.current);
72
72
  if (_instance !== undefined) {
@@ -78,7 +78,7 @@ exports.EChart = react_1.default.memo(function EChart({ option, sx, onEvents, _i
78
78
  chartElement.current.dispose();
79
79
  chartElement.current = null;
80
80
  };
81
- }, [_instance, onChartInitialized]);
81
+ }, [_instance, onChartInitialized, theme, renderer]);
82
82
  // Update chart data when option changes
83
83
  (0, react_1.useEffect)(() => {
84
84
  if (prevOption.current === undefined || (0, lodash_es_1.isEqual)(prevOption.current, option))
@@ -19,34 +19,16 @@ const core_1 = require("echarts/core");
19
19
  const charts_1 = require("echarts/charts");
20
20
  const components_1 = require("echarts/components");
21
21
  const renderers_1 = require("echarts/renderers");
22
- const units_1 = require("./model/units");
23
- const EChart_1 = require("./EChart");
22
+ const ChartsThemeProvider_1 = require("../context/ChartsThemeProvider");
23
+ const units_1 = require("../model/units");
24
+ const EChart_1 = require("../EChart");
24
25
  (0, core_1.use)([charts_1.GaugeChart, components_1.GridComponent, components_1.TitleComponent, components_1.TooltipComponent, renderers_1.CanvasRenderer]);
25
- const noDataOption = {
26
- title: {
27
- show: true,
28
- textStyle: {
29
- color: 'grey',
30
- fontSize: 16,
31
- fontWeight: 400,
32
- },
33
- text: 'No data',
34
- left: 'center',
35
- top: 'center',
36
- },
37
- xAxis: {
38
- show: false,
39
- },
40
- yAxis: {
41
- show: false,
42
- },
43
- series: [],
44
- };
45
26
  function GaugeChart(props) {
46
- const { width, height, data, unit, axisLine } = props;
27
+ const { width, height, data, unit, axisLine, max } = props;
28
+ const chartsTheme = (0, ChartsThemeProvider_1.useChartsTheme)();
47
29
  const option = (0, react_1.useMemo)(() => {
48
30
  if (data === null || data === undefined)
49
- return noDataOption;
31
+ return chartsTheme.noDataOption;
50
32
  const calculatedValue = data;
51
33
  return {
52
34
  title: {
@@ -63,8 +45,7 @@ function GaugeChart(props) {
63
45
  startAngle: 200,
64
46
  endAngle: -20,
65
47
  min: 0,
66
- max: 100,
67
- splitNumber: 12,
48
+ max,
68
49
  silent: true,
69
50
  progress: {
70
51
  show: true,
@@ -84,21 +65,10 @@ function GaugeChart(props) {
84
65
  },
85
66
  axisTick: {
86
67
  show: false,
87
- distance: -28,
88
- splitNumber: 5,
89
- lineStyle: {
90
- width: 2,
91
- color: '#999',
92
- },
68
+ distance: 0,
93
69
  },
94
70
  splitLine: {
95
- show: false,
96
- distance: -32,
97
- length: 6,
98
- lineStyle: {
99
- width: 2,
100
- color: '#999',
101
- },
71
+ show: true,
102
72
  },
103
73
  axisLabel: {
104
74
  show: false,
@@ -128,7 +98,7 @@ function GaugeChart(props) {
128
98
  startAngle: 200,
129
99
  endAngle: -20,
130
100
  min: 0,
131
- max: 100,
101
+ max,
132
102
  pointer: {
133
103
  show: false,
134
104
  itemStyle: {
@@ -147,12 +117,9 @@ function GaugeChart(props) {
147
117
  },
148
118
  detail: {
149
119
  show: true,
150
- valueAnimation: false,
151
120
  width: '60%',
152
121
  borderRadius: 8,
153
122
  offsetCenter: [0, '-9%'],
154
- fontSize: 20,
155
- fontWeight: 'bolder',
156
123
  color: 'inherit',
157
124
  formatter: (value) => {
158
125
  return (0, units_1.formatValue)(value, {
@@ -169,10 +136,10 @@ function GaugeChart(props) {
169
136
  },
170
137
  ],
171
138
  };
172
- }, [data, unit, axisLine]);
139
+ }, [data, chartsTheme, unit, axisLine, max]);
173
140
  return ((0, jsx_runtime_1.jsx)(EChart_1.EChart, { sx: {
174
141
  width: width,
175
142
  height: height,
176
- }, option: option }));
143
+ }, option: option, theme: chartsTheme.themeName }));
177
144
  }
178
145
  exports.GaugeChart = GaugeChart;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ // Copyright 2022 The Perses Authors
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ __exportStar(require("./GaugeChart"), exports);