@perses-dev/heatmap-chart-plugin 0.4.0 → 0.4.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.
- package/__mf/js/{HeatMapChart.a5f52cc0.js → HeatMapChart.9e89e9fc.js} +3 -3
- package/__mf/js/async/{180.c67f24c4.js → 631.8bf555e3.js} +14 -14
- package/__mf/js/async/__federation_expose_HeatMapChart.142ce29b.js +23 -0
- package/__mf/js/{main.69b7f04b.js → main.d436962b.js} +3 -3
- package/lib/cjs/components/HeatMapChartPanel.js +1 -1
- package/lib/components/HeatMapChart.d.ts.map +1 -1
- package/lib/components/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChartPanel.js +1 -1
- package/lib/components/HeatMapChartPanel.js.map +1 -1
- package/mf-manifest.json +8 -8
- package/mf-stats.json +8 -8
- package/package.json +4 -4
- package/__mf/js/async/__federation_expose_HeatMapChart.c74c73d1.js +0 -23
- /package/__mf/js/async/{180.c67f24c4.js.LICENSE.txt → 631.8bf555e3.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/HeatMapChartPanel.tsx"],"sourcesContent":["// Copyright 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 { Stack, Typography } from '@mui/material';\nimport { TimeScale, TimeSeries, TimeSeriesData } from '@perses-dev/core';\nimport { PanelProps } from '@perses-dev/plugin-system';\nimport merge from 'lodash/merge';\nimport { ReactElement, useMemo } from 'react';\nimport { DEFAULT_FORMAT, HeatMapChartOptions, LOG_BASE } from '../heat-map-chart-model';\nimport { generateCompleteTimestamps, getCommonTimeScaleForQueries } from '../utils';\nimport { HeatMapChart, HeatMapDataItem } from './HeatMapChart';\n\n/**\n * Helper function to get the effective lower bound for log scale.\n * For values <= 0, we use a small fraction of the upper bound.\n */\nconst getEffectiveLowerBound = (lowerBound: number, upperBound: number, logBase: LOG_BASE): number => {\n if (logBase === undefined || lowerBound > 0) {\n return lowerBound;\n }\n // For log scales with non-positive lower bounds, use a small fraction of upper bound\n // This ensures the bucket is still visible on the log scale\n return upperBound * 0.001;\n};\n\nexport type HeatMapChartPanelProps = PanelProps<HeatMapChartOptions, TimeSeriesData>;\n\nexport function HeatMapChartPanel(props: HeatMapChartPanelProps): ReactElement | null {\n const { spec: pluginSpec, contentDimensions, queryResults } = props;\n\n // ensures all default format properties set if undef\n const yAxisFormat = merge({}, DEFAULT_FORMAT, pluginSpec.yAxisFormat);\n const countFormat = merge({}, DEFAULT_FORMAT, pluginSpec.countFormat);\n\n const {\n data,\n xAxisCategories,\n min,\n max,\n countMin,\n countMax,\n timeScale,\n }: {\n data: HeatMapDataItem[];\n xAxisCategories: number[];\n min?: number;\n max?: number;\n countMin: number;\n countMax: number;\n timeScale?: TimeScale;\n } = useMemo(() => {\n if (!queryResults || queryResults.length === 0) {\n return {\n data: [],\n xAxisCategories: [],\n min: 0,\n max: 0,\n countMin: 0,\n countMax: 0,\n timeScale: undefined,\n };\n }\n\n if (\n queryResults.length != 1 ||\n queryResults[0]!.data.series.length != 1 ||\n queryResults[0]!.data.series[0]!.histograms === undefined\n ) {\n return {\n data: [],\n xAxisCategories: [],\n min: 0,\n max: 0,\n countMin: 0,\n countMax: 0,\n timeScale: undefined,\n };\n }\n\n const series: TimeSeries = queryResults[0]!.data.series[0]!;\n\n const timeScale = getCommonTimeScaleForQueries(queryResults);\n const xAxisCategories: number[] = generateCompleteTimestamps(timeScale);\n\n const logBase = pluginSpec.logBase;\n\n // Dummy value that will be replaced at the first iteration\n let lowestBound = Infinity;\n let highestBound = -Infinity;\n let countMin = Infinity;\n let countMax = -Infinity;\n\n for (const [, histogram] of series?.histograms ?? []) {\n for (const bucket of histogram?.buckets ?? []) {\n const [, lowerBound, upperBound, count] = bucket;\n let lowerBoundFloat = parseFloat(lowerBound);\n const upperBoundFloat = parseFloat(upperBound);\n const countFloat = parseFloat(count);\n\n // For logarithmic scales, skip buckets that would be entirely non-positive\n if (logBase !== undefined && upperBoundFloat <= 0) {\n continue;\n }\n\n // For log scales, adjust non-positive lower bounds\n if (logBase !== undefined) {\n lowerBoundFloat = getEffectiveLowerBound(lowerBoundFloat, upperBoundFloat, logBase);\n }\n\n if (lowerBoundFloat < lowestBound) {\n lowestBound = lowerBoundFloat;\n }\n if (upperBoundFloat > highestBound) {\n highestBound = upperBoundFloat;\n }\n if (countFloat < countMin) {\n countMin = countFloat;\n }\n if (countFloat > countMax) {\n countMax = countFloat;\n }\n }\n }\n\n const data: HeatMapDataItem[] = [];\n // Each bucket becomes a rectangle spanning [lowerBound, upperBound] at the given x index\n for (const [time, histogram] of series?.histograms ?? []) {\n const itemIndexOnXaxis = xAxisCategories.findIndex((v) => v === time * 1000);\n\n for (const bucket of histogram?.buckets ?? []) {\n const [, lowerBound, upperBound, count] = bucket;\n let lowerBoundFloat = parseFloat(lowerBound);\n const upperBoundFloat = parseFloat(upperBound);\n\n // For logarithmic scales, skip buckets that would be entirely non-positive\n if (logBase !== undefined && upperBoundFloat <= 0) {\n continue;\n }\n\n // For log scales, adjust non-positive lower bounds\n if (logBase !== undefined) {\n lowerBoundFloat = getEffectiveLowerBound(lowerBoundFloat, upperBoundFloat, logBase);\n }\n\n data.push({\n value: [itemIndexOnXaxis, lowerBoundFloat, upperBoundFloat, parseFloat(count)],\n label: count,\n });\n }\n }\n return {\n data,\n xAxisCategories,\n min: lowestBound === Infinity ? undefined : lowestBound,\n max: highestBound === -Infinity ? undefined : highestBound,\n countMin,\n countMax,\n timeScale,\n };\n }, [pluginSpec.logBase, queryResults]);\n\n // Use configured min/max if provided, otherwise use calculated values\n // For logarithmic scales, ignore user-provided min if it's <= 0 (log of non-positive is undefined)\n // and let ECharts auto-calculate the range to avoid rendering issues\n const finalMin = useMemo(() => {\n if (pluginSpec.logBase !== undefined) {\n // For log scale, ignore min if it's <= 0 or let ECharts auto-calculate\n if (pluginSpec.min !== undefined && pluginSpec.min <= 0) {\n return undefined; // Let ECharts auto-calculate\n }\n return pluginSpec.min ?? min;\n }\n return pluginSpec.min ?? min;\n }, [pluginSpec.logBase, pluginSpec.min, min]);\n\n const finalMax = useMemo(() => {\n if (pluginSpec.logBase !== undefined) {\n // For log scale, ignore max if it's <= 0\n if (pluginSpec.max !== undefined && pluginSpec.max <= 0) {\n return undefined; // Let ECharts auto-calculate\n }\n return pluginSpec.max ?? max;\n }\n return pluginSpec.max ?? max;\n }, [pluginSpec.logBase, pluginSpec.max, max]);\n\n // TODO: add support for multiple queries\n if (queryResults.length > 1) {\n return (\n <Stack justifyContent=\"center\" height=\"100%\">\n <Typography variant=\"body2\" textAlign=\"center\">\n Only one query at a time is supported for now\n </Typography>\n </Stack>\n );\n }\n\n // Mo data message handled inside chart component\n if (data.length === 0) {\n return (\n <Stack justifyContent=\"center\" height=\"100%\">\n <Typography variant=\"body2\" textAlign=\"center\">\n No data available (only native histograms are supported for now)\n </Typography>\n </Stack>\n );\n }\n\n if (contentDimensions === undefined) return null;\n\n return (\n <Stack direction=\"row\" justifyContent=\"center\" alignItems=\"center\">\n <HeatMapChart\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={data}\n xAxisCategories={xAxisCategories}\n yAxisFormat={yAxisFormat}\n countFormat={countFormat}\n countMin={countMin}\n countMax={countMax}\n timeScale={timeScale}\n showVisualMap={pluginSpec.showVisualMap}\n min={finalMin}\n max={finalMax}\n logBase={pluginSpec.logBase}\n />\n </Stack>\n );\n}\n"],"names":["Stack","Typography","merge","useMemo","DEFAULT_FORMAT","generateCompleteTimestamps","getCommonTimeScaleForQueries","HeatMapChart","getEffectiveLowerBound","lowerBound","upperBound","logBase","undefined","HeatMapChartPanel","props","spec","pluginSpec","contentDimensions","queryResults","yAxisFormat","countFormat","data","xAxisCategories","min","max","countMin","countMax","timeScale","length","series","histograms","lowestBound","Infinity","highestBound","histogram","bucket","buckets","count","lowerBoundFloat","parseFloat","upperBoundFloat","countFloat","time","itemIndexOnXaxis","findIndex","v","push","value","label","finalMin","finalMax","justifyContent","height","variant","textAlign","direction","alignItems","width","showVisualMap"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAGlD,OAAOC,WAAW,eAAe;AACjC,SAAuBC,OAAO,QAAQ,QAAQ;AAC9C,SAASC,cAAc,QAAuC,0BAA0B;AACxF,SAASC,0BAA0B,EAAEC,4BAA4B,QAAQ,WAAW;AACpF,SAASC,YAAY,QAAyB,iBAAiB;AAE/D;;;CAGC,GACD,MAAMC,yBAAyB,CAACC,YAAoBC,YAAoBC;IACtE,IAAIA,YAAYC,aAAaH,aAAa,GAAG;QAC3C,OAAOA;IACT;IACA,qFAAqF;IACrF,4DAA4D;IAC5D,OAAOC,aAAa;AACtB;AAIA,OAAO,SAASG,kBAAkBC,KAA6B;IAC7D,MAAM,EAAEC,MAAMC,UAAU,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGJ;IAE9D,qDAAqD;IACrD,MAAMK,cAAcjB,MAAM,CAAC,GAAGE,gBAAgBY,WAAWG,WAAW;IACpE,MAAMC,cAAclB,MAAM,CAAC,GAAGE,gBAAgBY,WAAWI,WAAW;IAEpE,MAAM,EACJC,IAAI,EACJC,eAAe,EACfC,GAAG,EACHC,GAAG,EACHC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACV,GAQGxB,QAAQ;QACV,IAAI,CAACe,gBAAgB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AAInC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/HeatMapChartPanel.tsx"],"sourcesContent":["// Copyright 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 { Stack, Typography } from '@mui/material';\nimport { TimeScale, TimeSeries, TimeSeriesData } from '@perses-dev/core';\nimport { PanelProps } from '@perses-dev/plugin-system';\nimport merge from 'lodash/merge';\nimport { ReactElement, useMemo } from 'react';\nimport { DEFAULT_FORMAT, HeatMapChartOptions, LOG_BASE } from '../heat-map-chart-model';\nimport { generateCompleteTimestamps, getCommonTimeScaleForQueries } from '../utils';\nimport { HeatMapChart, HeatMapDataItem } from './HeatMapChart';\n\n/**\n * Helper function to get the effective lower bound for log scale.\n * For values <= 0, we use a small fraction of the upper bound.\n */\nconst getEffectiveLowerBound = (lowerBound: number, upperBound: number, logBase: LOG_BASE): number => {\n if (logBase === undefined || lowerBound > 0) {\n return lowerBound;\n }\n // For log scales with non-positive lower bounds, use a small fraction of upper bound\n // This ensures the bucket is still visible on the log scale\n return upperBound * 0.001;\n};\n\nexport type HeatMapChartPanelProps = PanelProps<HeatMapChartOptions, TimeSeriesData>;\n\nexport function HeatMapChartPanel(props: HeatMapChartPanelProps): ReactElement | null {\n const { spec: pluginSpec, contentDimensions, queryResults } = props;\n\n // ensures all default format properties set if undef\n const yAxisFormat = merge({}, DEFAULT_FORMAT, pluginSpec.yAxisFormat);\n const countFormat = merge({}, DEFAULT_FORMAT, pluginSpec.countFormat);\n\n const {\n data,\n xAxisCategories,\n min,\n max,\n countMin,\n countMax,\n timeScale,\n }: {\n data: HeatMapDataItem[];\n xAxisCategories: number[];\n min?: number;\n max?: number;\n countMin: number;\n countMax: number;\n timeScale?: TimeScale;\n } = useMemo(() => {\n if (!queryResults || queryResults.length === 0) {\n return {\n data: [],\n xAxisCategories: [],\n min: 0,\n max: 0,\n countMin: 0,\n countMax: 0,\n timeScale: undefined,\n };\n }\n\n if (\n queryResults.length !== 1 ||\n queryResults[0]!.data.series.length !== 1 ||\n queryResults[0]!.data.series[0]!.histograms === undefined\n ) {\n return {\n data: [],\n xAxisCategories: [],\n min: 0,\n max: 0,\n countMin: 0,\n countMax: 0,\n timeScale: undefined,\n };\n }\n\n const series: TimeSeries = queryResults[0]!.data.series[0]!;\n\n const timeScale = getCommonTimeScaleForQueries(queryResults);\n const xAxisCategories: number[] = generateCompleteTimestamps(timeScale);\n\n const logBase = pluginSpec.logBase;\n\n // Dummy value that will be replaced at the first iteration\n let lowestBound = Infinity;\n let highestBound = -Infinity;\n let countMin = Infinity;\n let countMax = -Infinity;\n\n for (const [, histogram] of series?.histograms ?? []) {\n for (const bucket of histogram?.buckets ?? []) {\n const [, lowerBound, upperBound, count] = bucket;\n let lowerBoundFloat = parseFloat(lowerBound);\n const upperBoundFloat = parseFloat(upperBound);\n const countFloat = parseFloat(count);\n\n // For logarithmic scales, skip buckets that would be entirely non-positive\n if (logBase !== undefined && upperBoundFloat <= 0) {\n continue;\n }\n\n // For log scales, adjust non-positive lower bounds\n if (logBase !== undefined) {\n lowerBoundFloat = getEffectiveLowerBound(lowerBoundFloat, upperBoundFloat, logBase);\n }\n\n if (lowerBoundFloat < lowestBound) {\n lowestBound = lowerBoundFloat;\n }\n if (upperBoundFloat > highestBound) {\n highestBound = upperBoundFloat;\n }\n if (countFloat < countMin) {\n countMin = countFloat;\n }\n if (countFloat > countMax) {\n countMax = countFloat;\n }\n }\n }\n\n const data: HeatMapDataItem[] = [];\n // Each bucket becomes a rectangle spanning [lowerBound, upperBound] at the given x index\n for (const [time, histogram] of series?.histograms ?? []) {\n const itemIndexOnXaxis = xAxisCategories.findIndex((v) => v === time * 1000);\n\n for (const bucket of histogram?.buckets ?? []) {\n const [, lowerBound, upperBound, count] = bucket;\n let lowerBoundFloat = parseFloat(lowerBound);\n const upperBoundFloat = parseFloat(upperBound);\n\n // For logarithmic scales, skip buckets that would be entirely non-positive\n if (logBase !== undefined && upperBoundFloat <= 0) {\n continue;\n }\n\n // For log scales, adjust non-positive lower bounds\n if (logBase !== undefined) {\n lowerBoundFloat = getEffectiveLowerBound(lowerBoundFloat, upperBoundFloat, logBase);\n }\n\n data.push({\n value: [itemIndexOnXaxis, lowerBoundFloat, upperBoundFloat, parseFloat(count)],\n label: count,\n });\n }\n }\n return {\n data,\n xAxisCategories,\n min: lowestBound === Infinity ? undefined : lowestBound,\n max: highestBound === -Infinity ? undefined : highestBound,\n countMin,\n countMax,\n timeScale,\n };\n }, [pluginSpec.logBase, queryResults]);\n\n // Use configured min/max if provided, otherwise use calculated values\n // For logarithmic scales, ignore user-provided min if it's <= 0 (log of non-positive is undefined)\n // and let ECharts auto-calculate the range to avoid rendering issues\n const finalMin = useMemo(() => {\n if (pluginSpec.logBase !== undefined) {\n // For log scale, ignore min if it's <= 0 or let ECharts auto-calculate\n if (pluginSpec.min !== undefined && pluginSpec.min <= 0) {\n return undefined; // Let ECharts auto-calculate\n }\n return pluginSpec.min ?? min;\n }\n return pluginSpec.min ?? min;\n }, [pluginSpec.logBase, pluginSpec.min, min]);\n\n const finalMax = useMemo(() => {\n if (pluginSpec.logBase !== undefined) {\n // For log scale, ignore max if it's <= 0\n if (pluginSpec.max !== undefined && pluginSpec.max <= 0) {\n return undefined; // Let ECharts auto-calculate\n }\n return pluginSpec.max ?? max;\n }\n return pluginSpec.max ?? max;\n }, [pluginSpec.logBase, pluginSpec.max, max]);\n\n // TODO: add support for multiple queries\n if (queryResults.length > 1) {\n return (\n <Stack justifyContent=\"center\" height=\"100%\">\n <Typography variant=\"body2\" textAlign=\"center\">\n Only one query at a time is supported for now\n </Typography>\n </Stack>\n );\n }\n\n // Mo data message handled inside chart component\n if (data.length === 0) {\n return (\n <Stack justifyContent=\"center\" height=\"100%\">\n <Typography variant=\"body2\" textAlign=\"center\">\n No data available (only native histograms are supported for now)\n </Typography>\n </Stack>\n );\n }\n\n if (contentDimensions === undefined) return null;\n\n return (\n <Stack direction=\"row\" justifyContent=\"center\" alignItems=\"center\">\n <HeatMapChart\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={data}\n xAxisCategories={xAxisCategories}\n yAxisFormat={yAxisFormat}\n countFormat={countFormat}\n countMin={countMin}\n countMax={countMax}\n timeScale={timeScale}\n showVisualMap={pluginSpec.showVisualMap}\n min={finalMin}\n max={finalMax}\n logBase={pluginSpec.logBase}\n />\n </Stack>\n );\n}\n"],"names":["Stack","Typography","merge","useMemo","DEFAULT_FORMAT","generateCompleteTimestamps","getCommonTimeScaleForQueries","HeatMapChart","getEffectiveLowerBound","lowerBound","upperBound","logBase","undefined","HeatMapChartPanel","props","spec","pluginSpec","contentDimensions","queryResults","yAxisFormat","countFormat","data","xAxisCategories","min","max","countMin","countMax","timeScale","length","series","histograms","lowestBound","Infinity","highestBound","histogram","bucket","buckets","count","lowerBoundFloat","parseFloat","upperBoundFloat","countFloat","time","itemIndexOnXaxis","findIndex","v","push","value","label","finalMin","finalMax","justifyContent","height","variant","textAlign","direction","alignItems","width","showVisualMap"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAGlD,OAAOC,WAAW,eAAe;AACjC,SAAuBC,OAAO,QAAQ,QAAQ;AAC9C,SAASC,cAAc,QAAuC,0BAA0B;AACxF,SAASC,0BAA0B,EAAEC,4BAA4B,QAAQ,WAAW;AACpF,SAASC,YAAY,QAAyB,iBAAiB;AAE/D;;;C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AS;;;IAKrD;IAEA,iDAAiD;IACjD,IAAIjC,KAAKO,MAAM,KAAK,GAAG;QACrB,qBACE,KAAC5B;YAAMmD,gBAAe;YAASC,QAAO;sBACpC,cAAA,KAACnD;gBAAWoD,SAAQ;gBAAQC,WAAU;0BAAS;;;IAKrD;IAEA,IAAIrC,sBAAsBL,WAAW,OAAO;IAE5C,qBACE,KAACZ;QAAMuD,WAAU;QAAMJ,gBAAe;QAASK,YAAW;kBACxD,cAAA,KAACjD;YACCkD,OAAOxC,kBAAkBwC,KAAK;YAC9BL,QAAQnC,kBAAkBmC,MAAM;YAChC/B,MAAMA;YACNC,iBAAiBA;YACjBH,aAAaA;YACbC,aAAaA;YACbK,UAAUA;YACVC,UAAUA;YACVC,WAAWA;YACX+B,eAAe1C,WAAW0C,aAAa;YACvCnC,KAAK0B;YACLzB,KAAK0B;YACLvC,SAASK,WAAWL,OAAO;;;AAInC"}
|
package/mf-manifest.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"name": "HeatMapChart",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.4.
|
|
8
|
+
"buildVersion": "0.4.1",
|
|
9
9
|
"buildName": "@perses-dev/heatmap-chart-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/HeatMapChart.
|
|
12
|
+
"name": "__mf/js/HeatMapChart.9e89e9fc.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
{
|
|
29
29
|
"id": "HeatMapChart:@perses-dev/components",
|
|
30
30
|
"name": "@perses-dev/components",
|
|
31
|
-
"version": "0.53.
|
|
31
|
+
"version": "0.53.1",
|
|
32
32
|
"singleton": true,
|
|
33
|
-
"requiredVersion": "^0.53.
|
|
33
|
+
"requiredVersion": "^0.53.1",
|
|
34
34
|
"assets": {
|
|
35
35
|
"js": {
|
|
36
36
|
"async": [],
|
|
37
37
|
"sync": [
|
|
38
|
-
"__mf/js/async/
|
|
38
|
+
"__mf/js/async/631.8bf555e3.js"
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
41
|
"css": {
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
{
|
|
48
48
|
"id": "HeatMapChart:@perses-dev/core",
|
|
49
49
|
"name": "@perses-dev/core",
|
|
50
|
-
"version": "0.53.0
|
|
50
|
+
"version": "0.53.0",
|
|
51
51
|
"singleton": true,
|
|
52
|
-
"requiredVersion": "^0.53.0
|
|
52
|
+
"requiredVersion": "^0.53.0",
|
|
53
53
|
"assets": {
|
|
54
54
|
"js": {
|
|
55
55
|
"async": [],
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"js": {
|
|
150
150
|
"sync": [
|
|
151
151
|
"__mf/js/async/980.092bc51a.js",
|
|
152
|
-
"__mf/js/async/__federation_expose_HeatMapChart.
|
|
152
|
+
"__mf/js/async/__federation_expose_HeatMapChart.142ce29b.js"
|
|
153
153
|
],
|
|
154
154
|
"async": [
|
|
155
155
|
"__mf/js/async/888.944e0384.js"
|
package/mf-stats.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"name": "HeatMapChart",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.4.
|
|
8
|
+
"buildVersion": "0.4.1",
|
|
9
9
|
"buildName": "@perses-dev/heatmap-chart-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/HeatMapChart.
|
|
12
|
+
"name": "__mf/js/HeatMapChart.9e89e9fc.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"shared": [
|
|
28
28
|
{
|
|
29
29
|
"singleton": true,
|
|
30
|
-
"requiredVersion": "^0.53.
|
|
30
|
+
"requiredVersion": "^0.53.1",
|
|
31
31
|
"shareScope": "default",
|
|
32
32
|
"name": "@perses-dev/components",
|
|
33
|
-
"version": "0.53.
|
|
33
|
+
"version": "0.53.1",
|
|
34
34
|
"eager": false,
|
|
35
35
|
"id": "HeatMapChart:@perses-dev/components",
|
|
36
36
|
"assets": {
|
|
37
37
|
"js": {
|
|
38
38
|
"async": [],
|
|
39
39
|
"sync": [
|
|
40
|
-
"__mf/js/async/
|
|
40
|
+
"__mf/js/async/631.8bf555e3.js"
|
|
41
41
|
]
|
|
42
42
|
},
|
|
43
43
|
"css": {
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"singleton": true,
|
|
54
|
-
"requiredVersion": "^0.53.0
|
|
54
|
+
"requiredVersion": "^0.53.0",
|
|
55
55
|
"shareScope": "default",
|
|
56
56
|
"name": "@perses-dev/core",
|
|
57
|
-
"version": "0.53.0
|
|
57
|
+
"version": "0.53.0",
|
|
58
58
|
"eager": false,
|
|
59
59
|
"id": "HeatMapChart:@perses-dev/core",
|
|
60
60
|
"assets": {
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
"js": {
|
|
184
184
|
"sync": [
|
|
185
185
|
"__mf/js/async/980.092bc51a.js",
|
|
186
|
-
"__mf/js/async/__federation_expose_HeatMapChart.
|
|
186
|
+
"__mf/js/async/__federation_expose_HeatMapChart.142ce29b.js"
|
|
187
187
|
],
|
|
188
188
|
"async": [
|
|
189
189
|
"__mf/js/async/888.944e0384.js"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/heatmap-chart-plugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"homepage": "https://github.com/perses/plugins/blob/main/README.md",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"module": "lib/index.js",
|
|
25
25
|
"types": "lib/index.d.ts",
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@perses-dev/components": "^0.53.
|
|
28
|
-
"@perses-dev/core": "^0.53.0
|
|
29
|
-
"@perses-dev/plugin-system": "^0.53.
|
|
27
|
+
"@perses-dev/components": "^0.53.1",
|
|
28
|
+
"@perses-dev/core": "^0.53.0",
|
|
29
|
+
"@perses-dev/plugin-system": "^0.53.1",
|
|
30
30
|
"echarts": "5.5.0",
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
32
|
"react": "^17.0.2 || ^18.0.0",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";(self.chunk_HeatMapChart=self.chunk_HeatMapChart||[]).push([["21"],{4089:function(e,t,o){o.r(t),o.d(t,{HeatMapChart:()=>j});var a=o(2540),i=o(8003),n=o(3648),r=o(3349),l=o(3945),s=o(5632),d=o.n(s);let u={unit:"decimal"},m={none:{label:"None",log:void 0},2:{label:"2",log:2},10:{label:"10",log:10}},p=Object.entries(m).map(e=>{let[t,o]=e;return{id:t,...o}});var c=o(315),h=o(8091),x=o(451),g=o(261),v=o(4653),f=o(6331),y=o(6599),b=o(1785);(0,v.Y)([f.a]);let M=["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"];function C(e){let{width:t,height:o,data:i,xAxisCategories:n,yAxisFormat:l,countFormat:s,countMin:d,countMax:u,timeScale:m,showVisualMap:p,min:c,max:h,logBase:v}=e,f=(0,r.useChartsTheme)(),C=(0,y.A)(),{timeZone:A}=(0,r.useTimeZone)(),j=(0,x.useMemo)(()=>{var e;return{tooltip:{appendToBody:!0,formatter:e=>(function(e){let{data:t,label:o,marker:a,xAxisCategories:i,theme:n,yAxisFormat:l,countFormat:s}=e,[d,u,m]=t,p=i[d],{formattedDate:c,formattedTime:h}=(0,r.getDateAndTime)(p),x=(0,b.AH)`
|
|
2
|
-
border-bottom: 1px solid ${n.palette.grey[500]};
|
|
3
|
-
padding-bottom: 8px;
|
|
4
|
-
`,v=(0,b.AH)`
|
|
5
|
-
display: flex;
|
|
6
|
-
justify-content: space-between;
|
|
7
|
-
padding-top: 8px;
|
|
8
|
-
`,f=(0,b.AH)`
|
|
9
|
-
margin-right: 16px;
|
|
10
|
-
`;return`
|
|
11
|
-
<div>
|
|
12
|
-
<div style="${x.styles}">${c} ${h}</div>
|
|
13
|
-
<div style="${v.styles}">
|
|
14
|
-
<div style="${f.styles}">
|
|
15
|
-
${a}
|
|
16
|
-
<strong>${(0,g.formatValue)(u,l)} - ${(0,g.formatValue)(m,l)}</strong>
|
|
17
|
-
</div>
|
|
18
|
-
<div>
|
|
19
|
-
${(0,g.formatValue)(parseFloat(o),s)}
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
`})({data:e.data.value,label:e.data.label,marker:e.marker,xAxisCategories:n,theme:C,yAxisFormat:l,countFormat:s})},xAxis:{type:"category",data:n,axisLabel:{hideOverlap:!0,formatter:(e=(null==m?void 0:m.rangeMs)??0,function(t){let o=new Date(Number(t));return e>15768e7?(0,r.formatWithTimeZone)(o,"yyy",A):e>63072e6?(0,r.formatWithTimeZone)(o,"MMM yyy",A):e>864e6&&e<1577664e4?(0,r.formatWithTimeZone)(o,"dd.MM",A):e>1728e5&&e<=864e6?(0,r.formatWithTimeZone)(o,"dd.MM HH:mm",A):(0,r.formatWithTimeZone)(o,"HH:mm",A)})}},yAxis:{type:void 0!==v?"log":"value",logBase:v,boundaryGap:[0,"10%"],min:c,max:h,axisLabel:{hideOverlap:!0,formatter:e=>void 0!==v&&0===e?"":(0,g.formatValue)(e,l)}},visualMap:{show:p??!1,type:"continuous",min:d,max:u,realtime:!1,itemHeight:o-30,itemWidth:10,orient:"vertical",left:"right",top:"center",inRange:{color:M},textStyle:{color:C.palette.text.primary,textBorderColor:C.palette.background.default,textBorderWidth:5},dimension:3},series:[{name:"HeatMap",type:"custom",renderItem:function(e,t){let o=t.value(0),a=t.value(1),i=t.value(2),n=t.coord([o,i]),r=t.coord([o,a]),l=t.coord([o+1,i]),s=null==n?void 0:n[0],d=null==n?void 0:n[1],u=null==r?void 0:r[1],m=null==l?void 0:l[0];if(void 0===s||void 0===d||void 0===u||void 0===m)return null;let p=Math.min(d,u);return{type:"rect",shape:{x:s,y:p,width:m-s,height:Math.max(d,u)-p},style:{fill:t.visual("color")}}},label:{show:!1},dimensions:["xIndex","yLower","yUpper","count"],encode:{x:0,y:[1,2],tooltip:[1,2,3]},data:i,progressive:1e3,animation:!1}]}},[n,null==m?void 0:m.rangeMs,A,l,p,d,u,o,C,i,s,c,h,v]),F=(0,x.useMemo)(()=>(0,a.jsx)(r.EChart,{style:{width:t,height:o},sx:{padding:`${f.container.padding.default}px`},option:j,theme:f.echartsTheme}),[f.container.padding.default,f.echartsTheme,o,j,t]);return(0,a.jsx)(a.Fragment,{children:F})}let A=(e,t,o)=>void 0===o||e>0?e:.001*t,j={PanelComponent:function(e){let{spec:t,contentDimensions:o,queryResults:i}=e,n=d()({},u,t.yAxisFormat),r=d()({},u,t.countFormat),{data:l,xAxisCategories:s,min:m,max:p,countMin:v,countMax:f,timeScale:y}=(0,x.useMemo)(()=>{let e;if(!i||0===i.length||1!=i.length||1!=i[0].data.series.length||void 0===i[0].data.series[0].histograms)return{data:[],xAxisCategories:[],min:0,max:0,countMin:0,countMax:0,timeScale:void 0};let o=i[0].data.series[0],a=(e=i.map(e=>e.data),(0,g.getCommonTimeScale)(e)),n=function(e){if(!e)return[];let{startMs:t,endMs:o,stepMs:a}=e,i=[];for(let e=t;e<=o;e+=a)i.push(e);return i}(a),r=t.logBase,l=1/0,s=-1/0,d=1/0,u=-1/0;for(let[,e]of(null==o?void 0:o.histograms)??[])for(let t of(null==e?void 0:e.buckets)??[]){let[,e,o,a]=t,i=parseFloat(e),n=parseFloat(o),m=parseFloat(a);(void 0===r||!(n<=0))&&(void 0!==r&&(i=A(i,n,r)),i<l&&(l=i),n>s&&(s=n),m<d&&(d=m),m>u&&(u=m))}let m=[];for(let[e,t]of(null==o?void 0:o.histograms)??[]){let o=n.findIndex(t=>t===1e3*e);for(let e of(null==t?void 0:t.buckets)??[]){let[,t,a,i]=e,n=parseFloat(t),l=parseFloat(a);void 0!==r&&l<=0||(void 0!==r&&(n=A(n,l,r)),m.push({value:[o,n,l,parseFloat(i)],label:i}))}}return{data:m,xAxisCategories:n,min:l===1/0?void 0:l,max:s===-1/0?void 0:s,countMin:d,countMax:u,timeScale:a}},[t.logBase,i]),b=(0,x.useMemo)(()=>{if(void 0===t.logBase||void 0===t.min||!(t.min<=0))return t.min??m},[t.logBase,t.min,m]),M=(0,x.useMemo)(()=>{if(void 0===t.logBase||void 0===t.max||!(t.max<=0))return t.max??p},[t.logBase,t.max,p]);return i.length>1?(0,a.jsx)(c.A,{justifyContent:"center",height:"100%",children:(0,a.jsx)(h.A,{variant:"body2",textAlign:"center",children:"Only one query at a time is supported for now"})}):0===l.length?(0,a.jsx)(c.A,{justifyContent:"center",height:"100%",children:(0,a.jsx)(h.A,{variant:"body2",textAlign:"center",children:"No data available (only native histograms are supported for now)"})}):void 0===o?null:(0,a.jsx)(c.A,{direction:"row",justifyContent:"center",alignItems:"center",children:(0,a.jsx)(C,{width:o.width,height:o.height,data:l,xAxisCategories:s,yAxisFormat:n,countFormat:r,countMin:v,countMax:f,timeScale:y,showVisualMap:t.showVisualMap,min:b,max:M,logBase:t.logBase})})},supportedQueryTypes:["TimeSeriesQuery"],queryOptions:{mode:"range"},panelOptionsEditorComponents:[{label:"Settings",content:function(e){let{onChange:t,value:o}=e,s=d()({},u,o.yAxisFormat),c=d()({},u,o.countFormat),h=m[o.logBase?String(o.logBase):"none"]??m.none;return(0,a.jsxs)(r.OptionsEditorGrid,{children:[(0,a.jsx)(r.OptionsEditorColumn,{children:(0,a.jsxs)(r.OptionsEditorGroup,{title:"Bucket Count",children:[(0,a.jsx)(r.FormatControls,{value:c,onChange:e=>{t((0,l.produce)(o,t=>{t.countFormat=e}))}}),(0,a.jsx)(r.OptionsEditorControl,{label:"Show Visual Map",control:(0,a.jsx)(i.A,{checked:!!o.showVisualMap,onChange:(e,a)=>{t((0,l.produce)(o,e=>{e.showVisualMap=a}))}})})]})}),(0,a.jsx)(r.OptionsEditorColumn,{children:(0,a.jsxs)(r.OptionsEditorGroup,{title:"Y Axis",children:[(0,a.jsx)(r.FormatControls,{value:s,onChange:e=>{t((0,l.produce)(o,t=>{t.yAxisFormat=e}))}}),(0,a.jsx)(r.OptionsEditorControl,{label:"Min",control:(0,a.jsx)(n.A,{type:"number",value:o.min??"",onChange:e=>{let a=e.target.value?Number(e.target.value):void 0;t((0,l.produce)(o,e=>{e.min=a}))},placeholder:"Auto",sx:{width:"100%"}})}),(0,a.jsx)(r.OptionsEditorControl,{label:"Max",control:(0,a.jsx)(n.A,{type:"number",value:o.max??"",onChange:e=>{let a=e.target.value?Number(e.target.value):void 0;t((0,l.produce)(o,e=>{e.max=a}))},placeholder:"Auto",sx:{width:"100%"}})}),(0,a.jsx)(r.OptionsEditorControl,{label:"Log Base",control:(0,a.jsx)(r.SettingsAutocomplete,{value:{...h,id:(null==h?void 0:h.label)??"None"},options:p,onChange:(e,a)=>{t((0,l.produce)(o,e=>{e.logBase=a.log}))},disableClearable:!0})})]})})]})}}],createInitialOptions:function(){return{yAxisFormat:u,countFormat:u,showVisualMap:!0}}}}}]);
|
|
File without changes
|