@perses-dev/components 0.8.1 → 0.9.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 (131) hide show
  1. package/dist/Drawer/Drawer.d.ts +3 -4
  2. package/dist/Drawer/Drawer.d.ts.map +1 -1
  3. package/dist/Drawer/Drawer.js +35 -1
  4. package/dist/Drawer/Drawer.js.map +1 -0
  5. package/dist/Drawer/index.js +15 -1
  6. package/dist/Drawer/index.js.map +1 -0
  7. package/dist/EChart.d.ts.map +1 -1
  8. package/dist/EChart.js +142 -1
  9. package/dist/EChart.js.map +1 -0
  10. package/dist/ErrorAlert.js +25 -1
  11. package/dist/ErrorAlert.js.map +1 -0
  12. package/dist/ErrorBoundary.js +16 -1
  13. package/dist/ErrorBoundary.js.map +1 -0
  14. package/dist/GaugeChart/GaugeChart.js +172 -1
  15. package/dist/GaugeChart/GaugeChart.js.map +1 -0
  16. package/dist/GaugeChart/index.js +15 -1
  17. package/dist/GaugeChart/index.js.map +1 -0
  18. package/dist/InfoTooltip/InfoTooltip.js +79 -1
  19. package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
  20. package/dist/InfoTooltip/InfoTooltip.test.js +36 -1
  21. package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
  22. package/dist/InfoTooltip/index.js +15 -1
  23. package/dist/InfoTooltip/index.js.map +1 -0
  24. package/dist/LineChart/LineChart.js +198 -1
  25. package/dist/LineChart/LineChart.js.map +1 -0
  26. package/dist/LineChart/index.js +15 -1
  27. package/dist/LineChart/index.js.map +1 -0
  28. package/dist/LineChart/utils.js +63 -1
  29. package/dist/LineChart/utils.js.map +1 -0
  30. package/dist/StatChart/StatChart.js +121 -1
  31. package/dist/StatChart/StatChart.js.map +1 -0
  32. package/dist/StatChart/StatChart.test.js +82 -1
  33. package/dist/StatChart/StatChart.test.js.map +1 -0
  34. package/dist/StatChart/index.js +15 -1
  35. package/dist/StatChart/index.js.map +1 -0
  36. package/dist/TimeRangeSelector/AbsoluteTimePicker.js +175 -1
  37. package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +1 -0
  38. package/dist/TimeRangeSelector/TimeRangeSelector.js +52 -1
  39. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
  40. package/dist/TimeRangeSelector/index.js +16 -1
  41. package/dist/TimeRangeSelector/index.js.map +1 -0
  42. package/dist/TimeRangeSelector/utils.js +36 -1
  43. package/dist/TimeRangeSelector/utils.js.map +1 -0
  44. package/dist/Tooltip/SeriesInfo.js +143 -1
  45. package/dist/Tooltip/SeriesInfo.js.map +1 -0
  46. package/dist/Tooltip/SeriesMarker.js +33 -1
  47. package/dist/Tooltip/SeriesMarker.js.map +1 -0
  48. package/dist/Tooltip/Tooltip.js +72 -1
  49. package/dist/Tooltip/Tooltip.js.map +1 -0
  50. package/dist/Tooltip/TooltipContent.js +89 -1
  51. package/dist/Tooltip/TooltipContent.js.map +1 -0
  52. package/dist/Tooltip/focused-series.js +108 -1
  53. package/dist/Tooltip/focused-series.js.map +1 -0
  54. package/dist/Tooltip/focused-series.test.js +75 -1
  55. package/dist/Tooltip/focused-series.test.js.map +1 -0
  56. package/dist/Tooltip/index.js +16 -1
  57. package/dist/Tooltip/index.js.map +1 -0
  58. package/dist/Tooltip/tooltip-model.js +80 -1
  59. package/dist/Tooltip/tooltip-model.js.map +1 -0
  60. package/dist/Tooltip/utils.js +46 -1
  61. package/dist/Tooltip/utils.js.map +1 -0
  62. package/dist/cjs/Drawer/Drawer.js +26 -13
  63. package/dist/cjs/Drawer/index.js +16 -17
  64. package/dist/cjs/EChart.js +114 -89
  65. package/dist/cjs/ErrorAlert.js +16 -12
  66. package/dist/cjs/ErrorBoundary.js +10 -6
  67. package/dist/cjs/GaugeChart/GaugeChart.js +90 -57
  68. package/dist/cjs/GaugeChart/index.js +16 -17
  69. package/dist/cjs/InfoTooltip/InfoTooltip.js +90 -33
  70. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +27 -17
  71. package/dist/cjs/InfoTooltip/index.js +16 -17
  72. package/dist/cjs/LineChart/LineChart.js +122 -87
  73. package/dist/cjs/LineChart/index.js +16 -17
  74. package/dist/cjs/LineChart/utils.js +23 -23
  75. package/dist/cjs/StatChart/StatChart.js +107 -46
  76. package/dist/cjs/StatChart/StatChart.test.js +65 -21
  77. package/dist/cjs/StatChart/index.js +16 -17
  78. package/dist/cjs/TimeRangeSelector/AbsoluteTimePicker.js +144 -64
  79. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +45 -22
  80. package/dist/cjs/TimeRangeSelector/index.js +17 -18
  81. package/dist/cjs/TimeRangeSelector/utils.js +19 -16
  82. package/dist/cjs/Tooltip/SeriesInfo.js +120 -48
  83. package/dist/cjs/Tooltip/SeriesMarker.js +20 -11
  84. package/dist/cjs/Tooltip/Tooltip.js +95 -67
  85. package/dist/cjs/Tooltip/TooltipContent.js +76 -31
  86. package/dist/cjs/Tooltip/focused-series.js +40 -36
  87. package/dist/cjs/Tooltip/focused-series.test.js +36 -16
  88. package/dist/cjs/Tooltip/index.js +17 -18
  89. package/dist/cjs/Tooltip/tooltip-model.js +46 -30
  90. package/dist/cjs/Tooltip/utils.js +13 -16
  91. package/dist/cjs/context/ChartsThemeProvider.js +65 -13
  92. package/dist/cjs/index.js +27 -28
  93. package/dist/cjs/model/graph.js +10 -5
  94. package/dist/cjs/model/index.js +18 -19
  95. package/dist/cjs/model/theme.js +4 -2
  96. package/dist/cjs/model/units.js +68 -51
  97. package/dist/cjs/test/index.js +16 -17
  98. package/dist/cjs/test/render.js +22 -12
  99. package/dist/cjs/test/setup-tests.js +4 -2
  100. package/dist/cjs/utils/combine-sx.js +15 -16
  101. package/dist/cjs/utils/index.js +17 -18
  102. package/dist/cjs/utils/theme-gen.js +64 -55
  103. package/dist/cjs/utils/theme-gen.test.js +14 -12
  104. package/dist/context/ChartsThemeProvider.js +36 -1
  105. package/dist/context/ChartsThemeProvider.js.map +1 -0
  106. package/dist/index.js +26 -1
  107. package/dist/index.js.map +1 -0
  108. package/dist/model/graph.js +15 -1
  109. package/dist/model/graph.js.map +1 -0
  110. package/dist/model/index.js +17 -1
  111. package/dist/model/index.js.map +1 -0
  112. package/dist/model/theme.js +15 -1
  113. package/dist/model/theme.js.map +1 -0
  114. package/dist/model/units.d.ts.map +1 -1
  115. package/dist/model/units.js +196 -1
  116. package/dist/model/units.js.map +1 -0
  117. package/dist/test/index.js +15 -1
  118. package/dist/test/index.js.map +1 -0
  119. package/dist/test/render.js +32 -1
  120. package/dist/test/render.js.map +1 -0
  121. package/dist/test/setup-tests.js +18 -1
  122. package/dist/test/setup-tests.js.map +1 -0
  123. package/dist/utils/combine-sx.js +27 -1
  124. package/dist/utils/combine-sx.js.map +1 -0
  125. package/dist/utils/index.js +16 -1
  126. package/dist/utils/index.js.map +1 -0
  127. package/dist/utils/theme-gen.js +183 -1
  128. package/dist/utils/theme-gen.js.map +1 -0
  129. package/dist/utils/theme-gen.test.js +196 -1
  130. package/dist/utils/theme-gen.test.js.map +1 -0
  131. package/package.json +8 -4
@@ -1,10 +1,9 @@
1
1
  /// <reference types="react" />
2
- interface DrawerProps {
2
+ import { DrawerProps as MuiDrawerProps } from '@mui/material';
3
+ export interface DrawerProps extends MuiDrawerProps {
3
4
  isOpen: boolean;
4
5
  onClose: () => void;
5
6
  anchor?: 'left' | 'right';
6
- children?: React.ReactNode;
7
7
  }
8
- export declare const Drawer: ({ anchor, isOpen, onClose, children }: DrawerProps) => JSX.Element;
9
- export {};
8
+ export declare const Drawer: ({ anchor, isOpen, onClose, PaperProps, children, ...rest }: DrawerProps) => JSX.Element;
10
9
  //# sourceMappingURL=Drawer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/Drawer/Drawer.tsx"],"names":[],"mappings":";AAeA,UAAU,WAAW;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAID,eAAO,MAAM,MAAM,0CAAqD,WAAW,gBAiBlF,CAAC"}
1
+ {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/Drawer/Drawer.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAuB,WAAW,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AAGnF,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAID,eAAO,MAAM,MAAM,+DAA0E,WAAW,gBAsBvG,CAAC"}
@@ -1 +1,35 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{Drawer as MuiDrawer}from"@mui/material";const DRAWER_DEFAULT_WIDTH=900;export const Drawer=({anchor:r="right",isOpen:e,onClose:o,children:i})=>_jsx(MuiDrawer,{open:e,onClose:o,anchor:r,PaperProps:{sx:{width:"900px",padding:r=>r.spacing(2),overflow:"hidden"}},children:i});
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Drawer as MuiDrawer } from '@mui/material';
15
+ import { combineSx } from '../utils';
16
+ const DRAWER_DEFAULT_WIDTH = 900;
17
+ export const Drawer = ({ anchor ='right' , isOpen , onClose , PaperProps , children , ...rest })=>{
18
+ return /*#__PURE__*/ _jsx(MuiDrawer, {
19
+ ...rest,
20
+ open: isOpen,
21
+ onClose: onClose,
22
+ anchor: anchor,
23
+ PaperProps: {
24
+ ...PaperProps,
25
+ sx: combineSx({
26
+ width: `${DRAWER_DEFAULT_WIDTH}px`,
27
+ padding: (theme)=>theme.spacing(2),
28
+ overflow: 'hidden'
29
+ }, PaperProps === null || PaperProps === void 0 ? void 0 : PaperProps.sx)
30
+ },
31
+ children: children
32
+ });
33
+ };
34
+
35
+ //# sourceMappingURL=Drawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Drawer/Drawer.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Drawer as MuiDrawer, DrawerProps as MuiDrawerProps } from '@mui/material';\nimport { combineSx } from '../utils';\n\nexport interface DrawerProps extends MuiDrawerProps {\n isOpen: boolean;\n onClose: () => void;\n anchor?: 'left' | 'right';\n}\n\nconst DRAWER_DEFAULT_WIDTH = 900;\n\nexport const Drawer = ({ anchor = 'right', isOpen, onClose, PaperProps, children, ...rest }: DrawerProps) => {\n return (\n <MuiDrawer\n {...rest}\n open={isOpen}\n onClose={onClose}\n anchor={anchor}\n PaperProps={{\n ...PaperProps,\n sx: combineSx(\n {\n width: `${DRAWER_DEFAULT_WIDTH}px`,\n padding: (theme) => theme.spacing(2),\n overflow: 'hidden',\n },\n PaperProps?.sx\n ),\n }}\n >\n {children}\n </MuiDrawer>\n );\n};\n"],"names":["Drawer","MuiDrawer","combineSx","DRAWER_DEFAULT_WIDTH","anchor","isOpen","onClose","PaperProps","children","rest","open","sx","width","padding","theme","spacing","overflow"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,IAAIC,SAAS,QAAuC,eAAe,CAAC;AACnF,SAASC,SAAS,QAAQ,UAAU,CAAC;AAQrC,MAAMC,oBAAoB,GAAG,GAAG,AAAC;AAEjC,OAAO,MAAMH,MAAM,GAAG,CAAC,EAAEI,MAAM,EAAG,OAAO,CAAA,EAAEC,MAAM,CAAA,EAAEC,OAAO,CAAA,EAAEC,UAAU,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGC,IAAI,EAAe,GAAK;IAC3G,qBACE,KAACR,SAAS;QACP,GAAGQ,IAAI;QACRC,IAAI,EAAEL,MAAM;QACZC,OAAO,EAAEA,OAAO;QAChBF,MAAM,EAAEA,MAAM;QACdG,UAAU,EAAE;YACV,GAAGA,UAAU;YACbI,EAAE,EAAET,SAAS,CACX;gBACEU,KAAK,EAAE,CAAC,EAAET,oBAAoB,CAAC,EAAE,CAAC;gBAClCU,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;gBACpCC,QAAQ,EAAE,QAAQ;aACnB,EACDT,UAAU,aAAVA,UAAU,WAAI,GAAdA,KAAAA,CAAc,GAAdA,UAAU,CAAEI,EAAE,CACf;SACF;kBAEAH,QAAQ;MACC,CACZ;AACJ,CAAC,CAAC"}
@@ -1 +1,15 @@
1
- export*from"./Drawer";
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './Drawer';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Drawer/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './Drawer';\n"],"names":[],"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,cAAc,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"EChart.d.ts","sourceRoot":"","sources":["../src/EChart.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAQ,MAAM,cAAc,CAAC;AAChE,OAAO,EAAO,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EA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;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,6IA0EjB,CAAC"}
package/dist/EChart.js CHANGED
@@ -1 +1,142 @@
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:u,_instance:o,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!==o&&(o.current=f.current),()=>{null!==f.current&&(f.current.dispose(),f.current=null)}}),[o,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!==u)return bindEvents(e,u),()=>{if(void 0!==e&&!0!==e.isDisposed())for(const n in u)e.off(n)}}),[u]),useEffect((()=>{debounce((()=>{null!==f.current&&f.current.resize()}),200)()}),[r]),_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 u=null!==(t=n[e])&&void 0!==t?t:null;u&&r(e,u)}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
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import React, { useEffect, useLayoutEffect, useRef } from 'react';
15
+ import { init } from 'echarts/core';
16
+ import { Box } from '@mui/material';
17
+ import { isEqual, debounce } from 'lodash-es';
18
+ const mouseEvents = [
19
+ 'click',
20
+ 'dblclick',
21
+ 'mousedown',
22
+ 'mousemove',
23
+ 'mouseup',
24
+ 'mouseover',
25
+ 'mouseout',
26
+ 'globalout',
27
+ 'contextmenu'
28
+ ];
29
+ const batchEvents = [
30
+ 'datazoom',
31
+ 'downplay',
32
+ 'highlight'
33
+ ];
34
+ export const EChart = /*#__PURE__*/ React.memo(function EChart({ option , theme , renderer , sx , onEvents , _instance , onChartInitialized }) {
35
+ const initialOption = useRef(option);
36
+ const prevOption = useRef(option);
37
+ const containerRef = useRef(null);
38
+ const chartElement = useRef(null);
39
+ // Initialize chart, dispose on unmount
40
+ useLayoutEffect(()=>{
41
+ if (containerRef.current === null || chartElement.current !== null) return;
42
+ chartElement.current = init(containerRef.current, theme, {
43
+ renderer: renderer !== null && renderer !== void 0 ? renderer : 'canvas'
44
+ });
45
+ chartElement.current.setOption(initialOption.current, true);
46
+ onChartInitialized === null || onChartInitialized === void 0 ? void 0 : onChartInitialized(chartElement.current);
47
+ if (_instance !== undefined) {
48
+ _instance.current = chartElement.current;
49
+ }
50
+ return ()=>{
51
+ if (chartElement.current === null) return;
52
+ chartElement.current.dispose();
53
+ chartElement.current = null;
54
+ };
55
+ }, [
56
+ _instance,
57
+ onChartInitialized,
58
+ theme,
59
+ renderer
60
+ ]);
61
+ // Update chart data when option changes
62
+ useEffect(()=>{
63
+ if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;
64
+ if (chartElement.current === null) return;
65
+ chartElement.current.setOption(option, true);
66
+ prevOption.current = option;
67
+ }, [
68
+ option
69
+ ]);
70
+ // Resize chart, cleanup listener on unmount
71
+ useLayoutEffect(()=>{
72
+ const updateSize = debounce(()=>{
73
+ if (chartElement.current === null) return;
74
+ chartElement.current.resize();
75
+ }, 200);
76
+ window.addEventListener('resize', updateSize);
77
+ updateSize();
78
+ return ()=>{
79
+ window.removeEventListener('resize', updateSize);
80
+ };
81
+ }, []);
82
+ // Bind and unbind chart events passed as prop
83
+ useEffect(()=>{
84
+ const chart = chartElement.current;
85
+ if (chart === null || onEvents === undefined) return;
86
+ bindEvents(chart, onEvents);
87
+ return ()=>{
88
+ if (chart === undefined) return;
89
+ if (chart.isDisposed() === true) return;
90
+ for(const event in onEvents){
91
+ chart.off(event);
92
+ }
93
+ };
94
+ }, [
95
+ onEvents
96
+ ]);
97
+ useEffect(()=>{
98
+ const updateSize = debounce(()=>{
99
+ if (chartElement.current === null) return;
100
+ chartElement.current.resize();
101
+ }, 200);
102
+ updateSize();
103
+ }, [
104
+ sx
105
+ ]);
106
+ return /*#__PURE__*/ _jsx(Box, {
107
+ ref: containerRef,
108
+ sx: sx
109
+ });
110
+ });
111
+ // Validate event config and bind custom events
112
+ function bindEvents(instance, events) {
113
+ if (events === undefined) return;
114
+ function bindEvent(eventName, OnEventFunction) {
115
+ if (typeof OnEventFunction === 'function') {
116
+ if (isMouseEvent(eventName)) {
117
+ instance.on(eventName, (params)=>OnEventFunction(params, instance));
118
+ } else if (isBatchEvent(eventName)) {
119
+ instance.on(eventName, (params)=>OnEventFunction(params));
120
+ } else {
121
+ instance.on(eventName, ()=>OnEventFunction(null, instance));
122
+ }
123
+ }
124
+ }
125
+ for(const eventName in events){
126
+ if (Object.prototype.hasOwnProperty.call(events, eventName)) {
127
+ var _eventName;
128
+ const customEvent = (_eventName = events[eventName]) !== null && _eventName !== void 0 ? _eventName : null;
129
+ if (customEvent) {
130
+ bindEvent(eventName, customEvent);
131
+ }
132
+ }
133
+ }
134
+ }
135
+ function isMouseEvent(eventName) {
136
+ return mouseEvents.includes(eventName);
137
+ }
138
+ function isBatchEvent(eventName) {
139
+ return batchEvents.includes(eventName);
140
+ }
141
+
142
+ //# sourceMappingURL=EChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/EChart.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useEffect, useLayoutEffect, useRef } from 'react';\nimport { ECharts, EChartsCoreOption, init } from 'echarts/core';\nimport { Box, SxProps, Theme } from '@mui/material';\nimport { isEqual, debounce } from 'lodash-es';\nimport { EChartsTheme } from './model';\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = typeof mouseEvents[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = typeof batchEvents[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = React.memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n onEvents,\n _instance,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (_instance !== undefined) {\n _instance.current = chartElement.current;\n }\n return () => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [_instance, onChartInitialized, theme, renderer]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (chartElement.current === null) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Resize chart, cleanup listener on unmount\n useLayoutEffect(() => {\n const updateSize = debounce(() => {\n if (chartElement.current === null) return;\n chartElement.current.resize();\n }, 200);\n window.addEventListener('resize', updateSize);\n updateSize();\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (chart === null || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return () => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n useEffect(() => {\n const updateSize = debounce(() => {\n if (chartElement.current === null) return;\n chartElement.current.resize();\n }, 200);\n updateSize();\n }, [sx]);\n\n return <Box ref={containerRef} sx={sx}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>) {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown) {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["React","useEffect","useLayoutEffect","useRef","init","Box","isEqual","debounce","mouseEvents","batchEvents","EChart","memo","option","theme","renderer","sx","onEvents","_instance","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","setOption","undefined","dispose","updateSize","resize","window","addEventListener","removeEventListener","chart","bindEvents","isDisposed","event","off","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,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wB,EAAE;QACjE,IAAI,OAAOA,eAAe,KAAK,UAAU,EAAE;YACzC,IAAIC,YAAY,CAACF,SAAS,CAAC,EAAE;gBAC3BH,QAAQ,CAACM,EAAE,CAACH,SAAS,EAAE,CAACI,MAAM,GAAKH,eAAe,CAACG,MAAM,EAAEP,QAAQ,CAAC,CAAC,CAAC;YACxE,OAAO,IAAIQ,YAAY,CAACL,SAAS,CAAC,EAAE;gBAClCH,QAAQ,CAACM,EAAE,CAACH,SAAS,EAAE,CAACI,MAAM,GAAKH,eAAe,CAACG,MAAM,CAAC,CAAC,CAAC;YAC9D,OAAO;gBACLP,QAAQ,CAACM,EAAE,CAACH,SAAS,EAAE,IAAMC,eAAe,CAAC,IAAI,EAAEJ,QAAQ,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAK,MAAMG,SAAS,IAAIF,MAAM,CAAE;QAC9B,IAAIQ,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,MAAM,EAAEE,SAAS,CAAC,EAAE;gBACvCF,UAA8B;YAAlD,MAAMY,WAAW,GAAGZ,CAAAA,UAA8B,GAA9BA,MAAM,CAACE,SAAS,CAAc,cAA9BF,UAA8B,cAA9BA,UAA8B,GAAI,IAAI,AAAC;YAC3D,IAAIY,WAAW,EAAE;gBACfX,SAAS,CAACC,SAAS,EAAeU,WAAW,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAASR,YAAY,CAACF,SAAoB,EAA+B;IACvE,OAAO,AAACjC,WAAW,CAAuB4C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC;AAED,SAASK,YAAY,CAACL,SAAoB,EAA+B;IACvE,OAAO,AAAChC,WAAW,CAAuB2C,QAAQ,CAACX,SAAS,CAAC,CAAC;AAChE,CAAC"}
@@ -1 +1,25 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{Alert}from"@mui/material";export function ErrorAlert(r){const{error:e}=r;return _jsx(Alert,{severity:"error",children:e.message})}
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Alert } from '@mui/material';
15
+ /**
16
+ * Shows an MUI Alert with the `Error.message` as its contents.
17
+ */ export function ErrorAlert(props) {
18
+ const { error } = props;
19
+ return /*#__PURE__*/ _jsx(Alert, {
20
+ severity: "error",
21
+ children: error.message
22
+ });
23
+ }
24
+
25
+ //# sourceMappingURL=ErrorAlert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ErrorAlert.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Alert } from '@mui/material';\n\nexport interface ErrorAlertProps {\n error: Error;\n}\n\n/**\n * Shows an MUI Alert with the `Error.message` as its contents.\n */\nexport function ErrorAlert(props: ErrorAlertProps) {\n const { error } = props;\n return <Alert severity=\"error\">{error.message}</Alert>;\n}\n"],"names":["Alert","ErrorAlert","props","error","severity","message"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,KAAK,QAAQ,eAAe,CAAC;AAMtC;;CAEC,GACD,OAAO,SAASC,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGD,KAAK,AAAC;IACxB,qBAAO,KAACF,KAAK;QAACI,QAAQ,EAAC,OAAO;kBAAED,KAAK,CAACE,OAAO;MAAS,CAAC;AACzD,CAAC"}
@@ -1 +1,16 @@
1
- export{ErrorBoundary}from"react-error-boundary";
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ // Just use react-error-boundary as-is for now
14
+ export { ErrorBoundary } from 'react-error-boundary';
15
+
16
+ //# sourceMappingURL=ErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ErrorBoundary.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Just use react-error-boundary as-is for now\nexport { ErrorBoundary } from 'react-error-boundary';\nexport type { ErrorBoundaryProps } from 'react-error-boundary';\n"],"names":["ErrorBoundary"],"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,8CAA8C;AAC9C,SAASA,aAAa,QAAQ,sBAAsB,CAAC"}
@@ -1 +1,172 @@
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})}
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { useMemo } from 'react';
15
+ import { use } from 'echarts/core';
16
+ import { GaugeChart as EChartsGaugeChart } from 'echarts/charts';
17
+ import { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';
18
+ import { CanvasRenderer } from 'echarts/renderers';
19
+ import { useChartsTheme } from '../context/ChartsThemeProvider';
20
+ import { formatValue } from '../model/units';
21
+ import { EChart } from '../EChart';
22
+ use([
23
+ EChartsGaugeChart,
24
+ GridComponent,
25
+ TitleComponent,
26
+ TooltipComponent,
27
+ CanvasRenderer
28
+ ]);
29
+ export function GaugeChart(props) {
30
+ const { width , height , data , unit , axisLine , max } = props;
31
+ const chartsTheme = useChartsTheme();
32
+ const option = useMemo(()=>{
33
+ if (data === null || data === undefined) return chartsTheme.noDataOption;
34
+ const calculatedValue = data;
35
+ return {
36
+ title: {
37
+ show: false
38
+ },
39
+ tooltip: {
40
+ show: false
41
+ },
42
+ series: [
43
+ {
44
+ type: 'gauge',
45
+ center: [
46
+ '50%',
47
+ '65%'
48
+ ],
49
+ radius: '100%',
50
+ startAngle: 200,
51
+ endAngle: -20,
52
+ min: 0,
53
+ max,
54
+ silent: true,
55
+ progress: {
56
+ show: true,
57
+ width: 22,
58
+ itemStyle: {
59
+ color: 'auto'
60
+ }
61
+ },
62
+ pointer: {
63
+ show: false
64
+ },
65
+ axisLine: {
66
+ lineStyle: {
67
+ color: [
68
+ [
69
+ 1,
70
+ '#e1e5e9'
71
+ ]
72
+ ],
73
+ width: 22
74
+ }
75
+ },
76
+ axisTick: {
77
+ show: false,
78
+ distance: 0
79
+ },
80
+ splitLine: {
81
+ show: true
82
+ },
83
+ axisLabel: {
84
+ show: false,
85
+ distance: -18,
86
+ color: '#999',
87
+ fontSize: 12
88
+ },
89
+ anchor: {
90
+ show: false
91
+ },
92
+ title: {
93
+ show: false
94
+ },
95
+ detail: {
96
+ show: false
97
+ },
98
+ data: [
99
+ {
100
+ value: calculatedValue
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ type: 'gauge',
106
+ center: [
107
+ '50%',
108
+ '65%'
109
+ ],
110
+ radius: '114%',
111
+ startAngle: 200,
112
+ endAngle: -20,
113
+ min: 0,
114
+ max,
115
+ pointer: {
116
+ show: false,
117
+ itemStyle: {
118
+ color: 'auto'
119
+ }
120
+ },
121
+ axisLine,
122
+ axisTick: {
123
+ show: false
124
+ },
125
+ splitLine: {
126
+ show: false
127
+ },
128
+ axisLabel: {
129
+ show: false
130
+ },
131
+ detail: {
132
+ show: true,
133
+ width: '60%',
134
+ borderRadius: 8,
135
+ offsetCenter: [
136
+ 0,
137
+ '-9%'
138
+ ],
139
+ color: 'inherit',
140
+ formatter: (value)=>{
141
+ return formatValue(value, {
142
+ kind: unit.kind,
143
+ decimal_places: 0
144
+ });
145
+ }
146
+ },
147
+ data: [
148
+ {
149
+ value: calculatedValue
150
+ }
151
+ ]
152
+ }
153
+ ]
154
+ };
155
+ }, [
156
+ data,
157
+ chartsTheme,
158
+ unit,
159
+ axisLine,
160
+ max
161
+ ]);
162
+ return /*#__PURE__*/ _jsx(EChart, {
163
+ sx: {
164
+ width: width,
165
+ height: height
166
+ },
167
+ option: option,
168
+ theme: chartsTheme.themeName
169
+ });
170
+ }
171
+
172
+ //# sourceMappingURL=GaugeChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/GaugeChart/GaugeChart.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo } from 'react';\nimport { use, EChartsCoreOption } from 'echarts/core';\nimport { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts';\nimport { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { useChartsTheme } from '../context/ChartsThemeProvider';\nimport { formatValue, UnitOptions } from '../model/units';\nimport { EChart } from '../EChart';\n\nuse([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]);\n\nexport type GaugeChartData = number | null | undefined;\n\ninterface GaugeChartProps {\n width: number;\n height: number;\n data: GaugeChartData;\n unit: UnitOptions;\n axisLine: GaugeSeriesOption['axisLine'];\n max?: number;\n}\n\nexport function GaugeChart(props: GaugeChartProps) {\n const { width, height, data, unit, axisLine, max } = props;\n\n const chartsTheme = useChartsTheme();\n\n const option: EChartsCoreOption = useMemo(() => {\n if (data === null || data === undefined) return chartsTheme.noDataOption;\n\n const calculatedValue = data;\n return {\n title: {\n show: false,\n },\n tooltip: {\n show: false,\n },\n series: [\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '100%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n silent: true,\n progress: {\n show: true,\n width: 22,\n itemStyle: {\n color: 'auto',\n },\n },\n pointer: {\n show: false,\n },\n axisLine: {\n lineStyle: {\n color: [[1, '#e1e5e9']], // TODO (sjcobb): use future chart theme colors\n width: 22,\n },\n },\n axisTick: {\n show: false,\n distance: 0,\n },\n splitLine: {\n show: true,\n },\n axisLabel: {\n show: false,\n distance: -18,\n color: '#999',\n fontSize: 12,\n },\n anchor: {\n show: false,\n },\n title: {\n show: false,\n },\n detail: {\n show: false,\n },\n data: [\n {\n value: calculatedValue,\n },\n ],\n },\n {\n type: 'gauge',\n center: ['50%', '65%'],\n radius: '114%',\n startAngle: 200,\n endAngle: -20,\n min: 0,\n max,\n pointer: {\n show: false,\n itemStyle: {\n color: 'auto',\n },\n },\n axisLine,\n axisTick: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n show: false,\n },\n detail: {\n show: true,\n width: '60%',\n borderRadius: 8,\n offsetCenter: [0, '-9%'],\n color: 'inherit',\n formatter: (value: number) => {\n return formatValue(value, {\n kind: unit.kind,\n decimal_places: 0,\n });\n },\n },\n data: [\n {\n value: calculatedValue,\n },\n ],\n },\n ],\n };\n }, [data, chartsTheme, unit, axisLine, max]);\n\n return (\n <EChart\n sx={{\n width: width,\n height: height,\n }}\n option={option}\n theme={chartsTheme.themeName}\n />\n );\n}\n"],"names":["useMemo","use","GaugeChart","EChartsGaugeChart","GridComponent","TitleComponent","TooltipComponent","CanvasRenderer","useChartsTheme","formatValue","EChart","props","width","height","data","unit","axisLine","max","chartsTheme","option","undefined","noDataOption","calculatedValue","title","show","tooltip","series","type","center","radius","startAngle","endAngle","min","silent","progress","itemStyle","color","pointer","lineStyle","axisTick","distance","splitLine","axisLabel","fontSize","anchor","detail","value","borderRadius","offsetCenter","formatter","kind","decimal_places","sx","theme","themeName"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,GAAG,QAA2B,cAAc,CAAC;AACtD,SAASC,UAAU,IAAIC,iBAAiB,QAA2B,gBAAgB,CAAC;AACpF,SAASC,aAAa,EAAEC,cAAc,E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ACVZ,KAAK,EAAE,KAAK;wBACZmC,YAAY,EAAE,CAAC;wBACfC,YAAY,EAAE;AAAC,6BAAC;4BAAE,KAAK;yBAAC;wBACxBZ,KAAK,EAAE,SAAS;wBAChBa,SAAS,EAAE,CAACH,KAAa,GAAK;4BAC5B,OAAOrC,WAAW,CAACqC,KAAK,EAAE;gCACxBI,IAAI,EAAEnC,IAAI,CAACmC,IAAI;gCACfC,cAAc,EAAE,CAAC;6BAClB,CAAC,CAAC;wBACL,CAAC;qBACF;oBACDrC,IAAI,EAAE;wBACJ;4BACEgC,KAAK,EAAExB,eAAe;yBACvB;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC,EAAE;QAACR,IAAI;QAAEI,WAAW;QAAEH,IAAI;QAAEC,QAAQ;QAAEC,GAAG;KAAC,CAAC,AAAC;IAE7C,qBACE,KAACP,MAAM;QACL0C,EAAE,EAAE;YACFxC,KAAK,EAAEA,KAAK;YACZC,MAAM,EAAEA,MAAM;SACf;QACDM,MAAM,EAAEA,MAAM;QACdkC,KAAK,EAAEnC,WAAW,CAACoC,SAAS;MAC5B,CACF;AACJ,CAAC"}
@@ -1 +1,15 @@
1
- export*from"./GaugeChart";
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './GaugeChart';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/GaugeChart/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './GaugeChart';\n"],"names":[],"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,cAAc,cAAc,CAAC"}
@@ -1 +1,79 @@
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}}})));
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
+ import React from 'react';
15
+ import { styled, Tooltip as MuiTooltip, tooltipClasses, Typography } from '@mui/material';
16
+ export var TooltipPlacement;
17
+ (function(TooltipPlacement) {
18
+ TooltipPlacement["Top"] = 'top';
19
+ TooltipPlacement["Left"] = 'left';
20
+ TooltipPlacement["Right"] = 'right';
21
+ TooltipPlacement["Bottom"] = 'bottom';
22
+ })(TooltipPlacement || (TooltipPlacement = {}));
23
+ export const InfoTooltip = ({ id , title , description , placement , children })=>{
24
+ return /*#__PURE__*/ _jsx(StyledTooltip, {
25
+ arrow: true,
26
+ id: id,
27
+ placement: placement,
28
+ title: /*#__PURE__*/ _jsx(TooltipContent, {
29
+ title: title,
30
+ description: description
31
+ }),
32
+ children: /*#__PURE__*/ _jsx("div", {
33
+ children: children
34
+ })
35
+ });
36
+ };
37
+ const TooltipContent = ({ title , description })=>{
38
+ return /*#__PURE__*/ _jsxs(_Fragment, {
39
+ children: [
40
+ title && /*#__PURE__*/ _jsx(Typography, {
41
+ variant: "body2",
42
+ sx: (theme)=>({
43
+ color: theme.palette.text.primary,
44
+ fontWeight: theme.typography.fontWeightMedium
45
+ }),
46
+ children: title
47
+ }),
48
+ /*#__PURE__*/ _jsx(Typography, {
49
+ variant: "caption",
50
+ sx: (theme)=>({
51
+ color: theme.palette.text.primary
52
+ }),
53
+ children: description
54
+ })
55
+ ]
56
+ });
57
+ };
58
+ const StyledTooltip = styled(({ className , ...props })=>/*#__PURE__*/ _jsx(MuiTooltip, {
59
+ ...props,
60
+ classes: {
61
+ popper: className
62
+ }
63
+ }))(({ theme })=>({
64
+ [`& .${tooltipClasses.tooltip}`]: {
65
+ backgroundColor: theme.palette.secondary.main,
66
+ color: theme.palette.grey[900],
67
+ maxWidth: '300px',
68
+ padding: theme.spacing(1),
69
+ boxShadow: theme.shadows[1]
70
+ },
71
+ [`& .${tooltipClasses.arrow}`]: {
72
+ color: theme.palette.background.paper,
73
+ '&::before': {
74
+ backgroundColor: theme.palette.secondary.main
75
+ }
76
+ }
77
+ }));
78
+
79
+ //# sourceMappingURL=InfoTooltip.js.map