@perses-dev/pie-chart-plugin 0.10.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/__mf/css/async/442.d3010b86.css +1 -0
  2. package/__mf/css/async/61.d3010b86.css +1 -0
  3. package/__mf/css/async/823.d3010b86.css +1 -0
  4. package/__mf/js/PieChart.b1153c53.js +6 -0
  5. package/__mf/js/async/{964.7fdfdfd5.js → 121.281eb287.js} +2 -2
  6. package/__mf/js/async/{488.a0bde6cf.js → 177.c83badab.js} +1 -1
  7. package/__mf/js/async/192.b0eb01c2.js +1 -0
  8. package/__mf/js/async/2.ba8aa6eb.js +1 -0
  9. package/__mf/js/async/217.01ced8ce.js +110 -0
  10. package/__mf/js/async/235.88141957.js +1 -0
  11. package/__mf/js/async/250.baaa2e6d.js +7 -0
  12. package/__mf/js/async/252.f2f74aad.js +22 -0
  13. package/__mf/js/async/274.78035147.js +2 -0
  14. package/__mf/js/async/322.e2f8adf7.js +2 -0
  15. package/__mf/js/async/337.13482c5c.js +1 -0
  16. package/__mf/js/async/350.7f227cc5.js +1 -0
  17. package/__mf/js/async/356.75a8af4c.js +1 -0
  18. package/__mf/js/async/392.4e64389c.js +2 -0
  19. package/__mf/js/async/469.e52e96c4.js +1 -0
  20. package/__mf/js/async/470.844ea64f.js +2 -0
  21. package/__mf/js/async/554.2692322c.js +2 -0
  22. package/__mf/js/async/{214.a7648318.js → 587.6f746ff5.js} +1 -1
  23. package/__mf/js/async/616.b6650249.js +1 -0
  24. package/__mf/js/async/663.c0629798.js +1 -0
  25. package/__mf/js/async/721.8dc45583.js +1 -0
  26. package/__mf/js/async/873.8b5831f0.js +1 -0
  27. package/__mf/js/async/941.ca6b716b.js +38 -0
  28. package/__mf/js/async/{738.5a36e399.js → 968.a62ee0f7.js} +1 -1
  29. package/__mf/js/async/__federation_expose_PieChart.af9fd247.js +1 -0
  30. package/__mf/js/async/lib-router.34969c19.js +2 -0
  31. package/__mf/js/main.75a48646.js +6 -0
  32. package/lib/PieChartBase.d.ts +1 -2
  33. package/lib/PieChartBase.d.ts.map +1 -1
  34. package/lib/PieChartBase.js +27 -26
  35. package/lib/PieChartBase.js.map +1 -1
  36. package/lib/PieChartOptionsEditorSettings.d.ts.map +1 -1
  37. package/lib/PieChartOptionsEditorSettings.js +145 -18
  38. package/lib/PieChartOptionsEditorSettings.js.map +1 -1
  39. package/lib/PieChartPanel.d.ts.map +1 -1
  40. package/lib/PieChartPanel.js +37 -28
  41. package/lib/PieChartPanel.js.map +1 -1
  42. package/lib/bootstrap.js +1 -1
  43. package/lib/bootstrap.js.map +1 -1
  44. package/lib/cjs/PieChartBase.js +24 -23
  45. package/lib/cjs/PieChartOptionsEditorSettings.js +142 -15
  46. package/lib/cjs/PieChartPanel.js +35 -26
  47. package/lib/cjs/colors.js +207 -0
  48. package/lib/cjs/index-federation.js +12 -12
  49. package/lib/cjs/index.js +2 -4
  50. package/lib/cjs/pie-chart-model.js +8 -7
  51. package/lib/cjs/utils.js +13 -33
  52. package/lib/colors.d.ts +38 -0
  53. package/lib/colors.d.ts.map +1 -0
  54. package/lib/colors.js +192 -0
  55. package/lib/colors.js.map +1 -0
  56. package/lib/index.d.ts +2 -4
  57. package/lib/index.d.ts.map +1 -1
  58. package/lib/index.js +2 -4
  59. package/lib/index.js.map +1 -1
  60. package/lib/pie-chart-model.d.ts +5 -3
  61. package/lib/pie-chart-model.d.ts.map +1 -1
  62. package/lib/pie-chart-model.js +3 -2
  63. package/lib/pie-chart-model.js.map +1 -1
  64. package/lib/utils.d.ts.map +1 -1
  65. package/lib/utils.js +10 -30
  66. package/lib/utils.js.map +1 -1
  67. package/mf-manifest.json +35 -55
  68. package/mf-stats.json +35 -58
  69. package/package.json +4 -4
  70. package/__mf/css/async/263.80005a4a.css +0 -1
  71. package/__mf/css/async/341.80005a4a.css +0 -1
  72. package/__mf/css/async/759.80005a4a.css +0 -1
  73. package/__mf/js/PieChart.df86cbf0.js +0 -5
  74. package/__mf/js/async/109.77dcc7d9.js +0 -73
  75. package/__mf/js/async/173.c694e6f7.js +0 -2
  76. package/__mf/js/async/224.43460380.js +0 -1
  77. package/__mf/js/async/238.3e689a99.js +0 -1
  78. package/__mf/js/async/288.4cad0403.js +0 -7
  79. package/__mf/js/async/289.c295f73f.js +0 -38
  80. package/__mf/js/async/292.67519c5b.js +0 -1
  81. package/__mf/js/async/298.707087d2.js +0 -1
  82. package/__mf/js/async/409.9c48d616.js +0 -1
  83. package/__mf/js/async/470.1e913aa7.js +0 -2
  84. package/__mf/js/async/651.9c74cbf3.js +0 -1
  85. package/__mf/js/async/656.13055e59.js +0 -1
  86. package/__mf/js/async/680.f1da299d.js +0 -110
  87. package/__mf/js/async/694.011b21e8.js +0 -1
  88. package/__mf/js/async/707.c77cb775.js +0 -1
  89. package/__mf/js/async/708.77a1c1f6.js +0 -1
  90. package/__mf/js/async/740.254a5697.js +0 -1
  91. package/__mf/js/async/75.a825d10b.js +0 -1
  92. package/__mf/js/async/770.73dda090.js +0 -1
  93. package/__mf/js/async/863.2d634113.js +0 -2
  94. package/__mf/js/async/960.021d7634.js +0 -2
  95. package/__mf/js/async/981.e6f0d188.js +0 -2
  96. package/__mf/js/async/__federation_expose_PieChart.3d887a98.js +0 -1
  97. package/__mf/js/async/lib-router.5205dc27.js +0 -2
  98. package/__mf/js/main.47849ff0.js +0 -5
  99. package/lib/cjs/model.js +0 -16
  100. package/lib/cjs/palette-gen.js +0 -63
  101. package/lib/cjs/palette.js +0 -83
  102. package/lib/model.d.ts +0 -20
  103. package/lib/model.d.ts.map +0 -1
  104. package/lib/model.js +0 -15
  105. package/lib/model.js.map +0 -1
  106. package/lib/palette-gen.d.ts +0 -20
  107. package/lib/palette-gen.d.ts.map +0 -1
  108. package/lib/palette-gen.js +0 -50
  109. package/lib/palette-gen.js.map +0 -1
  110. package/lib/palette.d.ts +0 -6
  111. package/lib/palette.d.ts.map +0 -1
  112. package/lib/palette.js +0 -64
  113. package/lib/palette.js.map +0 -1
  114. /package/__mf/js/async/{964.7fdfdfd5.js.LICENSE.txt → 121.281eb287.js.LICENSE.txt} +0 -0
  115. /package/__mf/js/async/{680.f1da299d.js.LICENSE.txt → 217.01ced8ce.js.LICENSE.txt} +0 -0
  116. /package/__mf/js/async/{288.4cad0403.js.LICENSE.txt → 250.baaa2e6d.js.LICENSE.txt} +0 -0
  117. /package/__mf/js/async/{109.77dcc7d9.js.LICENSE.txt → 252.f2f74aad.js.LICENSE.txt} +0 -0
  118. /package/__mf/js/async/{960.021d7634.js.LICENSE.txt → 274.78035147.js.LICENSE.txt} +0 -0
  119. /package/__mf/js/async/{863.2d634113.js.LICENSE.txt → 322.e2f8adf7.js.LICENSE.txt} +0 -0
  120. /package/__mf/js/async/{981.e6f0d188.js.LICENSE.txt → 392.4e64389c.js.LICENSE.txt} +0 -0
  121. /package/__mf/js/async/{173.c694e6f7.js.LICENSE.txt → 470.844ea64f.js.LICENSE.txt} +0 -0
  122. /package/__mf/js/async/{470.1e913aa7.js.LICENSE.txt → 554.2692322c.js.LICENSE.txt} +0 -0
  123. /package/__mf/js/async/{lib-router.5205dc27.js.LICENSE.txt → lib-router.34969c19.js.LICENSE.txt} +0 -0
@@ -1,83 +0,0 @@
1
- // Copyright 2024 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
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- getConsistentCategoricalColor: function() {
25
- return getConsistentCategoricalColor;
26
- },
27
- getConsistentColor: function() {
28
- return getConsistentColor;
29
- }
30
- });
31
- const _colorhash = /*#__PURE__*/ _interop_require_default(require("color-hash"));
32
- function _interop_require_default(obj) {
33
- return obj && obj.__esModule ? obj : {
34
- default: obj
35
- };
36
- }
37
- // Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
38
- // More info: https://github.com/zenozeng/color-hash#custom-hue
39
- // Picked min of 20 and max of 360 to exclude common threshold colors (red).
40
- // Items with "error" in them will always be generated as red.
41
- const ERROR_HUE_CUTOFF = 20;
42
- const colorGenerator = new _colorhash.default({
43
- hue: {
44
- min: ERROR_HUE_CUTOFF,
45
- max: 360
46
- }
47
- });
48
- const redColorGenerator = new _colorhash.default({
49
- hue: {
50
- min: 0,
51
- max: ERROR_HUE_CUTOFF
52
- }
53
- });
54
- function computeConsistentColor(name, error) {
55
- const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
56
- const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
57
- const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
58
- return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
59
- }
60
- // To check whether a color has already been generated for a given string.
61
- // TODO: Predefined color aliases will be defined here
62
- const colorLookup = {};
63
- function getConsistentColor(name, error) {
64
- const key = `${name}_____${error}`;
65
- let value = colorLookup[key];
66
- if (!value) {
67
- value = computeConsistentColor(name, error);
68
- colorLookup[key] = value;
69
- }
70
- return value;
71
- }
72
- function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
73
- const palette = error ? errorPalette : categoricalPalette;
74
- if (palette.length === 0) {
75
- console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
76
- return '#000';
77
- }
78
- let hash = 0;
79
- for(let i = 0; i < name.length; i++){
80
- hash = name.charCodeAt(i) + ((hash << 5) - hash);
81
- }
82
- return palette[Math.abs(hash) % palette.length] ?? '#000';
83
- }
package/lib/model.d.ts DELETED
@@ -1,20 +0,0 @@
1
- export interface QuerySettingsOptions {
2
- queryIndex: number;
3
- colorMode: 'fixed' | 'fixed-single';
4
- colorValue: string;
5
- }
6
- export interface ChartPaletteOptions {
7
- mode: 'auto' | 'categorical';
8
- }
9
- export type StackOptions = 'none' | 'all';
10
- export type ChartVisualOptions = {
11
- display?: 'line' | 'bar';
12
- lineWidth?: number;
13
- areaOpacity?: number;
14
- showPoints?: 'auto' | 'always';
15
- palette?: ChartPaletteOptions;
16
- pointRadius?: number;
17
- stack?: StackOptions;
18
- connectNulls?: boolean;
19
- };
20
- //# sourceMappingURL=model.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,GAAG,cAAc,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC;CAC9B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC"}
package/lib/model.js DELETED
@@ -1,15 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- export { };
14
-
15
- //# sourceMappingURL=model.js.map
package/lib/model.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport interface QuerySettingsOptions {\n queryIndex: number;\n colorMode: 'fixed' | 'fixed-single';\n colorValue: string;\n}\n\nexport interface ChartPaletteOptions {\n mode: 'auto' | 'categorical';\n}\n\nexport type StackOptions = 'none' | 'all';\n\nexport type ChartVisualOptions = {\n display?: 'line' | 'bar';\n lineWidth?: number;\n areaOpacity?: number;\n showPoints?: 'auto' | 'always';\n palette?: ChartPaletteOptions;\n pointRadius?: number;\n stack?: StackOptions;\n connectNulls?: boolean;\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;AAcjC,WASE"}
@@ -1,20 +0,0 @@
1
- export interface SeriesColorProps {
2
- categoricalPalette: string[];
3
- muiPrimaryColor: string;
4
- seriesName: string;
5
- }
6
- /**
7
- * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative
8
- */
9
- export declare function getSeriesColor(props: SeriesColorProps): string;
10
- /**
11
- * Get color from generative color palette, this approaches uses series name as the seed and
12
- * allows for consistent colors across panels (when all panels use this approach).
13
- */
14
- export declare function getAutoPaletteColor(name: string, fallbackColor: string): string;
15
- /**
16
- * Default classical qualitative palette that cycles through the colors array by index.
17
- */
18
- export declare function getCategoricalPaletteColor(palette: string[], seriesIndex: number, fallbackColor: string): string;
19
- export declare function getConsistentSeriesNameColor(inputString: string): string;
20
- //# sourceMappingURL=palette-gen.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"palette-gen.d.ts","sourceRoot":"","sources":["../../src/palette-gen.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAU9D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAI/E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAUhH;AAKD,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAExE"}
@@ -1,50 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { getConsistentColor } from './palette';
14
- /**
15
- * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative
16
- */ export function getSeriesColor(props) {
17
- const { categoricalPalette, muiPrimaryColor, seriesName } = props;
18
- // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.
19
- const fallbackColor = Array.isArray(categoricalPalette) && categoricalPalette[0] ? categoricalPalette[0] // Needed since echarts color property isn't always an array.
20
- : muiPrimaryColor;
21
- return getAutoPaletteColor(seriesName, fallbackColor);
22
- }
23
- /**
24
- * Get color from generative color palette, this approaches uses series name as the seed and
25
- * allows for consistent colors across panels (when all panels use this approach).
26
- */ export function getAutoPaletteColor(name, fallbackColor) {
27
- // corresponds to 'Auto' in palette.kind for generative color palette
28
- const generatedColor = getConsistentSeriesNameColor(name);
29
- return generatedColor ?? fallbackColor;
30
- }
31
- /**
32
- * Default classical qualitative palette that cycles through the colors array by index.
33
- */ export function getCategoricalPaletteColor(palette, seriesIndex, fallbackColor) {
34
- if (palette === undefined) {
35
- return fallbackColor;
36
- }
37
- // Loop through predefined static color palette
38
- const paletteTotalColors = palette.length ?? 1;
39
- const paletteIndex = seriesIndex % paletteTotalColors;
40
- // fallback color comes from echarts theme
41
- const seriesColor = palette[paletteIndex] ?? fallbackColor;
42
- return seriesColor;
43
- }
44
- /*
45
- * Generate a consistent series name color (if series name includes 'error', it will have a red hue).
46
- */ export function getConsistentSeriesNameColor(inputString) {
47
- return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));
48
- }
49
-
50
- //# sourceMappingURL=palette-gen.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/palette-gen.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getConsistentColor } from './palette';\n\nexport interface SeriesColorProps {\n categoricalPalette: string[];\n muiPrimaryColor: string;\n seriesName: string;\n}\n\n/**\n * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative\n */\nexport function getSeriesColor(props: SeriesColorProps): string {\n const { categoricalPalette, muiPrimaryColor, seriesName } = props;\n\n // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.\n const fallbackColor =\n Array.isArray(categoricalPalette) && categoricalPalette[0]\n ? (categoricalPalette[0] as string) // Needed since echarts color property isn't always an array.\n : muiPrimaryColor;\n\n return getAutoPaletteColor(seriesName, fallbackColor);\n}\n\n/**\n * Get color from generative color palette, this approaches uses series name as the seed and\n * allows for consistent colors across panels (when all panels use this approach).\n */\nexport function getAutoPaletteColor(name: string, fallbackColor: string): string {\n // corresponds to 'Auto' in palette.kind for generative color palette\n const generatedColor = getConsistentSeriesNameColor(name);\n return generatedColor ?? fallbackColor;\n}\n\n/**\n * Default classical qualitative palette that cycles through the colors array by index.\n */\nexport function getCategoricalPaletteColor(palette: string[], seriesIndex: number, fallbackColor: string): string {\n if (palette === undefined) {\n return fallbackColor;\n }\n // Loop through predefined static color palette\n const paletteTotalColors = palette.length ?? 1;\n const paletteIndex = seriesIndex % paletteTotalColors;\n // fallback color comes from echarts theme\n const seriesColor = palette[paletteIndex] ?? fallbackColor;\n return seriesColor;\n}\n\n/*\n * Generate a consistent series name color (if series name includes 'error', it will have a red hue).\n */\nexport function getConsistentSeriesNameColor(inputString: string): string {\n return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));\n}\n"],"names":["getConsistentColor","getSeriesColor","props","categoricalPalette","muiPrimaryColor","seriesName","fallbackColor","Array","isArray","getAutoPaletteColor","name","generatedColor","getConsistentSeriesNameColor","getCategoricalPaletteColor","palette","seriesIndex","undefined","paletteTotalColors","length","paletteIndex","seriesColor","inputString","toLowerCase","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,SAASA,kBAAkB,QAAQ,YAAY;AAQ/C;;CAEC,GACD,OAAO,SAASC,eAAeC,KAAuB;IACpD,MAAM,EAAEC,kBAAkB,EAAEC,eAAe,EAAEC,UAAU,EAAE,GAAGH;IAE5D,kGAAkG;IAClG,MAAMI,gBACJC,MAAMC,OAAO,CAACL,uBAAuBA,kBAAkB,CAAC,EAAE,GACrDA,kBAAkB,CAAC,EAAE,CAAY,6DAA6D;OAC/FC;IAEN,OAAOK,oBAAoBJ,YAAYC;AACzC;AAEA;;;CAGC,GACD,OAAO,SAASG,oBAAoBC,IAAY,EAAEJ,aAAqB;IACrE,qEAAqE;IACrE,MAAMK,iBAAiBC,6BAA6BF;IACpD,OAAOC,kBAAkBL;AAC3B;AAEA;;CAEC,GACD,OAAO,SAASO,2BAA2BC,OAAiB,EAAEC,WAAmB,EAAET,aAAqB;IACtG,IAAIQ,YAAYE,WAAW;QACzB,OAAOV;IACT;IACA,+CAA+C;IAC/C,MAAMW,qBAAqBH,QAAQI,MAAM,IAAI;IAC7C,MAAMC,eAAeJ,cAAcE;IACnC,0CAA0C;IAC1C,MAAMG,cAAcN,OAAO,CAACK,aAAa,IAAIb;IAC7C,OAAOc;AACT;AAEA;;CAEC,GACD,OAAO,SAASR,6BAA6BS,WAAmB;IAC9D,OAAOrB,mBAAmBqB,aAAaA,YAAYC,WAAW,GAAGC,QAAQ,CAAC;AAC5E"}
package/lib/palette.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Return a consistent color for (name, error) tuple
3
- */
4
- export declare function getConsistentColor(name: string, error: boolean): string;
5
- export declare function getConsistentCategoricalColor(name: string, error: boolean, categoricalPalette: string[], errorPalette: string[]): string;
6
- //# sourceMappingURL=palette.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/palette.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAQvE;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,kBAAkB,EAAE,MAAM,EAAE,EAC5B,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,CAaR"}
package/lib/palette.js DELETED
@@ -1,64 +0,0 @@
1
- // Copyright 2024 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 ColorHash from 'color-hash';
14
- // Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
15
- // More info: https://github.com/zenozeng/color-hash#custom-hue
16
- // Picked min of 20 and max of 360 to exclude common threshold colors (red).
17
- // Items with "error" in them will always be generated as red.
18
- const ERROR_HUE_CUTOFF = 20;
19
- const colorGenerator = new ColorHash({
20
- hue: {
21
- min: ERROR_HUE_CUTOFF,
22
- max: 360
23
- }
24
- });
25
- const redColorGenerator = new ColorHash({
26
- hue: {
27
- min: 0,
28
- max: ERROR_HUE_CUTOFF
29
- }
30
- });
31
- function computeConsistentColor(name, error) {
32
- const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
33
- const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
34
- const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
35
- return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
36
- }
37
- // To check whether a color has already been generated for a given string.
38
- // TODO: Predefined color aliases will be defined here
39
- const colorLookup = {};
40
- /**
41
- * Return a consistent color for (name, error) tuple
42
- */ export function getConsistentColor(name, error) {
43
- const key = `${name}_____${error}`;
44
- let value = colorLookup[key];
45
- if (!value) {
46
- value = computeConsistentColor(name, error);
47
- colorLookup[key] = value;
48
- }
49
- return value;
50
- }
51
- export function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
52
- const palette = error ? errorPalette : categoricalPalette;
53
- if (palette.length === 0) {
54
- console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
55
- return '#000';
56
- }
57
- let hash = 0;
58
- for(let i = 0; i < name.length; i++){
59
- hash = name.charCodeAt(i) + ((hash << 5) - hash);
60
- }
61
- return palette[Math.abs(hash) % palette.length] ?? '#000';
62
- }
63
-
64
- //# sourceMappingURL=palette.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/palette.ts"],"sourcesContent":["// Copyright 2024 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 ColorHash from 'color-hash';\n\n// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.\n// More info: https://github.com/zenozeng/color-hash#custom-hue\n// Picked min of 20 and max of 360 to exclude common threshold colors (red).\n// Items with \"error\" in them will always be generated as red.\nconst ERROR_HUE_CUTOFF = 20;\nconst colorGenerator = new ColorHash({ hue: { min: ERROR_HUE_CUTOFF, max: 360 } });\nconst redColorGenerator = new ColorHash({ hue: { min: 0, max: ERROR_HUE_CUTOFF } });\n\nfunction computeConsistentColor(name: string, error: boolean): string {\n const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);\n const saturationPercent = `${(saturation * 100).toFixed(0)}%`;\n const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;\n return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;\n}\n\n// To check whether a color has already been generated for a given string.\n// TODO: Predefined color aliases will be defined here\nconst colorLookup: Record<string, string> = {};\n\n/**\n * Return a consistent color for (name, error) tuple\n */\nexport function getConsistentColor(name: string, error: boolean): string {\n const key = `${name}_____${error}`;\n let value = colorLookup[key];\n if (!value) {\n value = computeConsistentColor(name, error);\n colorLookup[key] = value;\n }\n return value;\n}\n\nexport function getConsistentCategoricalColor(\n name: string,\n error: boolean,\n categoricalPalette: string[],\n errorPalette: string[]\n): string {\n const palette = error ? errorPalette : categoricalPalette;\n if (palette.length === 0) {\n console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');\n return '#000';\n }\n\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n hash = name.charCodeAt(i) + ((hash << 5) - hash);\n }\n\n return palette[Math.abs(hash) % palette.length] ?? '#000';\n}\n"],"names":["ColorHash","ERROR_HUE_CUTOFF","colorGenerator","hue","min","max","redColorGenerator","computeConsistentColor","name","error","saturation","lightness","hsl","saturationPercent","toFixed","lightnessPercent","colorLookup","getConsistentColor","key","value","getConsistentCategoricalColor","categoricalPalette","errorPalette","palette","length","console","warn","hash","i","charCodeAt","Math","abs"],"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,OAAOA,eAAe,aAAa;AAEnC,qFAAqF;AACrF,+DAA+D;AAC/D,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB,IAAIF,UAAU;IAAEG,KAAK;QAAEC,KAAKH;QAAkBI,KAAK;IAAI;AAAE;AAChF,MAAMC,oBAAoB,IAAIN,UAAU;IAAEG,KAAK;QAAEC,KAAK;QAAGC,KAAKJ;IAAiB;AAAE;AAEjF,SAASM,uBAAuBC,IAAY,EAAEC,KAAc;IAC1D,MAAM,CAACN,KAAKO,YAAYC,UAAU,GAAGF,QAAQH,kBAAkBM,GAAG,CAACJ,QAAQN,eAAeU,GAAG,CAACJ;IAC9F,MAAMK,oBAAoB,GAAG,AAACH,CAAAA,aAAa,GAAE,EAAGI,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7D,MAAMC,mBAAmB,GAAG,AAACJ,CAAAA,YAAY,GAAE,EAAGG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,KAAK,EAAEX,IAAIW,OAAO,CAAC,GAAG,CAAC,EAAED,kBAAkB,CAAC,EAAEE,iBAAiB,KAAK,CAAC;AAC/E;AAEA,0EAA0E;AAC1E,sDAAsD;AACtD,MAAMC,cAAsC,CAAC;AAE7C;;CAEC,GACD,OAAO,SAASC,mBAAmBT,IAAY,EAAEC,KAAc;IAC7D,MAAMS,MAAM,GAAGV,KAAK,KAAK,EAAEC,OAAO;IAClC,IAAIU,QAAQH,WAAW,CAACE,IAAI;IAC5B,IAAI,CAACC,OAAO;QACVA,QAAQZ,uBAAuBC,MAAMC;QACrCO,WAAW,CAACE,IAAI,GAAGC;IACrB;IACA,OAAOA;AACT;AAEA,OAAO,SAASC,8BACdZ,IAAY,EACZC,KAAc,EACdY,kBAA4B,EAC5BC,YAAsB;IAEtB,MAAMC,UAAUd,QAAQa,eAAeD;IACvC,IAAIE,QAAQC,MAAM,KAAK,GAAG;QACxBC,QAAQC,IAAI,CAAC;QACb,OAAO;IACT;IAEA,IAAIC,OAAO;IACX,IAAK,IAAIC,IAAI,GAAGA,IAAIpB,KAAKgB,MAAM,EAAEI,IAAK;QACpCD,OAAOnB,KAAKqB,UAAU,CAACD,KAAM,CAAA,AAACD,CAAAA,QAAQ,CAAA,IAAKA,IAAG;IAChD;IAEA,OAAOJ,OAAO,CAACO,KAAKC,GAAG,CAACJ,QAAQJ,QAAQC,MAAM,CAAC,IAAI;AACrD"}