@perses-dev/components 0.12.0 → 0.14.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 (72) hide show
  1. package/dist/Drawer/Drawer.d.ts.map +1 -1
  2. package/dist/Drawer/Drawer.js +0 -1
  3. package/dist/Drawer/Drawer.js.map +1 -1
  4. package/dist/EChart.d.ts.map +1 -1
  5. package/dist/EChart.js +5 -4
  6. package/dist/EChart.js.map +1 -1
  7. package/dist/GaugeChart/GaugeChart.js +3 -3
  8. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  9. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  10. package/dist/Legend/ListLegendItem.js +1 -0
  11. package/dist/Legend/ListLegendItem.js.map +1 -1
  12. package/dist/LineChart/LineChart.js +1 -1
  13. package/dist/LineChart/LineChart.js.map +1 -1
  14. package/dist/StatChart/StatChart.js +1 -1
  15. package/dist/StatChart/StatChart.js.map +1 -1
  16. package/dist/StatChart/StatChart.test.js +1 -2
  17. package/dist/StatChart/StatChart.test.js.map +1 -1
  18. package/dist/cjs/Drawer/Drawer.js +0 -1
  19. package/dist/cjs/EChart.js +5 -4
  20. package/dist/cjs/GaugeChart/GaugeChart.js +3 -3
  21. package/dist/cjs/Legend/ListLegendItem.js +1 -0
  22. package/dist/cjs/LineChart/LineChart.js +1 -1
  23. package/dist/cjs/StatChart/StatChart.js +1 -1
  24. package/dist/cjs/StatChart/StatChart.test.js +2 -3
  25. package/dist/cjs/context/ChartsThemeProvider.js +1 -6
  26. package/dist/cjs/index.js +1 -1
  27. package/dist/cjs/model/units.js +1 -1
  28. package/dist/cjs/test/index.js +0 -1
  29. package/dist/cjs/test-utils/index.js +28 -0
  30. package/dist/cjs/{test → test-utils}/theme.js +0 -1
  31. package/dist/cjs/utils/mathjs.js +25 -0
  32. package/dist/cjs/utils/theme-gen.js +1 -2
  33. package/dist/cjs/utils/theme-gen.test.js +1 -2
  34. package/dist/context/ChartsThemeProvider.d.ts +0 -1
  35. package/dist/context/ChartsThemeProvider.d.ts.map +1 -1
  36. package/dist/context/ChartsThemeProvider.js +1 -6
  37. package/dist/context/ChartsThemeProvider.js.map +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/model/theme.d.ts +0 -1
  43. package/dist/model/theme.d.ts.map +1 -1
  44. package/dist/model/theme.js.map +1 -1
  45. package/dist/model/units.js +1 -1
  46. package/dist/model/units.js.map +1 -1
  47. package/dist/test/index.d.ts +0 -1
  48. package/dist/test/index.d.ts.map +1 -1
  49. package/dist/test/index.js +0 -1
  50. package/dist/test/index.js.map +1 -1
  51. package/dist/test-utils/index.d.ts +2 -0
  52. package/dist/test-utils/index.d.ts.map +1 -0
  53. package/dist/test-utils/index.js +15 -0
  54. package/dist/test-utils/index.js.map +1 -0
  55. package/dist/test-utils/theme.d.ts +3 -0
  56. package/dist/test-utils/theme.d.ts.map +1 -0
  57. package/dist/{test → test-utils}/theme.js +0 -1
  58. package/dist/test-utils/theme.js.map +1 -0
  59. package/dist/utils/mathjs.d.ts +6 -0
  60. package/dist/utils/mathjs.d.ts.map +1 -0
  61. package/dist/utils/mathjs.js +20 -0
  62. package/dist/utils/mathjs.js.map +1 -0
  63. package/dist/utils/theme-gen.d.ts +1 -1
  64. package/dist/utils/theme-gen.d.ts.map +1 -1
  65. package/dist/utils/theme-gen.js +1 -2
  66. package/dist/utils/theme-gen.js.map +1 -1
  67. package/dist/utils/theme-gen.test.js +1 -2
  68. package/dist/utils/theme-gen.test.js.map +1 -1
  69. package/package.json +7 -2
  70. package/dist/test/theme.d.ts +0 -3
  71. package/dist/test/theme.d.ts.map +0 -1
  72. package/dist/test/theme.js.map +0 -1
@@ -27,7 +27,7 @@ _export(exports, {
27
27
  formatNumber: ()=>formatNumber
28
28
  });
29
29
  const _dateFns = require("date-fns");
30
- const _mathjs = require("mathjs");
30
+ const _mathjs = require("../utils/mathjs");
31
31
  const DEFAULT_DECIMAL_PLACES = 2;
32
32
  function formatValue(value, unitOptions) {
33
33
  if (unitOptions === undefined) {
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _exportStar(require("./render"), exports);
18
- _exportStar(require("./theme"), exports);
19
18
  function _exportStar(from, to) {
20
19
  Object.keys(from).forEach(function(k) {
21
20
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -0,0 +1,28 @@
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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./theme"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -19,7 +19,6 @@ Object.defineProperty(exports, "testChartsTheme", {
19
19
  get: ()=>testChartsTheme
20
20
  });
21
21
  const testChartsTheme = {
22
- themeName: 'perses',
23
22
  echartsTheme: {},
24
23
  noDataOption: {},
25
24
  sparkline: {
@@ -0,0 +1,25 @@
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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "round", {
18
+ enumerable: true,
19
+ get: ()=>round
20
+ });
21
+ const _mathjs = require("mathjs");
22
+ // This ensures we get a minimal mathjs bundle for just what we need (see https://mathjs.org/docs/custom_bundling.html)
23
+ const { round } = (0, _mathjs.create)({
24
+ roundDependencies: _mathjs.roundDependencies
25
+ });
@@ -20,7 +20,7 @@ Object.defineProperty(exports, "generateChartsTheme", {
20
20
  });
21
21
  const _lodashEs = require("lodash-es");
22
22
  const DEFAULT_TEXT_COLOR = '#222';
23
- function generateChartsTheme(themeName, muiTheme, echartsTheme) {
23
+ function generateChartsTheme(muiTheme, echartsTheme) {
24
24
  var ref, ref1, ref2, ref3, ref4;
25
25
  var ref5;
26
26
  const primaryTextColor = (ref5 = (ref = muiTheme.palette.text) === null || ref === void 0 ? void 0 : ref.primary) !== null && ref5 !== void 0 ? ref5 : DEFAULT_TEXT_COLOR;
@@ -160,7 +160,6 @@ function generateChartsTheme(themeName, muiTheme, echartsTheme) {
160
160
  }
161
161
  };
162
162
  return {
163
- themeName,
164
163
  echartsTheme: (0, _lodashEs.merge)(muiConvertedTheme, echartsTheme),
165
164
  noDataOption: {
166
165
  title: {
@@ -29,7 +29,7 @@ describe('generateChartsTheme', ()=>{
29
29
  smooth: true
30
30
  }
31
31
  };
32
- const chartsTheme = (0, _themeGen.generateChartsTheme)('perses', muiTheme, echartsThemeOverrides);
32
+ const chartsTheme = (0, _themeGen.generateChartsTheme)(muiTheme, echartsThemeOverrides);
33
33
  it('should return perses specific charts theme from converted MUI theme', ()=>{
34
34
  expect(chartsTheme).toMatchInlineSnapshot(`
35
35
  Object {
@@ -191,7 +191,6 @@ describe('generateChartsTheme', ()=>{
191
191
  "color": "#1976d2",
192
192
  "width": 2,
193
193
  },
194
- "themeName": "perses",
195
194
  }
196
195
  `);
197
196
  });
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { PersesChartsTheme } from '../model';
3
3
  export interface ChartsThemeProviderProps {
4
- themeName: string;
5
4
  chartsTheme?: PersesChartsTheme;
6
5
  children?: React.ReactNode;
7
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ChartsThemeProvider.d.ts","sourceRoot":"","sources":["../../src/context/ChartsThemeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eASlE;AAED,eAAO,MAAM,kBAAkB,8CAA0D,CAAC;AAE1F,wBAAgB,cAAc,IAAI,iBAAiB,CAMlD"}
1
+ {"version":3,"file":"ChartsThemeProvider.d.ts","sourceRoot":"","sources":["../../src/context/ChartsThemeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,wBAAwB;IACvC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAGlE;AAED,eAAO,MAAM,kBAAkB,8CAA0D,CAAC;AAE1F,wBAAgB,cAAc,IAAI,iBAAiB,CAMlD"}
@@ -12,13 +12,8 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import React, { createContext, useContext } from 'react';
15
- import { registerTheme } from 'echarts';
16
15
  export function ChartsThemeProvider(props) {
17
- const { children , themeName , chartsTheme } = props;
18
- if (chartsTheme !== undefined && chartsTheme.echartsTheme !== undefined) {
19
- // register ECharts theme to be used in individual charts, see: https://apache.github.io/echarts-handbook/en/concepts/style/#theme
20
- registerTheme(themeName, chartsTheme.echartsTheme);
21
- }
16
+ const { children , chartsTheme } = props;
22
17
  return /*#__PURE__*/ _jsx(ChartsThemeContext.Provider, {
23
18
  value: chartsTheme,
24
19
  children: children
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/ChartsThemeProvider.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, { createContext, useContext } from 'react';\nimport { registerTheme } from 'echarts';\nimport { PersesChartsTheme } from '../model';\n\nexport interface ChartsThemeProviderProps {\n themeName: string;\n chartsTheme?: PersesChartsTheme;\n children?: React.ReactNode;\n}\n\nexport function ChartsThemeProvider(props: ChartsThemeProviderProps) {\n const { children, themeName, chartsTheme } = props;\n\n if (chartsTheme !== undefined && chartsTheme.echartsTheme !== undefined) {\n // register ECharts theme to be used in individual charts, see: https://apache.github.io/echarts-handbook/en/concepts/style/#theme\n registerTheme(themeName, chartsTheme.echartsTheme);\n }\n\n return <ChartsThemeContext.Provider value={chartsTheme}>{children}</ChartsThemeContext.Provider>;\n}\n\nexport const ChartsThemeContext = createContext<PersesChartsTheme | undefined>(undefined);\n\nexport function useChartsTheme(): PersesChartsTheme {\n const ctx = useContext(ChartsThemeContext);\n if (ctx === undefined) {\n throw new Error('No ChartsThemeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n"],"names":["React","createContext","useContext","registerTheme","ChartsThemeProvider","props","children","themeName","chartsTheme","undefined","echartsTheme","ChartsThemeContext","Provider","value","useChartsTheme","ctx","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AACzD,SAASC,aAAa,QAAQ,SAAS,CAAC;AASxC,OAAO,SAASC,mBAAmB,CAACC,KAA+B,EAAE;IACnE,MAAM,EAAEC,QAAQ,CAAA,EAAEC,SAAS,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAGH,KAAK,AAAC;IAEnD,IAAIG,WAAW,KAAKC,SAAS,IAAID,WAAW,CAACE,YAAY,KAAKD,SAAS,EAAE;QACvE,kIAAkI;QAClIN,aAAa,CAACI,SAAS,EAAEC,WAAW,CAACE,YAAY,CAAC,CAAC;IACrD,CAAC;IAED,qBAAO,KAACC,kBAAkB,CAACC,QAAQ;QAACC,KAAK,EAAEL,WAAW;kBAAGF,QAAQ;MAA+B,CAAC;AACnG,CAAC;AAED,OAAO,MAAMK,kBAAkB,iBAAGV,aAAa,CAAgCQ,SAAS,CAAC,CAAC;AAE1F,OAAO,SAASK,cAAc,GAAsB;IAClD,MAAMC,GAAG,GAAGb,UAAU,CAACS,kBAAkB,CAAC,AAAC;IAC3C,IAAII,GAAG,KAAKN,SAAS,EAAE;QACrB,MAAM,IAAIO,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC"}
1
+ {"version":3,"sources":["../../src/context/ChartsThemeProvider.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, { createContext, useContext } from 'react';\nimport { PersesChartsTheme } from '../model';\n\nexport interface ChartsThemeProviderProps {\n chartsTheme?: PersesChartsTheme;\n children?: React.ReactNode;\n}\n\nexport function ChartsThemeProvider(props: ChartsThemeProviderProps) {\n const { children, chartsTheme } = props;\n return <ChartsThemeContext.Provider value={chartsTheme}>{children}</ChartsThemeContext.Provider>;\n}\n\nexport const ChartsThemeContext = createContext<PersesChartsTheme | undefined>(undefined);\n\nexport function useChartsTheme(): PersesChartsTheme {\n const ctx = useContext(ChartsThemeContext);\n if (ctx === undefined) {\n throw new Error('No ChartsThemeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n"],"names":["React","createContext","useContext","ChartsThemeProvider","props","children","chartsTheme","ChartsThemeContext","Provider","value","undefined","useChartsTheme","ctx","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAQzD,OAAO,SAASC,mBAAmB,CAACC,KAA+B,EAAE;IACnE,MAAM,EAAEC,QAAQ,CAAA,EAAEC,WAAW,CAAA,EAAE,GAAGF,KAAK,AAAC;IACxC,qBAAO,KAACG,kBAAkB,CAACC,QAAQ;QAACC,KAAK,EAAEH,WAAW;kBAAGD,QAAQ;MAA+B,CAAC;AACnG,CAAC;AAED,OAAO,MAAME,kBAAkB,iBAAGN,aAAa,CAAgCS,SAAS,CAAC,CAAC;AAE1F,OAAO,SAASC,cAAc,GAAsB;IAClD,MAAMC,GAAG,GAAGV,UAAU,CAACK,kBAAkB,CAAC,AAAC;IAC3C,IAAIK,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -12,5 +12,5 @@ export * from './TimeRangeSelector';
12
12
  export * from './context/ChartsThemeProvider';
13
13
  export * from './utils';
14
14
  export * from './model';
15
- export * from './test';
15
+ export * from './test-utils';
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -24,6 +24,6 @@ export * from './TimeRangeSelector';
24
24
  export * from './context/ChartsThemeProvider';
25
25
  export * from './utils';
26
26
  export * from './model';
27
- export * from './test';
27
+ export * from './test-utils';
28
28
 
29
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/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';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './GaugeChart';\nexport * from './StatChart';\nexport * from './TimeRangeSelector';\nexport * from './context/ChartsThemeProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test';\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;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"sources":["../src/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';\nexport * from './EChart';\nexport * from './ErrorAlert';\nexport * from './ErrorBoundary';\nexport * from './InfoTooltip';\nexport * from './JSONEditor';\nexport * from './Legend';\nexport * from './LineChart';\nexport * from './GaugeChart';\nexport * from './StatChart';\nexport * from './TimeRangeSelector';\nexport * from './context/ChartsThemeProvider';\nexport * from './utils';\nexport * from './model';\nexport * from './test-utils';\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;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import type { EChartsOption, EChartsCoreOption, BarSeriesOption, LineSeriesOption, GaugeSeriesOption } from 'echarts';
2
2
  export interface PersesChartsTheme {
3
- themeName: string;
4
3
  echartsTheme: EChartsTheme;
5
4
  noDataOption: EChartsCoreOption;
6
5
  sparkline: {
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEtH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,iBAAiB,CAAC;IAChC,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAGD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/model/theme.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEtH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,iBAAiB,CAAC;IAChC,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAGD,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/theme.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { EChartsOption, EChartsCoreOption, BarSeriesOption, LineSeriesOption, GaugeSeriesOption } from 'echarts';\n\nexport interface PersesChartsTheme {\n themeName: string;\n echartsTheme: EChartsTheme;\n noDataOption: EChartsCoreOption;\n sparkline: {\n width: number;\n color: string;\n };\n}\n\n// https://github.com/apache/echarts/issues/12489#issuecomment-643185207\nexport interface EChartsTheme extends EChartsOption {\n bar?: BarSeriesOption;\n line?: LineSeriesOption;\n gauge?: GaugeSeriesOption;\n}\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,WAiBC"}
1
+ {"version":3,"sources":["../../src/model/theme.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { EChartsOption, EChartsCoreOption, BarSeriesOption, LineSeriesOption, GaugeSeriesOption } from 'echarts';\n\nexport interface PersesChartsTheme {\n echartsTheme: EChartsTheme;\n noDataOption: EChartsCoreOption;\n sparkline: {\n width: number;\n color: string;\n };\n}\n\n// https://github.com/apache/echarts/issues/12489#issuecomment-643185207\nexport interface EChartsTheme extends EChartsOption {\n bar?: BarSeriesOption;\n line?: LineSeriesOption;\n gauge?: GaugeSeriesOption;\n}\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,WAgBC"}
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { milliseconds } from 'date-fns';
14
- import { round } from 'mathjs';
14
+ import { round } from '../utils/mathjs';
15
15
  export const DEFAULT_DECIMAL_PLACES = 2;
16
16
  export function formatValue(value, unitOptions) {
17
17
  if (unitOptions === undefined) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/units.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Duration, milliseconds } from 'date-fns';\nimport { round } from 'mathjs';\n\nexport const DEFAULT_DECIMAL_PLACES = 2;\n\nexport type UnitOptions = TimeUnitOptions | PercentUnitOptions | DecimalUnitOptions | BytesUnitOptions;\n\nexport function formatValue(value: number, unitOptions?: UnitOptions): string {\n if (unitOptions === undefined) {\n return value.toString();\n }\n\n if (isDecimalUnit(unitOptions)) {\n return formatDecimal(value, unitOptions);\n }\n\n if (isTimeUnit(unitOptions)) {\n return formatTime(value, unitOptions);\n }\n\n if (isPercentUnit(unitOptions)) {\n return formatPercent(value, unitOptions);\n }\n\n if (isBytesUnit(unitOptions)) {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n return formatBytes(value, decimals);\n }\n\n const exhaustive: never = unitOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\n/* Time Unit Conversion */\nconst timeUnitKinds = ['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Days', 'Weeks', 'Months', 'Years'] as const;\nconst timeUnitKindsSet = new Set<string>(timeUnitKinds);\n\ntype TimeUnitOptions = {\n kind: typeof timeUnitKinds[number];\n};\n\nfunction isTimeUnit(unitOptions: UnitOptions): unitOptions is TimeUnitOptions {\n return timeUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatTime(value: number, unitOptions: TimeUnitOptions): string {\n // Create a Duration from the value based on what time unit it is\n const duration: Duration = {};\n switch (unitOptions.kind) {\n case 'Milliseconds':\n duration.seconds = value / 1000;\n break;\n case 'Seconds':\n duration.seconds = value;\n break;\n case 'Minutes':\n duration.minutes = value;\n break;\n case 'Hours':\n duration.hours = value;\n break;\n case 'Days':\n duration.days = value;\n break;\n case 'Weeks':\n duration.weeks = value;\n break;\n case 'Months':\n duration.months = value;\n break;\n case 'Years':\n duration.years = value;\n break;\n default: {\n const exhaustive: never = unitOptions.kind;\n throw new Error(`Unknown time unit type ${exhaustive}`);\n }\n }\n\n // Find the largest whole time unit we can display the value in and use it\n const ms = milliseconds(duration);\n const seconds = ms / 1000;\n if (seconds < 1) {\n return `${ms.toFixed()} milliseconds`;\n }\n\n const minutes = seconds / 60;\n if (minutes < 1) {\n return `${seconds.toFixed()} seconds`;\n }\n\n const hours = minutes / 60;\n if (hours < 1) {\n return `${minutes.toFixed()} minutes`;\n }\n\n const days = hours / 24;\n if (days < 1) {\n return `${hours.toFixed()} hours`;\n }\n\n const weeks = days / 7;\n if (weeks < 1) {\n return `${days.toFixed()} days`;\n }\n\n const years = weeks / 52;\n if (years < 1) {\n return `${weeks.toFixed()} weeks`;\n }\n\n return `${years.toFixed()} years`;\n}\n\n/* Percent Unit Conversion */\nconst percentUnitKinds = ['Percent', 'PercentDecimal', '%'] as const;\nconst percentUnitKindsSet = new Set<string>(percentUnitKinds);\n\ntype PercentUnitOptions = {\n kind: typeof percentUnitKinds[number];\n decimal_places?: number;\n};\n\nfunction isPercentUnit(unitOptions: UnitOptions): unitOptions is PercentUnitOptions {\n return percentUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatPercent(value: number, unitOptions: PercentUnitOptions): string {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n\n if (unitOptions.kind === 'PercentDecimal') {\n value = value * 100;\n }\n\n return value.toFixed(decimals) + '%';\n}\n\n/* Decimal Unit Conversion */\nconst decimalUnitKinds = ['Decimal'] as const;\nconst decimalUnitKindsSet = new Set<string>(decimalUnitKinds);\n\ntype DecimalUnitOptions = {\n kind: typeof decimalUnitKinds[number];\n decimal_places?: number;\n abbreviate?: boolean;\n};\n\nfunction isDecimalUnit(unitOptions: UnitOptions): unitOptions is DecimalUnitOptions {\n return decimalUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatDecimal(value: number, unitOptions: DecimalUnitOptions): string {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n\n if (unitOptions.abbreviate === true) {\n return abbreviateLargeNumber(value, decimals);\n }\n\n const formatParams: Intl.NumberFormatOptions = {\n style: 'decimal',\n minimumFractionDigits: 0,\n maximumFractionDigits: decimals,\n useGrouping: true,\n };\n const decimalFormatter = new Intl.NumberFormat('en-US', formatParams);\n return decimalFormatter.format(value);\n}\n\n/**\n * Takes large numbers and abbreviates them with the appropriate suffix\n * 10123 -> 10.123k\n * 1000000 -> 1M\n */\nexport function abbreviateLargeNumber(num: number, decimals = 2) {\n const modifier = (n: number) => round(n, decimals);\n return formatNumber(num, modifier);\n}\n\n/**\n * Takes large numbers, rounds and abbreviates them with the appropriate suffix\n * Add modifier to run on output value prior to unit being added (defaults to rounding)\n */\nexport function formatNumber(num: number, modifier?: (n: number) => number): string {\n const fn = modifier ?? Math.round;\n\n return num >= 1e12\n ? fn(num / 1e12) + 'T'\n : num >= 1e9\n ? fn(num / 1e9) + 'B'\n : num >= 1e6\n ? fn(num / 1e6) + 'M'\n : num >= 1e3\n ? fn(num / 1e3) + 'K'\n : num.toString();\n}\n\n/* Bytes Unit Conversion */\nconst bytesUnitKinds = ['Bytes'] as const;\nconst bytesUnitKindsSet = new Set<string>(bytesUnitKinds);\n\ntype BytesUnitOptions = {\n kind: typeof bytesUnitKinds[number];\n decimal_places?: number;\n};\n\nfunction isBytesUnit(unitOptions: UnitOptions): unitOptions is BytesUnitOptions {\n return bytesUnitKindsSet.has(unitOptions.kind);\n}\n\n// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript/18650828#18650828\nfunction formatBytes(bytes: number, decimals = 2) {\n if (bytes === 0) return '0 Bytes';\n\n const k = 1024;\n const dm = decimals < 0 ? 0 : decimals;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\n // Math.max(0, ...) ensures that we don't return -1 as a value for the index.\n // Why? When the number of bytes are between -1 and 1, Math.floor(Math.log(bytes)/Math.log(1024)) returns -1.\n const i = Math.max(0, Math.floor(Math.log(bytes) / Math.log(k)));\n\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n}\n"],"names":["milliseconds","round","DEFAULT_DECIMAL_PLACES","formatValue","value","unitOptions","undefined","toString","isDecimalUnit","formatDecimal","isTimeUnit","formatTime","isPercentUnit","formatPercent","isBytesUnit","decimals","decimal_places","formatBytes","exhaustive","Error","timeUnitKinds","timeUnitKindsSet","Set","has","kind","duration","seconds","minutes","hours","days","weeks","months","years","ms","toFixed","percentUnitKinds","percentUnitKindsSet","decimalUnitKinds","decimalUnitKindsSet","abbreviate","abbreviateLargeNumber","formatParams","style","minimumFractionDigits","maximumFractionDigits","useGrouping","decimalFormatter","Intl","NumberFormat","format","num","modifier","n","formatNumber","fn","Math","bytesUnitKinds","bytesUnitKindsSet","bytes","k","dm","sizes","i","max","floor","log","parseFloat","pow"],"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,SAAmBA,YAAY,QAAQ,UAAU,CAAC;AAClD,SAASC,KAAK,QAAQ,QAAQ,CAAC;AAE/B,OAAO,MAAMC,sBAAsB,GAAG,CAAC,CAAC;AAIxC,OAAO,SAASC,WAAW,CAACC,KAAa,EAAEC,WAAyB,EAAU;IAC5E,IAAIA,WAAW,KAAKC,SAAS,EAAE;QAC7B,OAAOF,KAAK,CAACG,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAED,IAAIC,aAAa,CAACH,WAAW,CAAC,EAAE;QAC9B,OAAOI,aAAa,CAACL,KAAK,EAAEC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,IAAIK,UAAU,CAACL,WAAW,CAAC,EAAE;QAC3B,OAAOM,UAAU,CAACP,KAAK,EAAEC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED,IAAIO,aAAa,CAACP,WAAW,CAAC,EAAE;QAC9B,OAAOQ,aAAa,CAACT,KAAK,EAAE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K,GAAGH,IAAI,CAACY,GAAG,CAACR,CAAC,EAAEG,CAAC,CAAC,CAAA,CAAE5B,OAAO,CAAC0B,EAAE,CAAC,CAAC,GAAG,GAAG,GAAGC,KAAK,CAACC,CAAC,CAAC,CAAC;AAC3E,CAAC"}
1
+ {"version":3,"sources":["../../src/model/units.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Duration, milliseconds } from 'date-fns';\nimport { round } from '../utils/mathjs';\n\nexport const DEFAULT_DECIMAL_PLACES = 2;\n\nexport type UnitOptions = TimeUnitOptions | PercentUnitOptions | DecimalUnitOptions | BytesUnitOptions;\n\nexport function formatValue(value: number, unitOptions?: UnitOptions): string {\n if (unitOptions === undefined) {\n return value.toString();\n }\n\n if (isDecimalUnit(unitOptions)) {\n return formatDecimal(value, unitOptions);\n }\n\n if (isTimeUnit(unitOptions)) {\n return formatTime(value, unitOptions);\n }\n\n if (isPercentUnit(unitOptions)) {\n return formatPercent(value, unitOptions);\n }\n\n if (isBytesUnit(unitOptions)) {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n return formatBytes(value, decimals);\n }\n\n const exhaustive: never = unitOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\n/* Time Unit Conversion */\nconst timeUnitKinds = ['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Days', 'Weeks', 'Months', 'Years'] as const;\nconst timeUnitKindsSet = new Set<string>(timeUnitKinds);\n\ntype TimeUnitOptions = {\n kind: typeof timeUnitKinds[number];\n};\n\nfunction isTimeUnit(unitOptions: UnitOptions): unitOptions is TimeUnitOptions {\n return timeUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatTime(value: number, unitOptions: TimeUnitOptions): string {\n // Create a Duration from the value based on what time unit it is\n const duration: Duration = {};\n switch (unitOptions.kind) {\n case 'Milliseconds':\n duration.seconds = value / 1000;\n break;\n case 'Seconds':\n duration.seconds = value;\n break;\n case 'Minutes':\n duration.minutes = value;\n break;\n case 'Hours':\n duration.hours = value;\n break;\n case 'Days':\n duration.days = value;\n break;\n case 'Weeks':\n duration.weeks = value;\n break;\n case 'Months':\n duration.months = value;\n break;\n case 'Years':\n duration.years = value;\n break;\n default: {\n const exhaustive: never = unitOptions.kind;\n throw new Error(`Unknown time unit type ${exhaustive}`);\n }\n }\n\n // Find the largest whole time unit we can display the value in and use it\n const ms = milliseconds(duration);\n const seconds = ms / 1000;\n if (seconds < 1) {\n return `${ms.toFixed()} milliseconds`;\n }\n\n const minutes = seconds / 60;\n if (minutes < 1) {\n return `${seconds.toFixed()} seconds`;\n }\n\n const hours = minutes / 60;\n if (hours < 1) {\n return `${minutes.toFixed()} minutes`;\n }\n\n const days = hours / 24;\n if (days < 1) {\n return `${hours.toFixed()} hours`;\n }\n\n const weeks = days / 7;\n if (weeks < 1) {\n return `${days.toFixed()} days`;\n }\n\n const years = weeks / 52;\n if (years < 1) {\n return `${weeks.toFixed()} weeks`;\n }\n\n return `${years.toFixed()} years`;\n}\n\n/* Percent Unit Conversion */\nconst percentUnitKinds = ['Percent', 'PercentDecimal', '%'] as const;\nconst percentUnitKindsSet = new Set<string>(percentUnitKinds);\n\ntype PercentUnitOptions = {\n kind: typeof percentUnitKinds[number];\n decimal_places?: number;\n};\n\nfunction isPercentUnit(unitOptions: UnitOptions): unitOptions is PercentUnitOptions {\n return percentUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatPercent(value: number, unitOptions: PercentUnitOptions): string {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n\n if (unitOptions.kind === 'PercentDecimal') {\n value = value * 100;\n }\n\n return value.toFixed(decimals) + '%';\n}\n\n/* Decimal Unit Conversion */\nconst decimalUnitKinds = ['Decimal'] as const;\nconst decimalUnitKindsSet = new Set<string>(decimalUnitKinds);\n\ntype DecimalUnitOptions = {\n kind: typeof decimalUnitKinds[number];\n decimal_places?: number;\n abbreviate?: boolean;\n};\n\nfunction isDecimalUnit(unitOptions: UnitOptions): unitOptions is DecimalUnitOptions {\n return decimalUnitKindsSet.has(unitOptions.kind);\n}\n\nfunction formatDecimal(value: number, unitOptions: DecimalUnitOptions): string {\n const decimals = unitOptions.decimal_places ?? DEFAULT_DECIMAL_PLACES;\n\n if (unitOptions.abbreviate === true) {\n return abbreviateLargeNumber(value, decimals);\n }\n\n const formatParams: Intl.NumberFormatOptions = {\n style: 'decimal',\n minimumFractionDigits: 0,\n maximumFractionDigits: decimals,\n useGrouping: true,\n };\n const decimalFormatter = new Intl.NumberFormat('en-US', formatParams);\n return decimalFormatter.format(value);\n}\n\n/**\n * Takes large numbers and abbreviates them with the appropriate suffix\n * 10123 -> 10.123k\n * 1000000 -> 1M\n */\nexport function abbreviateLargeNumber(num: number, decimals = 2) {\n const modifier = (n: number) => round(n, decimals);\n return formatNumber(num, modifier);\n}\n\n/**\n * Takes large numbers, rounds and abbreviates them with the appropriate suffix\n * Add modifier to run on output value prior to unit being added (defaults to rounding)\n */\nexport function formatNumber(num: number, modifier?: (n: number) => number): string {\n const fn = modifier ?? Math.round;\n\n return num >= 1e12\n ? fn(num / 1e12) + 'T'\n : num >= 1e9\n ? fn(num / 1e9) + 'B'\n : num >= 1e6\n ? fn(num / 1e6) + 'M'\n : num >= 1e3\n ? fn(num / 1e3) + 'K'\n : num.toString();\n}\n\n/* Bytes Unit Conversion */\nconst bytesUnitKinds = ['Bytes'] as const;\nconst bytesUnitKindsSet = new Set<string>(bytesUnitKinds);\n\ntype BytesUnitOptions = {\n kind: typeof bytesUnitKinds[number];\n decimal_places?: number;\n};\n\nfunction isBytesUnit(unitOptions: UnitOptions): unitOptions is BytesUnitOptions {\n return bytesUnitKindsSet.has(unitOptions.kind);\n}\n\n// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript/18650828#18650828\nfunction formatBytes(bytes: number, decimals = 2) {\n if (bytes === 0) return '0 Bytes';\n\n const k = 1024;\n const dm = decimals < 0 ? 0 : decimals;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\n // Math.max(0, ...) ensures that we don't return -1 as a value for the index.\n // Why? When the number of bytes are between -1 and 1, Math.floor(Math.log(bytes)/Math.log(1024)) returns -1.\n const i = Math.max(0, Math.floor(Math.log(bytes) / Math.log(k)));\n\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n}\n"],"names":["milliseconds","round","DEFAULT_DECIMAL_PLACES","formatValue","value","unitOptions","undefined","toString","isDecimalUnit","formatDecimal","isTimeUnit","formatTime","isPercentUnit","formatPercent","isBytesUnit","decimals","decimal_places","formatBytes","exhaustive","Error","timeUnitKinds","timeUnitKindsSet","Set","has","kind","duration","seconds","minutes","hours","days","weeks","months","years","ms","toFixed","percentUnitKinds","percentUnitKindsSet","decimalUnitKinds","decimalUnitKindsSet","abbreviate","abbreviateLargeNumber","formatParams","style","minimumFractionDigits","maximumFractionDigits","useGrouping","decimalFormatter","Intl","NumberFormat","format","num","modifier","n","formatNumber","fn","Math","bytesUnitKinds","bytesUnitKindsSet","bytes","k","dm","sizes","i","max","floor","log","parseFloat","pow"],"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,SAAmBA,YAAY,QAAQ,UAAU,CAAC;AAClD,SAASC,KAAK,QAAQ,iBAAiB,CAAC;AAEx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,GAAG,IAAI,AAAC;IACf,MAAMC,EAAE,GAAG7C,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAGA,QAAQ,AAAC;IACvC,MAAM8C,KAAK,GAAG;QAAC,OAAO;QAAE,IAAI;QAAE,IAAI;QAAE,IAAI;QAAE,IAAI;QAAE,IAAI;QAAE,IAAI;QAAE,IAAI;QAAE,IAAI;KAAC,AAAC;IAExE,6EAA6E;IAC7E,6GAA6G;IAC7G,MAAMC,CAAC,GAAGP,IAAI,CAACQ,GAAG,CAAC,CAAC,EAAER,IAAI,CAACS,KAAK,CAACT,IAAI,CAACU,GAAG,CAACP,KAAK,CAAC,GAAGH,IAAI,CAACU,GAAG,CAACN,CAAC,CAAC,CAAC,CAAC,AAAC;IAEjE,OAAOO,UAAU,CAAC,AAACR,CAAAA,KAAK,GAAGH,IAAI,CAACY,GAAG,CAACR,CAAC,EAAEG,CAAC,CAAC,CAAA,CAAE5B,OAAO,CAAC0B,EAAE,CAAC,CAAC,GAAG,GAAG,GAAGC,KAAK,CAACC,CAAC,CAAC,CAAC;AAC3E,CAAC"}
@@ -1,3 +1,2 @@
1
1
  export * from './render';
2
- export * from './theme';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAaA,cAAc,UAAU,CAAC"}
@@ -11,6 +11,5 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export * from './render';
14
- export * from './theme';
15
14
 
16
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/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 './render';\nexport * from './theme';\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;AACzB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../../src/test/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 './render';\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"}
@@ -0,0 +1,2 @@
1
+ export * from './theme';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,15 @@
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 './theme';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test-utils/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 './theme';\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,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { PersesChartsTheme } from '../model';
2
+ export declare const testChartsTheme: PersesChartsTheme;
3
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/test-utils/theme.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,eAAe,EAAE,iBAO7B,CAAC"}
@@ -11,7 +11,6 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export const testChartsTheme = {
14
- themeName: 'perses',
15
14
  echartsTheme: {},
16
15
  noDataOption: {},
17
16
  sparkline: {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test-utils/theme.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PersesChartsTheme } from '../model';\n\nexport const testChartsTheme: PersesChartsTheme = {\n echartsTheme: {},\n noDataOption: {},\n sparkline: {\n width: 1,\n color: '#000000',\n },\n};\n"],"names":["testChartsTheme","echartsTheme","noDataOption","sparkline","width","color"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,eAAe,GAAsB;IAChDC,YAAY,EAAE,EAAE;IAChBC,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE;QACTC,KAAK,EAAE,CAAC;QACRC,KAAK,EAAE,SAAS;KACjB;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ declare const round: {
2
+ <T extends import("mathjs").MathNumericType | import("mathjs").MathCollection>(x: T, n?: number | import("mathjs").BigNumber | undefined): T extends number ? number : T extends string ? string : T extends boolean ? boolean : T;
3
+ <U extends import("mathjs").MathCollection>(x: import("mathjs").MathNumericType, n: U): U;
4
+ };
5
+ export { round };
6
+ //# sourceMappingURL=mathjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mathjs.d.ts","sourceRoot":"","sources":["../../src/utils/mathjs.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAQ,KAAK;;;CAAkC,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,20 @@
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 { roundDependencies, create } from 'mathjs';
14
+ // This ensures we get a minimal mathjs bundle for just what we need (see https://mathjs.org/docs/custom_bundling.html)
15
+ const { round } = create({
16
+ roundDependencies
17
+ });
18
+ export { round };
19
+
20
+ //# sourceMappingURL=mathjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/mathjs.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { roundDependencies, create } from 'mathjs';\n\n// This ensures we get a minimal mathjs bundle for just what we need (see https://mathjs.org/docs/custom_bundling.html)\nconst { round } = create({ roundDependencies });\nexport { round };\n"],"names":["roundDependencies","create","round"],"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,SAASA,iBAAiB,EAAEC,MAAM,QAAQ,QAAQ,CAAC;AAEnD,uHAAuH;AACvH,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGD,MAAM,CAAC;IAAED,iBAAiB;CAAE,CAAC,AAAC;AAChD,SAASE,KAAK,GAAG"}
@@ -1,6 +1,6 @@
1
1
  import { Theme } from '@mui/material';
2
2
  import { EChartsTheme, PersesChartsTheme } from '../model';
3
3
  declare type MuiTheme = Omit<Theme, 'components'>;
4
- export declare function generateChartsTheme(themeName: string, muiTheme: MuiTheme, echartsTheme: EChartsTheme): PersesChartsTheme;
4
+ export declare function generateChartsTheme(muiTheme: MuiTheme, echartsTheme: EChartsTheme): PersesChartsTheme;
5
5
  export {};
6
6
  //# sourceMappingURL=theme-gen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-gen.d.ts","sourceRoot":"","sources":["../../src/utils/theme-gen.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAK3D,aAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAE1C,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,GACzB,iBAAiB,CA+JnB"}
1
+ {"version":3,"file":"theme-gen.d.ts","sourceRoot":"","sources":["../../src/utils/theme-gen.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAK3D,aAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAE1C,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,GAAG,iBAAiB,CA8JrG"}
@@ -12,7 +12,7 @@
12
12
  // limitations under the License.
13
13
  import { merge } from 'lodash-es';
14
14
  const DEFAULT_TEXT_COLOR = '#222';
15
- export function generateChartsTheme(themeName, muiTheme, echartsTheme) {
15
+ export function generateChartsTheme(muiTheme, echartsTheme) {
16
16
  var ref, ref1, ref2, ref3, ref4;
17
17
  var ref5;
18
18
  const primaryTextColor = (ref5 = (ref = muiTheme.palette.text) === null || ref === void 0 ? void 0 : ref.primary) !== null && ref5 !== void 0 ? ref5 : DEFAULT_TEXT_COLOR;
@@ -152,7 +152,6 @@ export function generateChartsTheme(themeName, muiTheme, echartsTheme) {
152
152
  }
153
153
  };
154
154
  return {
155
- themeName,
156
155
  echartsTheme: merge(muiConvertedTheme, echartsTheme),
157
156
  noDataOption: {
158
157
  title: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/theme-gen.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport { merge } from 'lodash-es';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\n\nconst DEFAULT_TEXT_COLOR = '#222';\n\n// avoid component override type errors since only palette and typography are used\ntype MuiTheme = Omit<Theme, 'components'>;\n\nexport function generateChartsTheme(\n themeName: string,\n muiTheme: MuiTheme,\n echartsTheme: EChartsTheme\n): PersesChartsTheme {\n const primaryTextColor = muiTheme.palette.text?.primary ?? DEFAULT_TEXT_COLOR;\n\n const muiConvertedTheme: EChartsTheme = {\n title: {\n show: false,\n },\n textStyle: {\n color: primaryTextColor,\n fontFamily: muiTheme.typography.fontFamily,\n fontSize: 12,\n },\n grid: {\n top: 5,\n right: 20,\n bottom: 0,\n left: 20,\n containLabel: true,\n },\n color: ['#8dd3c7', '#bebada', '#fb8072', '#80b1d3', '#fdb462'],\n categoryAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n valueAxis: {\n show: true,\n axisLabel: {\n color: primaryTextColor,\n margin: 12,\n },\n axisLine: {\n show: false,\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n },\n legend: {\n orient: 'horizontal',\n textStyle: {\n color: primaryTextColor,\n },\n pageTextStyle: {\n color: muiTheme.palette.grey[600],\n },\n pageIconColor: muiTheme?.palette?.action?.active,\n pageIconInactiveColor: muiTheme?.palette?.action?.disabled,\n },\n toolbox: {\n show: true,\n top: 10,\n right: 10,\n iconStyle: {\n borderColor: primaryTextColor,\n },\n },\n tooltip: {},\n line: {\n showSymbol: false,\n symbol: 'circle',\n symbolSize: 4,\n smooth: false,\n lineStyle: {\n width: 1,\n },\n emphasis: {\n lineStyle: {\n width: 1.5,\n },\n },\n },\n bar: {\n barMaxWidth: 150,\n itemStyle: {\n borderWidth: 0,\n borderColor: muiTheme.palette.grey[300],\n },\n },\n gauge: {\n detail: {\n fontSize: 18,\n fontWeight: 600,\n valueAnimation: false,\n },\n splitLine: {\n distance: 0,\n length: 4,\n lineStyle: {\n width: 1,\n },\n },\n splitNumber: 12,\n },\n };\n\n return {\n themeName,\n echartsTheme: merge(muiConvertedTheme, echartsTheme),\n noDataOption: {\n title: {\n show: true,\n textStyle: {\n color: primaryTextColor,\n fontSize: 16,\n fontWeight: 400,\n },\n text: 'No data',\n left: 'center',\n top: 'center',\n },\n xAxis: {\n show: false,\n },\n yAxis: {\n show: false,\n },\n },\n sparkline: {\n width: 2,\n color: '#1976d2',\n },\n // TODO: add thresholdColors to theme\n };\n}\n"],"names":["merge","DEFAULT_TEXT_COLOR","generateChartsTheme","themeName","muiTheme","echartsTheme","primaryTextColor","palette","text","primary","muiConvertedTheme","title","show","textStyle","color","fontFamily","typography","fontSize","grid","top","right","bottom","left","containLabel","categoryAxis","axisLabel","margin","axisTick","length","lineStyle","grey","axisLine","splitLine","width","opacity","splitArea","areaStyle","valueAxis","legend","orient","pageTextStyle","pageIconColor","action","active","pageIconInactiveColor","disabled","toolbox","iconStyle","borderColor","tooltip","line","showSymbol","symbol","symbolSize","smooth","emphasis","bar","barMaxWidth","itemStyle","borderWidth","gauge","detail","fontWeight","valueAnimation","distance","splitNumber","noDataOption","xAxis","yAxis","sparkline"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,KAAK,QAAQ,WAAW,CAAC;AAGlC,MAAMC,kBAAkB,GAAG,MAAM,AAAC;AAKlC,OAAO,SAASC,mBAAmB,CACjCC,SAAiB,EACjBC,QAAkB,EAClBC,YAA0B,EACP;QACMD,GAAqB,EAgF3BA,IAAiB,QACTA,IAAiB;QAjFnBA,IAA8B;IAAvD,MAAME,gBAAgB,GAAGF,CAAAA,IAA8B,GAA9BA,CAAAA,GAAqB,GAArBA,QAAQ,CAACG,OAAO,CAACC,IAAI,cAArBJ,GAAqB,WAAS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AAQ;aACd;YACDgD,KAAK,EAAE;gBACLvD,IAAI,EAAE,KAAK;aACZ;YACDwD,KAAK,EAAE;gBACLxD,IAAI,EAAE,KAAK;aACZ;SACF;QACDyD,SAAS,EAAE;YACTpC,KAAK,EAAE,CAAC;YACRnB,KAAK,EAAE,SAAS;SACjB;KAEF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/theme-gen.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Theme } from '@mui/material';\nimport { merge } from 'lodash-es';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\n\nconst DEFAULT_TEXT_COLOR = '#222';\n\n// avoid component override type errors since only palette and typography are used\ntype MuiTheme = Omit<Theme, 'components'>;\n\nexport function generateChartsTheme(muiTheme: MuiTheme, echartsTheme: EChartsTheme): PersesChartsTheme {\n const primaryTextColor = muiTheme.palette.text?.primary ?? DEFAULT_TEXT_COLOR;\n\n const muiConvertedTheme: EChartsTheme = {\n title: {\n show: false,\n },\n textStyle: {\n color: primaryTextColor,\n fontFamily: muiTheme.typography.fontFamily,\n fontSize: 12,\n },\n grid: {\n top: 5,\n right: 20,\n bottom: 0,\n left: 20,\n containLabel: true,\n },\n color: ['#8dd3c7', '#bebada', '#fb8072', '#80b1d3', '#fdb462'],\n categoryAxis: {\n show: true,\n axisLabel: {\n show: true,\n color: primaryTextColor,\n margin: 15,\n },\n axisTick: {\n show: false,\n length: 6,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n axisLine: {\n show: true,\n lineStyle: {\n color: muiTheme.palette.grey[600],\n },\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n splitArea: {\n show: false,\n areaStyle: {\n color: [muiTheme.palette.grey[300]],\n },\n },\n },\n valueAxis: {\n show: true,\n axisLabel: {\n color: primaryTextColor,\n margin: 12,\n },\n axisLine: {\n show: false,\n },\n splitLine: {\n show: true,\n lineStyle: {\n width: 0.5,\n color: muiTheme.palette.grey[300],\n opacity: 0.6,\n },\n },\n },\n legend: {\n orient: 'horizontal',\n textStyle: {\n color: primaryTextColor,\n },\n pageTextStyle: {\n color: muiTheme.palette.grey[600],\n },\n pageIconColor: muiTheme?.palette?.action?.active,\n pageIconInactiveColor: muiTheme?.palette?.action?.disabled,\n },\n toolbox: {\n show: true,\n top: 10,\n right: 10,\n iconStyle: {\n borderColor: primaryTextColor,\n },\n },\n tooltip: {},\n line: {\n showSymbol: false,\n symbol: 'circle',\n symbolSize: 4,\n smooth: false,\n lineStyle: {\n width: 1,\n },\n emphasis: {\n lineStyle: {\n width: 1.5,\n },\n },\n },\n bar: {\n barMaxWidth: 150,\n itemStyle: {\n borderWidth: 0,\n borderColor: muiTheme.palette.grey[300],\n },\n },\n gauge: {\n detail: {\n fontSize: 18,\n fontWeight: 600,\n valueAnimation: false,\n },\n splitLine: {\n distance: 0,\n length: 4,\n lineStyle: {\n width: 1,\n },\n },\n splitNumber: 12,\n },\n };\n\n return {\n echartsTheme: merge(muiConvertedTheme, echartsTheme),\n noDataOption: {\n title: {\n show: true,\n textStyle: {\n color: primaryTextColor,\n fontSize: 16,\n fontWeight: 400,\n },\n text: 'No data',\n left: 'center',\n top: 'center',\n },\n xAxis: {\n show: false,\n },\n yAxis: {\n show: false,\n },\n },\n sparkline: {\n width: 2,\n color: '#1976d2',\n },\n // TODO: add thresholdColors to theme\n };\n}\n"],"names":["merge","DEFAULT_TEXT_COLOR","generateChartsTheme","muiTheme","echartsTheme","primaryTextColor","palette","text","primary","muiConvertedTheme","title","show","textStyle","color","fontFamily","typography","fontSize","grid","top","right","bottom","left","containLabel","categoryAxis","axisLabel","margin","axisTick","length","lineStyle","grey","axisLine","splitLine","width","opacity","splitArea","areaStyle","valueAxis","legend","orient","pageTextStyle","pageIconColor","action","active","pageIconInactiveColor","disabled","toolbox","iconStyle","borderColor","tooltip","line","showSymbol","symbol","symbolSize","smooth","emphasis","bar","barMaxWidth","itemStyle","borderWidth","gauge","detail","fontWeight","valueAnimation","distance","splitNumber","noDataOption","xAxis","yAxis","sparkline"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,KAAK,QAAQ,WAAW,CAAC;AAGlC,MAAMC,kBAAkB,GAAG,MAAM,AAAC;AAKlC,OAAO,SAASC,mBAAmB,CAACC,QAAkB,EAAEC,YAA0B,EAAqB;QAC5ED,GAAqB,EAgF3BA,IAAiB,QACTA,IAAiB;QAjFnBA,IAA8B;IAAvD,MAAME,gBAAgB,GAAGF,CAAAA,IAA8B,GAA9BA,CAAAA,GAAqB,GAArBA,QAAQ,CAACG,OAAO,CAACC,IAAI,cAArBJ,GAAqB,WAAS,GAA9BA,KAAAA,CAA8B,GAA9BA,GAAqB,CAAEK,OAAO,cAA9BL,IAA8B,cAA9BA,IAA8B,GAAIF,kBAAkB,AAAC;IAE9E,MAAMQ,iBAAiB,GAAiB;QACtCC,KAAK,EAAE;YACLC,IAAI,EAAE,KAAK;SACZ;QACDC,SAAS,EAAE;YACTC,KAAK,EAAER,gBAAgB;YACvBS,UAAU,EAAEX,QAAQ,CAACY,UAAU,CAACD,UAAU;YAC1CE,QAAQ,EAAE,EAAE;SACb;QACDC,IAAI,EAAE;YACJC,GAAG,EAAE,CAAC;YACNC,KAAK,EAAE,EAAE;YACTC,MAAM,EAAE,CAA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AAK,EAAE,GAAG;iBACX;aACF;SACF;QACDuB,GAAG,EAAE;YACHC,WAAW,EAAE,GAAG;YAChBC,SAAS,EAAE;gBACTC,WAAW,EAAE,CAAC;gBACdX,WAAW,EAAE5C,QAAQ,CAACG,OAAO,CAACuB,IAAI,CAAC,GAAG,CAAC;aACxC;SACF;QACD8B,KAAK,EAAE;YACLC,MAAM,EAAE;gBACN5C,QAAQ,EAAE,EAAE;gBACZ6C,UAAU,EAAE,GAAG;gBACfC,cAAc,EAAE,KAAK;aACtB;YACD/B,SAAS,EAAE;gBACTgC,QAAQ,EAAE,CAAC;gBACXpC,MAAM,EAAE,CAAC;gBACTC,SAAS,EAAE;oBACTI,KAAK,EAAE,CAAC;iBACT;aACF;YACDgC,WAAW,EAAE,EAAE;SAChB;KACF,AAAC;IAEF,OAAO;QACL5D,YAAY,EAAEJ,KAAK,CAACS,iBAAiB,EAAEL,YAAY,CAAC;QACpD6D,YAAY,EAAE;YACZvD,KAAK,EAAE;gBACLC,IAAI,EAAE,IAAI;gBACVC,SAAS,EAAE;oBACTC,KAAK,EAAER,gBAAgB;oBACvBW,QAAQ,EAAE,EAAE;oBACZ6C,UAAU,EAAE,GAAG;iBAChB;gBACDtD,IAAI,EAAE,SAAS;gBACfc,IAAI,EAAE,QAAQ;gBACdH,GAAG,EAAE,QAAQ;aACd;YACDgD,KAAK,EAAE;gBACLvD,IAAI,EAAE,KAAK;aACZ;YACDwD,KAAK,EAAE;gBACLxD,IAAI,EAAE,KAAK;aACZ;SACF;QACDyD,SAAS,EAAE;YACTpC,KAAK,EAAE,CAAC;YACRnB,KAAK,EAAE,SAAS;SACjB;KAEF,CAAC;AACJ,CAAC"}
@@ -25,7 +25,7 @@ describe('generateChartsTheme', ()=>{
25
25
  smooth: true
26
26
  }
27
27
  };
28
- const chartsTheme = generateChartsTheme('perses', muiTheme, echartsThemeOverrides);
28
+ const chartsTheme = generateChartsTheme(muiTheme, echartsThemeOverrides);
29
29
  it('should return perses specific charts theme from converted MUI theme', ()=>{
30
30
  expect(chartsTheme).toMatchInlineSnapshot(`
31
31
  Object {
@@ -187,7 +187,6 @@ describe('generateChartsTheme', ()=>{
187
187
  "color": "#1976d2",
188
188
  "width": 2,
189
189
  },
190
- "themeName": "perses",
191
190
  }
192
191
  `);
193
192
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/theme-gen.test.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createTheme } from '@mui/material';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\nimport { generateChartsTheme } from './theme-gen';\n\ndescribe('generateChartsTheme', () => {\n const muiTheme = createTheme({});\n const echartsThemeOverrides: EChartsTheme = {\n legend: {\n textStyle: {\n color: 'yellow',\n },\n },\n line: {\n showSymbol: true,\n smooth: true,\n },\n };\n const chartsTheme: PersesChartsTheme = generateChartsTheme('perses', muiTheme, echartsThemeOverrides);\n\n it('should return perses specific charts theme from converted MUI theme', () => {\n expect(chartsTheme).toMatchInlineSnapshot(`\n Object {\n \"echartsTheme\": Object {\n \"bar\": Object {\n \"barMaxWidth\": 150,\n \"itemStyle\": Object {\n \"borderColor\": \"#e0e0e0\",\n \"borderWidth\": 0,\n },\n },\n \"categoryAxis\": Object {\n \"axisLabel\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"margin\": 15,\n \"show\": true,\n },\n \"axisLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#757575\",\n },\n \"show\": true,\n },\n \"axisTick\": Object {\n \"length\": 6,\n \"lineStyle\": Object {\n \"color\": \"#757575\",\n },\n \"show\": false,\n },\n \"show\": true,\n \"splitArea\": Object {\n \"areaStyle\": Object {\n \"color\": Array [\n \"#e0e0e0\",\n ],\n },\n \"show\": false,\n },\n \"splitLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#e0e0e0\",\n \"opacity\": 0.6,\n \"width\": 0.5,\n },\n \"show\": true,\n },\n },\n \"color\": Array [\n \"#8dd3c7\",\n \"#bebada\",\n \"#fb8072\",\n \"#80b1d3\",\n \"#fdb462\",\n ],\n \"gauge\": Object {\n \"detail\": Object {\n \"fontSize\": 18,\n \"fontWeight\": 600,\n \"valueAnimation\": false,\n },\n \"splitLine\": Object {\n \"distance\": 0,\n \"length\": 4,\n \"lineStyle\": Object {\n \"width\": 1,\n },\n },\n \"splitNumber\": 12,\n },\n \"grid\": Object {\n \"bottom\": 0,\n \"containLabel\": true,\n \"left\": 20,\n \"right\": 20,\n \"top\": 5,\n },\n \"legend\": Object {\n \"orient\": \"horizontal\",\n \"pageIconColor\": \"rgba(0, 0, 0, 0.54)\",\n \"pageIconInactiveColor\": \"rgba(0, 0, 0, 0.26)\",\n \"pageTextStyle\": Object {\n \"color\": \"#757575\",\n },\n \"textStyle\": Object {\n \"color\": \"yellow\",\n },\n },\n \"line\": Object {\n \"emphasis\": Object {\n \"lineStyle\": Object {\n \"width\": 1.5,\n },\n },\n \"lineStyle\": Object {\n \"width\": 1,\n },\n \"showSymbol\": true,\n \"smooth\": true,\n \"symbol\": \"circle\",\n \"symbolSize\": 4,\n },\n \"textStyle\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"fontFamily\": \"\\\\\"Roboto\\\\\", \\\\\"Helvetica\\\\\", \\\\\"Arial\\\\\", sans-serif\",\n \"fontSize\": 12,\n },\n \"title\": Object {\n \"show\": false,\n },\n \"toolbox\": Object {\n \"iconStyle\": Object {\n \"borderColor\": \"rgba(0, 0, 0, 0.87)\",\n },\n \"right\": 10,\n \"show\": true,\n \"top\": 10,\n },\n \"tooltip\": Object {},\n \"valueAxis\": Object {\n \"axisLabel\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"margin\": 12,\n },\n \"axisLine\": Object {\n \"show\": false,\n },\n \"show\": true,\n \"splitLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#e0e0e0\",\n \"opacity\": 0.6,\n \"width\": 0.5,\n },\n \"show\": true,\n },\n },\n },\n \"noDataOption\": Object {\n \"title\": Object {\n \"left\": \"center\",\n \"show\": true,\n \"text\": \"No data\",\n \"textStyle\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"fontSize\": 16,\n \"fontWeight\": 400,\n },\n \"top\": \"center\",\n },\n \"xAxis\": Object {\n \"show\": false,\n },\n \"yAxis\": Object {\n \"show\": false,\n },\n },\n \"sparkline\": Object {\n \"color\": \"#1976d2\",\n \"width\": 2,\n },\n \"themeName\": \"perses\",\n }\n `);\n });\n});\n"],"names":["createTheme","generateChartsTheme","describe","muiTheme","echartsThemeOverrides","legend","textStyle","color","line","showSymbol","smooth","chartsTheme","it","expect","toMatchInlineSnapshot"],"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,SAASA,WAAW,QAAQ,eAAe,CAAC;AAE5C,SAASC,mBAAmB,QAAQ,aAAa,CAAC;AAElDC,QAAQ,CAAC,qBAAqB,EAAE,IAAM;IACpC,MAAMC,QAAQ,GAAGH,WAAW,CAAC,EAAE,CAAC,AAAC;IACjC,MAAMI,qBAAqB,GAAiB;QAC1CC,MAAM,EAAE;YACNC,SAAS,EAAE;gBACTC,KAAK,EAAE,QAAQ;aAChB;SACF;QACDC,IAAI,EAAE;YACJC,UAAU,EAAE,IAAI;YAChBC,MAAM,EAAE,IAAI;SACb;KACF,AAAC;IACF,MAAMC,WAAW,GAAsBV,mBAAmB,CAAC,QAAQ,EAAEE,QAAQ,EAAEC,qBAAqB,CAAC,AAAC;IAEtGQ,EAAE,CAAC,qEAAqE,EAAE,IAAM;QAC9EC,MAAM,CAACF,WAAW,CAAC,CAACG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkK3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/theme-gen.test.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createTheme } from '@mui/material';\nimport { EChartsTheme, PersesChartsTheme } from '../model';\nimport { generateChartsTheme } from './theme-gen';\n\ndescribe('generateChartsTheme', () => {\n const muiTheme = createTheme({});\n const echartsThemeOverrides: EChartsTheme = {\n legend: {\n textStyle: {\n color: 'yellow',\n },\n },\n line: {\n showSymbol: true,\n smooth: true,\n },\n };\n const chartsTheme: PersesChartsTheme = generateChartsTheme(muiTheme, echartsThemeOverrides);\n\n it('should return perses specific charts theme from converted MUI theme', () => {\n expect(chartsTheme).toMatchInlineSnapshot(`\n Object {\n \"echartsTheme\": Object {\n \"bar\": Object {\n \"barMaxWidth\": 150,\n \"itemStyle\": Object {\n \"borderColor\": \"#e0e0e0\",\n \"borderWidth\": 0,\n },\n },\n \"categoryAxis\": Object {\n \"axisLabel\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"margin\": 15,\n \"show\": true,\n },\n \"axisLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#757575\",\n },\n \"show\": true,\n },\n \"axisTick\": Object {\n \"length\": 6,\n \"lineStyle\": Object {\n \"color\": \"#757575\",\n },\n \"show\": false,\n },\n \"show\": true,\n \"splitArea\": Object {\n \"areaStyle\": Object {\n \"color\": Array [\n \"#e0e0e0\",\n ],\n },\n \"show\": false,\n },\n \"splitLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#e0e0e0\",\n \"opacity\": 0.6,\n \"width\": 0.5,\n },\n \"show\": true,\n },\n },\n \"color\": Array [\n \"#8dd3c7\",\n \"#bebada\",\n \"#fb8072\",\n \"#80b1d3\",\n \"#fdb462\",\n ],\n \"gauge\": Object {\n \"detail\": Object {\n \"fontSize\": 18,\n \"fontWeight\": 600,\n \"valueAnimation\": false,\n },\n \"splitLine\": Object {\n \"distance\": 0,\n \"length\": 4,\n \"lineStyle\": Object {\n \"width\": 1,\n },\n },\n \"splitNumber\": 12,\n },\n \"grid\": Object {\n \"bottom\": 0,\n \"containLabel\": true,\n \"left\": 20,\n \"right\": 20,\n \"top\": 5,\n },\n \"legend\": Object {\n \"orient\": \"horizontal\",\n \"pageIconColor\": \"rgba(0, 0, 0, 0.54)\",\n \"pageIconInactiveColor\": \"rgba(0, 0, 0, 0.26)\",\n \"pageTextStyle\": Object {\n \"color\": \"#757575\",\n },\n \"textStyle\": Object {\n \"color\": \"yellow\",\n },\n },\n \"line\": Object {\n \"emphasis\": Object {\n \"lineStyle\": Object {\n \"width\": 1.5,\n },\n },\n \"lineStyle\": Object {\n \"width\": 1,\n },\n \"showSymbol\": true,\n \"smooth\": true,\n \"symbol\": \"circle\",\n \"symbolSize\": 4,\n },\n \"textStyle\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"fontFamily\": \"\\\\\"Roboto\\\\\", \\\\\"Helvetica\\\\\", \\\\\"Arial\\\\\", sans-serif\",\n \"fontSize\": 12,\n },\n \"title\": Object {\n \"show\": false,\n },\n \"toolbox\": Object {\n \"iconStyle\": Object {\n \"borderColor\": \"rgba(0, 0, 0, 0.87)\",\n },\n \"right\": 10,\n \"show\": true,\n \"top\": 10,\n },\n \"tooltip\": Object {},\n \"valueAxis\": Object {\n \"axisLabel\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"margin\": 12,\n },\n \"axisLine\": Object {\n \"show\": false,\n },\n \"show\": true,\n \"splitLine\": Object {\n \"lineStyle\": Object {\n \"color\": \"#e0e0e0\",\n \"opacity\": 0.6,\n \"width\": 0.5,\n },\n \"show\": true,\n },\n },\n },\n \"noDataOption\": Object {\n \"title\": Object {\n \"left\": \"center\",\n \"show\": true,\n \"text\": \"No data\",\n \"textStyle\": Object {\n \"color\": \"rgba(0, 0, 0, 0.87)\",\n \"fontSize\": 16,\n \"fontWeight\": 400,\n },\n \"top\": \"center\",\n },\n \"xAxis\": Object {\n \"show\": false,\n },\n \"yAxis\": Object {\n \"show\": false,\n },\n },\n \"sparkline\": Object {\n \"color\": \"#1976d2\",\n \"width\": 2,\n },\n }\n `);\n });\n});\n"],"names":["createTheme","generateChartsTheme","describe","muiTheme","echartsThemeOverrides","legend","textStyle","color","line","showSymbol","smooth","chartsTheme","it","expect","toMatchInlineSnapshot"],"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,SAASA,WAAW,QAAQ,eAAe,CAAC;AAE5C,SAASC,mBAAmB,QAAQ,aAAa,CAAC;AAElDC,QAAQ,CAAC,qBAAqB,EAAE,IAAM;IACpC,MAAMC,QAAQ,GAAGH,WAAW,CAAC,EAAE,CAAC,AAAC;IACjC,MAAMI,qBAAqB,GAAiB;QAC1CC,MAAM,EAAE;YACNC,SAAS,EAAE;gBACTC,KAAK,EAAE,QAAQ;aAChB;SACF;QACDC,IAAI,EAAE;YACJC,UAAU,EAAE,IAAI;YAChBC,MAAM,EAAE,IAAI;SACb;KACF,AAAC;IACF,MAAMC,WAAW,GAAsBV,mBAAmB,CAACE,QAAQ,EAAEC,qBAAqB,CAAC,AAAC;IAE5FQ,EAAE,CAAC,qEAAqE,EAAE,IAAM;QAC9EC,MAAM,CAACF,WAAW,CAAC,CAACG,qBAAqB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiK3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}