@perses-dev/timeseries-chart-plugin 0.14.0-beta.0 → 0.14.0-beta.2
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/TimeSeriesChart.b9caac04.js +7 -0
- package/__mf/js/async/121.fde1320e.js +2 -0
- package/__mf/js/async/{527.f97d1b86.js → 182.9e1e293f.js} +9 -9
- package/__mf/js/async/192.66c6659d.js +1 -0
- package/__mf/js/async/2.166bda4f.js +1 -0
- package/__mf/js/async/235.76fd7af2.js +1 -0
- package/__mf/js/async/274.e4ed32f7.js +2 -0
- package/__mf/js/async/319.8e262f9c.js +1 -0
- package/__mf/js/async/356.52455d93.js +1 -0
- package/__mf/js/async/384.f40367cc.js +1 -0
- package/__mf/js/async/392.8cb3dcaa.js +2 -0
- package/__mf/js/async/463.f5dc7759.js +7 -0
- package/__mf/js/async/{694.0fb9ee5a.js.LICENSE.txt → 463.f5dc7759.js.LICENSE.txt} +41 -1
- package/__mf/js/async/465.add3260a.js +1 -0
- package/__mf/js/async/470.beedcbcc.js +2 -0
- package/__mf/js/async/522.806db24f.js +22 -0
- package/__mf/js/async/525.8b92c616.js +37 -0
- package/__mf/js/async/587.828c454a.js +1 -0
- package/__mf/js/async/597.0c5bd6dd.js +2 -0
- package/__mf/js/async/612.b2f31132.js +3 -0
- package/__mf/js/async/616.804d525d.js +1 -0
- package/__mf/js/async/663.892b9ad5.js +1 -0
- package/__mf/js/async/700.25c7e5dd.js +1 -0
- package/__mf/js/async/724.f74ffa12.js +1 -0
- package/__mf/js/async/730.058dea58.js +2 -0
- package/__mf/js/async/865.cb917066.js +2 -0
- package/__mf/js/async/941.3bb54150.js +2 -0
- package/__mf/js/async/955.52ca0671.js +1 -0
- package/__mf/js/async/968.2dd830b3.js +1 -0
- package/__mf/js/async/__federation_expose_TimeSeriesChart.4ddb01e0.js +1 -0
- package/__mf/js/async/lib-router.ecb51f08.js +2 -0
- package/__mf/js/{main.35c70c1e.js → main.f55169be.js} +7 -7
- package/lib/GeneralSettingsEditor.d.ts +2 -2
- package/lib/GeneralSettingsEditor.d.ts.map +1 -1
- package/lib/GeneralSettingsEditor.js +7 -7
- package/lib/GeneralSettingsEditor.js.map +1 -1
- package/lib/QuerySettingsEditor.d.ts +2 -2
- package/lib/QuerySettingsEditor.d.ts.map +1 -1
- package/lib/QuerySettingsEditor.js +11 -11
- package/lib/QuerySettingsEditor.js.map +1 -1
- package/lib/TimeSeriesChart.d.ts +3 -3
- package/lib/TimeSeriesChart.d.ts.map +1 -1
- package/lib/TimeSeriesChart.js +5 -5
- package/lib/TimeSeriesChart.js.map +1 -1
- package/lib/TimeSeriesChartBase.d.ts +4 -4
- package/lib/TimeSeriesChartBase.d.ts.map +1 -1
- package/lib/TimeSeriesChartBase.js +12 -12
- package/lib/TimeSeriesChartBase.js.map +1 -1
- package/lib/TimeSeriesChartPanel.d.ts +4 -4
- package/lib/TimeSeriesChartPanel.d.ts.map +1 -1
- package/lib/TimeSeriesChartPanel.js +11 -11
- package/lib/TimeSeriesChartPanel.js.map +1 -1
- package/lib/TimeSeriesExportAction.d.ts +1 -1
- package/lib/TimeSeriesExportAction.d.ts.map +1 -1
- package/lib/TimeSeriesExportAction.js +5 -5
- package/lib/TimeSeriesExportAction.js.map +1 -1
- package/lib/VisualOptionsEditor.d.ts +2 -2
- package/lib/VisualOptionsEditor.d.ts.map +1 -1
- package/lib/VisualOptionsEditor.js +4 -4
- package/lib/VisualOptionsEditor.js.map +1 -1
- package/lib/YAxisOptionsEditor.d.ts +2 -2
- package/lib/YAxisOptionsEditor.d.ts.map +1 -1
- package/lib/YAxisOptionsEditor.js +3 -3
- package/lib/YAxisOptionsEditor.js.map +1 -1
- package/lib/annotations/AnnotationTooltip.d.ts +2 -2
- package/lib/annotations/AnnotationTooltip.d.ts.map +1 -1
- package/lib/annotations/AnnotationTooltip.js +6 -6
- package/lib/annotations/AnnotationTooltip.js.map +1 -1
- package/lib/bootstrap.js +2 -2
- package/lib/getPluginModule.d.ts +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +3 -1
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index.js +9 -9
- package/lib/index.js.map +1 -1
- package/lib/setup-tests.d.ts +1 -1
- package/lib/setup-tests.d.ts.map +1 -1
- package/lib/setup-tests.js +2 -2
- package/lib/setup-tests.js.map +1 -1
- package/lib/test/mock-query-results.d.ts +1 -1
- package/lib/test/mock-query-results.d.ts.map +1 -1
- package/lib/test/mock-query-results.js.map +1 -1
- package/lib/time-series-chart-model.d.ts +3 -3
- package/lib/time-series-chart-model.d.ts.map +1 -1
- package/lib/time-series-chart-model.js.map +1 -1
- package/lib/utils/annotation.d.ts +2 -2
- package/lib/utils/annotation.d.ts.map +1 -1
- package/lib/utils/annotation.js.map +1 -1
- package/lib/utils/data-transform.d.ts +5 -5
- package/lib/utils/data-transform.d.ts.map +1 -1
- package/lib/utils/data-transform.js +3 -3
- package/lib/utils/data-transform.js.map +1 -1
- package/lib/utils/palette-gen.d.ts +1 -1
- package/lib/utils/palette-gen.d.ts.map +1 -1
- package/lib/utils/palette-gen.js +1 -1
- package/lib/utils/palette-gen.js.map +1 -1
- package/lib/utils/palette.js +1 -1
- package/lib/utils/palette.js.map +1 -1
- package/lib/utils/timezone-formatter.js +1 -1
- package/mf-manifest.json +37 -81
- package/mf-stats.json +39 -91
- package/package.json +11 -11
- package/__mf/js/TimeSeriesChart.7c5da441.js +0 -7
- package/__mf/js/async/121.c3c0e54f.js +0 -2
- package/__mf/js/async/163.cce4c882.js +0 -22
- package/__mf/js/async/177.2fef2962.js +0 -1
- package/__mf/js/async/187.f5e8932b.js +0 -1
- package/__mf/js/async/192.c3dd56d5.js +0 -1
- package/__mf/js/async/2.60fa4a40.js +0 -1
- package/__mf/js/async/202.29f2b119.js +0 -37
- package/__mf/js/async/208.b9f374ad.js +0 -7
- package/__mf/js/async/208.b9f374ad.js.LICENSE.txt +0 -39
- package/__mf/js/async/235.d23c8ef0.js +0 -1
- package/__mf/js/async/274.72dfa9c8.js +0 -2
- package/__mf/js/async/356.8170c96d.js +0 -1
- package/__mf/js/async/392.b9ba5bf2.js +0 -2
- package/__mf/js/async/470.e09f33b7.js +0 -2
- package/__mf/js/async/491.85194549.js +0 -1
- package/__mf/js/async/52.0d78de2b.js +0 -1
- package/__mf/js/async/568.45da2c30.js +0 -1
- package/__mf/js/async/587.c9460696.js +0 -1
- package/__mf/js/async/588.0a1aa144.js +0 -1
- package/__mf/js/async/616.79484ac8.js +0 -1
- package/__mf/js/async/626.9d2c051c.js +0 -2
- package/__mf/js/async/682.971bf8bf.js +0 -3
- package/__mf/js/async/694.0fb9ee5a.js +0 -2
- package/__mf/js/async/702.785cd635.js +0 -2
- package/__mf/js/async/71.8c6cf914.js +0 -1
- package/__mf/js/async/724.c45dcf5b.js +0 -1
- package/__mf/js/async/873.04a201bf.js +0 -1
- package/__mf/js/async/941.b89f8595.js +0 -2
- package/__mf/js/async/955.176fe200.js +0 -1
- package/__mf/js/async/968.2a9fb1a0.js +0 -1
- package/__mf/js/async/978.a9865b23.js +0 -1
- package/__mf/js/async/996.bd40c9c2.js +0 -2
- package/__mf/js/async/__federation_expose_TimeSeriesChart.0f989a8c.js +0 -1
- package/__mf/js/async/lib-router.319c02cd.js +0 -2
- package/lib/cjs/GeneralSettingsEditor.js +0 -103
- package/lib/cjs/QuerySettingsEditor.js +0 -666
- package/lib/cjs/TimeSeriesChart.js +0 -51
- package/lib/cjs/TimeSeriesChartBase.js +0 -488
- package/lib/cjs/TimeSeriesChartPanel.js +0 -456
- package/lib/cjs/TimeSeriesExportAction.js +0 -124
- package/lib/cjs/VisualOptionsEditor.js +0 -161
- package/lib/cjs/YAxisOptionsEditor.js +0 -118
- package/lib/cjs/annotations/AnnotationTooltip.js +0 -370
- package/lib/cjs/bootstrap.js +0 -26
- package/lib/cjs/env.d.js +0 -14
- package/lib/cjs/getPluginModule.js +0 -39
- package/lib/cjs/index-federation.js +0 -55
- package/lib/cjs/index.js +0 -44
- package/lib/cjs/setup-tests.js +0 -19
- package/lib/cjs/test/mock-query-results.js +0 -403
- package/lib/cjs/time-series-chart-model.js +0 -225
- package/lib/cjs/utils/annotation.js +0 -37
- package/lib/cjs/utils/data-transform.js +0 -243
- package/lib/cjs/utils/palette-gen.js +0 -75
- package/lib/cjs/utils/palette.js +0 -83
- package/lib/cjs/utils/timezone-formatter.js +0 -48
- /package/__mf/css/async/{208.85c2cbf6.css → 463.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{121.c3c0e54f.js.LICENSE.txt → 121.fde1320e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{527.f97d1b86.js.LICENSE.txt → 182.9e1e293f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.72dfa9c8.js.LICENSE.txt → 274.e4ed32f7.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.b9ba5bf2.js.LICENSE.txt → 392.8cb3dcaa.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.e09f33b7.js.LICENSE.txt → 470.beedcbcc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{163.cce4c882.js.LICENSE.txt → 522.806db24f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{626.9d2c051c.js.LICENSE.txt → 597.0c5bd6dd.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{702.785cd635.js.LICENSE.txt → 865.cb917066.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.b89f8595.js.LICENSE.txt → 941.3bb54150.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.319c02cd.js.LICENSE.txt → lib-router.ecb51f08.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/data-transform.ts"],"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 type { YAXisComponentOption } from 'echarts';\nimport { LineSeriesOption, BarSeriesOption } from 'echarts/charts';\nimport {\n OPTIMIZED_MODE_SERIES_LIMIT,\n LegacyTimeSeries,\n EChartsDataFormat,\n EChartsValues,\n TimeSeriesOption,\n StepOptions,\n getCommonTimeScale,\n} from '@perses-dev/components';\nimport { useTimeSeriesQueries, PanelData } from '@perses-dev/plugin-system';\nimport { TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec';\nimport {\n DEFAULT_AREA_OPACITY,\n DEFAULT_CONNECT_NULLS,\n DEFAULT_LINE_WIDTH,\n DEFAULT_POINT_RADIUS,\n DEFAULT_Y_AXIS,\n POSITIVE_MIN_VALUE_MULTIPLIER,\n NEGATIVE_MIN_VALUE_MULTIPLIER,\n TimeSeriesChartVisualOptions,\n TimeSeriesChartYAxisOptions,\n LineStyleType,\n} from '../time-series-chart-model';\n\nexport type RunningQueriesState = ReturnType<typeof useTimeSeriesQueries>;\n\nexport const EMPTY_GRAPH_DATA: EChartsDataFormat = {\n timeSeries: [],\n xAxis: [],\n legendItems: [],\n};\n\nexport const HIDE_DATAPOINTS_LIMIT = 70;\n\nexport const BLUR_FADEOUT_OPACITY = 0.5;\n\n/**\n * Given a list of running queries, calculates a common time scale for use on\n * the x axis (i.e. start/end dates and a step that is divisible into all of\n * the queries' steps).\n */\nexport function getCommonTimeScaleForQueries(queries: Array<PanelData<TimeSeriesData>>): TimeScale | undefined {\n const seriesData = queries.map((query) => query.data);\n return getCommonTimeScale(seriesData);\n}\n\n/**\n * Gets ECharts line series option properties for regular trends\n */\nexport function getTimeSeries(\n id: string,\n datasetIndex: number,\n formattedName: string,\n visual: TimeSeriesChartVisualOptions,\n timeScale: TimeScale,\n paletteColor: string,\n querySettings?: { lineStyle?: LineStyleType; areaOpacity?: number; stack?: boolean },\n yAxisIndex?: number\n): TimeSeriesOption {\n const lineWidth = visual.lineWidth ?? DEFAULT_LINE_WIDTH;\n const pointRadius = visual.pointRadius ?? DEFAULT_POINT_RADIUS;\n const shouldStack = querySettings?.stack !== undefined ? querySettings.stack : visual.stack === 'all';\n\n // Shows datapoint symbols when selected time range is roughly 15 minutes or less\n const minuteMs = 60000;\n let showPoints = timeScale.rangeMs <= minuteMs * 15;\n // Allows overriding default behavior and opt-in to always show all symbols (can hurt performance)\n if (visual.showPoints === 'always') {\n showPoints = true;\n }\n\n if (visual.display === 'bar') {\n const series: BarSeriesOption = {\n type: 'bar',\n id: id,\n datasetIndex,\n name: formattedName,\n color: paletteColor,\n stack: shouldStack ? 'all' : undefined,\n yAxisIndex: yAxisIndex,\n label: {\n show: false,\n },\n };\n return series;\n }\n\n const series: LineSeriesOption = {\n type: 'line',\n id: id,\n datasetIndex,\n name: formattedName,\n connectNulls: visual.connectNulls ?? DEFAULT_CONNECT_NULLS,\n color: paletteColor,\n stack: shouldStack ? 'all' : undefined,\n yAxisIndex: yAxisIndex,\n sampling: 'lttb',\n progressiveThreshold: OPTIMIZED_MODE_SERIES_LIMIT, // https://echarts.apache.org/en/option.html#series-lines.progressiveThreshold\n showSymbol: showPoints,\n showAllSymbol: true,\n symbolSize: pointRadius,\n lineStyle: {\n width: lineWidth,\n type: (querySettings?.lineStyle ?? visual.lineStyle) as LineStyleType,\n },\n areaStyle: {\n opacity: querySettings?.areaOpacity ?? visual.areaOpacity ?? DEFAULT_AREA_OPACITY,\n },\n // https://echarts.apache.org/en/option.html#series-line.emphasis\n emphasis: {\n focus: 'series',\n disabled: visual.areaOpacity !== undefined && visual.areaOpacity > 0, // prevents flicker when moving cursor between shaded regions\n lineStyle: {\n width: lineWidth + 1,\n opacity: 1,\n type: visual.lineStyle,\n },\n },\n blur: {\n lineStyle: {\n width: lineWidth,\n opacity: BLUR_FADEOUT_OPACITY,\n type: visual.lineStyle,\n },\n },\n };\n return series;\n}\n\n/**\n * Gets threshold-specific line series styles\n * markLine cannot be used since it does not update yAxis max / min\n * and threshold data needs to show in the tooltip\n */\nexport function getThresholdSeries(name: string, threshold: StepOptions, seriesIndex: number): LineSeriesOption {\n return {\n type: 'line',\n name: name,\n id: name,\n datasetId: name,\n datasetIndex: seriesIndex,\n color: threshold.color,\n label: {\n show: false,\n },\n lineStyle: {\n type: 'dashed',\n width: 2,\n },\n emphasis: {\n focus: 'series',\n lineStyle: {\n width: 2.5,\n },\n },\n blur: {\n lineStyle: {\n opacity: BLUR_FADEOUT_OPACITY,\n },\n },\n };\n}\n\n/**\n * Converts percent threshold into absolute step value\n * If max is undefined, use the max value from time series data as default\n */\nexport function convertPercentThreshold(\n percent: number,\n data: LegacyTimeSeries[] | TimeSeries[],\n max?: number,\n min?: number\n): number {\n const percentDecimal = percent / 100;\n const adjustedMax = max ?? findMax(data);\n const adjustedMin = min ?? 0;\n const total = adjustedMax - adjustedMin;\n return percentDecimal * total + adjustedMin;\n}\n\nfunction findMax(data: LegacyTimeSeries[] | TimeSeries[]): number {\n let max = 0;\n if (data.length && data[0] !== undefined && (data as TimeSeries[])[0]?.values) {\n (data as TimeSeries[]).forEach((series) => {\n series.values.forEach((valueTuple: TimeSeriesValueTuple) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, value] = valueTuple;\n // Use the absolute value so percent thresholds compute correctly against\n // negated series (e.g. when `querySettings[].negativeY` is enabled).\n if (typeof value === 'number' && Math.abs(value) > max) {\n max = Math.abs(value);\n }\n });\n });\n } else {\n (data as LegacyTimeSeries[]).forEach((series) => {\n if (series.data !== undefined) {\n series.data.forEach((value: EChartsValues) => {\n if (typeof value === 'number' && Math.abs(value) > max) {\n max = Math.abs(value);\n }\n });\n }\n });\n }\n return max;\n}\n\n/**\n * Converts Perses panel yAxis from dashboard spec to ECharts supported yAxis options.\n * Handles both linear and logarithmic scales with appropriate min/max calculations.\n */\nexport function convertPanelYAxis(inputAxis: TimeSeriesChartYAxisOptions = {}): YAXisComponentOption {\n // Determine the appropriate min value based on scale type and user input\n let minValue: YAXisComponentOption['min'];\n if (inputAxis.logBase !== undefined) {\n // For logarithmic scales without explicit min:\n // Let ECharts auto-calculate the range based on data to avoid issues with\n // function-based calculations which can result in improper ranges (e.g., 1-10)\n minValue = undefined;\n } else if (inputAxis?.min !== undefined) {\n // User explicitly set a min value - use it for both linear and log scales\n minValue = inputAxis.min;\n } else {\n // For linear scales without explicit min:\n // Use dynamic calculation with padding for better visualization\n // https://echarts.apache.org/en/option.html#yAxis.min\n minValue = (value): number => {\n if (value.min >= 0 && value.min <= 1) {\n // Helps with PercentDecimal units, or datasets that return 0 or 1 booleans\n return 0;\n }\n\n // Note: We can tweak the MULTIPLIER constants if we want\n // TODO: Experiment with using a padding that is based on the difference between max value and min value\n if (value.min > 0) {\n return roundDown(value.min * POSITIVE_MIN_VALUE_MULTIPLIER);\n } else {\n return roundDown(value.min * NEGATIVE_MIN_VALUE_MULTIPLIER);\n }\n };\n }\n\n // Build the yAxis configuration\n const yAxis: YAXisComponentOption = {\n show: inputAxis?.show ?? DEFAULT_Y_AXIS.show,\n min: minValue,\n max: inputAxis?.max,\n };\n\n // Apply logarithmic scale settings if requested\n if (inputAxis.logBase !== undefined) {\n return {\n ...yAxis,\n type: 'log',\n logBase: inputAxis.logBase,\n };\n }\n\n return yAxis;\n}\n\n/**\n * Rounds down to nearest number with one significant digit.\n *\n * Examples:\n * 1. 675 --> 600\n * 2. 0.567 --> 0.5\n * 3. -12 --> -20\n */\nexport function roundDown(num: number): number {\n const magnitude = Math.floor(Math.log10(Math.abs(num)));\n const firstDigit = Math.floor(num / Math.pow(10, magnitude));\n return firstDigit * Math.pow(10, magnitude);\n}\n"],"names":["OPTIMIZED_MODE_SERIES_LIMIT","getCommonTimeScale","DEFAULT_AREA_OPACITY","DEFAULT_CONNECT_NULLS","DEFAULT_LINE_WIDTH","DEFAULT_POINT_RADIUS","DEFAULT_Y_AXIS","POSITIVE_MIN_VALUE_MULTIPLIER","NEGATIVE_MIN_VALUE_MULTIPLIER","EMPTY_GRAPH_DATA","timeSeries","xAxis","legendItems","HIDE_DATAPOINTS_LIMIT","BLUR_FADEOUT_OPACITY","getCommonTimeScaleForQueries","queries","seriesData","map","query","data","getTimeSeries","id","datasetIndex","formattedName","visual","timeScale","paletteColor","querySettings","yAxisIndex","lineWidth","pointRadius","shouldStack","stack","undefined","minuteMs","showPoints","rangeMs","display","series","type","name","color","label","show","connectNulls","sampling","progressiveThreshold","showSymbol","showAllSymbol","symbolSize","lineStyle","width","areaStyle","opacity","areaOpacity","emphasis","focus","disabled","blur","getThresholdSeries","threshold","seriesIndex","datasetId","convertPercentThreshold","percent","max","min","percentDecimal","adjustedMax","findMax","adjustedMin","total","length","values","forEach","valueTuple","_","value","Math","abs","convertPanelYAxis","inputAxis","minValue","logBase","roundDown","yAxis","num","magnitude","floor","log10","firstDigit","pow"],"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;AAIjC,SACEA,2BAA2B,EAM3BC,kBAAkB,QACb,yBAAyB;AAGhC,SACEC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,EAClBC,oBAAoB,EACpBC,cAAc,EACdC,6BAA6B,EAC7BC,6BAA6B,QAIxB,6BAA6B;AAIpC,OAAO,MAAMC,mBAAsC;IACjDC,YAAY,EAAE;IACdC,OAAO,EAAE;IACTC,aAAa,EAAE;AACjB,EAAE;AAEF,OAAO,MAAMC,wBAAwB,GAAG;AAExC,OAAO,MAAMC,uBAAuB,IAAI;AAExC;;;;CAIC,GACD,OAAO,SAASC,6BAA6BC,OAAyC;IACpF,MAAMC,aAAaD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;YACR9C,MAAM;YACN4C,SAASF,UAAUE,OAAO;QAC5B;IACF;IAEA,OAAOE;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASD,UAAUE,GAAW;IACnC,MAAMC,YAAYT,KAAKU,KAAK,CAACV,KAAKW,KAAK,CAACX,KAAKC,GAAG,CAACO;IACjD,MAAMI,aAAaZ,KAAKU,KAAK,CAACF,MAAMR,KAAKa,GAAG,CAAC,IAAIJ;IACjD,OAAOG,aAAaZ,KAAKa,GAAG,CAAC,IAAIJ;AACnC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/data-transform.ts"],"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 type {\n LegacyTimeSeries,\n EChartsDataFormat,\n EChartsValues,\n TimeSeriesOption,\n StepOptions,\n} from '@perses-dev/components';\nimport { OPTIMIZED_MODE_SERIES_LIMIT, getCommonTimeScale } from '@perses-dev/components';\nimport type { useTimeSeriesQueries, PanelData } from '@perses-dev/plugin-system';\nimport type { TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec';\nimport type { YAXisComponentOption } from 'echarts';\nimport type { LineSeriesOption, BarSeriesOption } from 'echarts/charts';\n\nimport type {\n TimeSeriesChartVisualOptions,\n TimeSeriesChartYAxisOptions,\n LineStyleType,\n} from '../time-series-chart-model';\nimport {\n DEFAULT_AREA_OPACITY,\n DEFAULT_CONNECT_NULLS,\n DEFAULT_LINE_WIDTH,\n DEFAULT_POINT_RADIUS,\n DEFAULT_Y_AXIS,\n POSITIVE_MIN_VALUE_MULTIPLIER,\n NEGATIVE_MIN_VALUE_MULTIPLIER,\n} from '../time-series-chart-model';\n\nexport type RunningQueriesState = ReturnType<typeof useTimeSeriesQueries>;\n\nexport const EMPTY_GRAPH_DATA: EChartsDataFormat = {\n timeSeries: [],\n xAxis: [],\n legendItems: [],\n};\n\nexport const HIDE_DATAPOINTS_LIMIT = 70;\n\nexport const BLUR_FADEOUT_OPACITY = 0.5;\n\n/**\n * Given a list of running queries, calculates a common time scale for use on\n * the x axis (i.e. start/end dates and a step that is divisible into all of\n * the queries' steps).\n */\nexport function getCommonTimeScaleForQueries(queries: Array<PanelData<TimeSeriesData>>): TimeScale | undefined {\n const seriesData = queries.map((query) => query.data);\n return getCommonTimeScale(seriesData);\n}\n\n/**\n * Gets ECharts line series option properties for regular trends\n */\nexport function getTimeSeries(\n id: string,\n datasetIndex: number,\n formattedName: string,\n visual: TimeSeriesChartVisualOptions,\n timeScale: TimeScale,\n paletteColor: string,\n querySettings?: { lineStyle?: LineStyleType; areaOpacity?: number; stack?: boolean },\n yAxisIndex?: number,\n): TimeSeriesOption {\n const lineWidth = visual.lineWidth ?? DEFAULT_LINE_WIDTH;\n const pointRadius = visual.pointRadius ?? DEFAULT_POINT_RADIUS;\n const shouldStack = querySettings?.stack !== undefined ? querySettings.stack : visual.stack === 'all';\n\n // Shows datapoint symbols when selected time range is roughly 15 minutes or less\n const minuteMs = 60000;\n let showPoints = timeScale.rangeMs <= minuteMs * 15;\n // Allows overriding default behavior and opt-in to always show all symbols (can hurt performance)\n if (visual.showPoints === 'always') {\n showPoints = true;\n }\n\n if (visual.display === 'bar') {\n const series: BarSeriesOption = {\n type: 'bar',\n id: id,\n datasetIndex,\n name: formattedName,\n color: paletteColor,\n stack: shouldStack ? 'all' : undefined,\n yAxisIndex: yAxisIndex,\n label: {\n show: false,\n },\n };\n return series;\n }\n\n const series: LineSeriesOption = {\n type: 'line',\n id: id,\n datasetIndex,\n name: formattedName,\n connectNulls: visual.connectNulls ?? DEFAULT_CONNECT_NULLS,\n color: paletteColor,\n stack: shouldStack ? 'all' : undefined,\n yAxisIndex: yAxisIndex,\n sampling: 'lttb',\n progressiveThreshold: OPTIMIZED_MODE_SERIES_LIMIT, // https://echarts.apache.org/en/option.html#series-lines.progressiveThreshold\n showSymbol: showPoints,\n showAllSymbol: true,\n symbolSize: pointRadius,\n lineStyle: {\n width: lineWidth,\n type: (querySettings?.lineStyle ?? visual.lineStyle) as LineStyleType,\n },\n areaStyle: {\n opacity: querySettings?.areaOpacity ?? visual.areaOpacity ?? DEFAULT_AREA_OPACITY,\n },\n // https://echarts.apache.org/en/option.html#series-line.emphasis\n emphasis: {\n focus: 'series',\n disabled: visual.areaOpacity !== undefined && visual.areaOpacity > 0, // prevents flicker when moving cursor between shaded regions\n lineStyle: {\n width: lineWidth + 1,\n opacity: 1,\n type: visual.lineStyle,\n },\n },\n blur: {\n lineStyle: {\n width: lineWidth,\n opacity: BLUR_FADEOUT_OPACITY,\n type: visual.lineStyle,\n },\n },\n };\n return series;\n}\n\n/**\n * Gets threshold-specific line series styles\n * markLine cannot be used since it does not update yAxis max / min\n * and threshold data needs to show in the tooltip\n */\nexport function getThresholdSeries(name: string, threshold: StepOptions, seriesIndex: number): LineSeriesOption {\n return {\n type: 'line',\n name: name,\n id: name,\n datasetId: name,\n datasetIndex: seriesIndex,\n color: threshold.color,\n label: {\n show: false,\n },\n lineStyle: {\n type: 'dashed',\n width: 2,\n },\n emphasis: {\n focus: 'series',\n lineStyle: {\n width: 2.5,\n },\n },\n blur: {\n lineStyle: {\n opacity: BLUR_FADEOUT_OPACITY,\n },\n },\n };\n}\n\n/**\n * Converts percent threshold into absolute step value\n * If max is undefined, use the max value from time series data as default\n */\nexport function convertPercentThreshold(\n percent: number,\n data: LegacyTimeSeries[] | TimeSeries[],\n max?: number,\n min?: number,\n): number {\n const percentDecimal = percent / 100;\n const adjustedMax = max ?? findMax(data);\n const adjustedMin = min ?? 0;\n const total = adjustedMax - adjustedMin;\n return percentDecimal * total + adjustedMin;\n}\n\nfunction findMax(data: LegacyTimeSeries[] | TimeSeries[]): number {\n let max = 0;\n if (data.length && data[0] !== undefined && (data as TimeSeries[])[0]?.values) {\n (data as TimeSeries[]).forEach((series) => {\n series.values.forEach((valueTuple: TimeSeriesValueTuple) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, value] = valueTuple;\n // Use the absolute value so percent thresholds compute correctly against\n // negated series (e.g. when `querySettings[].negativeY` is enabled).\n if (typeof value === 'number' && Math.abs(value) > max) {\n max = Math.abs(value);\n }\n });\n });\n } else {\n (data as LegacyTimeSeries[]).forEach((series) => {\n if (series.data !== undefined) {\n series.data.forEach((value: EChartsValues) => {\n if (typeof value === 'number' && Math.abs(value) > max) {\n max = Math.abs(value);\n }\n });\n }\n });\n }\n return max;\n}\n\n/**\n * Converts Perses panel yAxis from dashboard spec to ECharts supported yAxis options.\n * Handles both linear and logarithmic scales with appropriate min/max calculations.\n */\nexport function convertPanelYAxis(inputAxis: TimeSeriesChartYAxisOptions = {}): YAXisComponentOption {\n // Determine the appropriate min value based on scale type and user input\n let minValue: YAXisComponentOption['min'];\n if (inputAxis.logBase !== undefined) {\n // For logarithmic scales without explicit min:\n // Let ECharts auto-calculate the range based on data to avoid issues with\n // function-based calculations which can result in improper ranges (e.g., 1-10)\n minValue = undefined;\n } else if (inputAxis?.min !== undefined) {\n // User explicitly set a min value - use it for both linear and log scales\n minValue = inputAxis.min;\n } else {\n // For linear scales without explicit min:\n // Use dynamic calculation with padding for better visualization\n // https://echarts.apache.org/en/option.html#yAxis.min\n minValue = (value): number => {\n if (value.min >= 0 && value.min <= 1) {\n // Helps with PercentDecimal units, or datasets that return 0 or 1 booleans\n return 0;\n }\n\n // Note: We can tweak the MULTIPLIER constants if we want\n // TODO: Experiment with using a padding that is based on the difference between max value and min value\n if (value.min > 0) {\n return roundDown(value.min * POSITIVE_MIN_VALUE_MULTIPLIER);\n } else {\n return roundDown(value.min * NEGATIVE_MIN_VALUE_MULTIPLIER);\n }\n };\n }\n\n // Build the yAxis configuration\n const yAxis: YAXisComponentOption = {\n show: inputAxis?.show ?? DEFAULT_Y_AXIS.show,\n min: minValue,\n max: inputAxis?.max,\n };\n\n // Apply logarithmic scale settings if requested\n if (inputAxis.logBase !== undefined) {\n return {\n ...yAxis,\n type: 'log',\n logBase: inputAxis.logBase,\n };\n }\n\n return yAxis;\n}\n\n/**\n * Rounds down to nearest number with one significant digit.\n *\n * Examples:\n * 1. 675 --> 600\n * 2. 0.567 --> 0.5\n * 3. -12 --> -20\n */\nexport function roundDown(num: number): number {\n const magnitude = Math.floor(Math.log10(Math.abs(num)));\n const firstDigit = Math.floor(num / Math.pow(10, magnitude));\n return Number((firstDigit * Math.pow(10, magnitude)).toPrecision(1));\n}\n"],"names":["OPTIMIZED_MODE_SERIES_LIMIT","getCommonTimeScale","DEFAULT_AREA_OPACITY","DEFAULT_CONNECT_NULLS","DEFAULT_LINE_WIDTH","DEFAULT_POINT_RADIUS","DEFAULT_Y_AXIS","POSITIVE_MIN_VALUE_MULTIPLIER","NEGATIVE_MIN_VALUE_MULTIPLIER","EMPTY_GRAPH_DATA","timeSeries","xAxis","legendItems","HIDE_DATAPOINTS_LIMIT","BLUR_FADEOUT_OPACITY","getCommonTimeScaleForQueries","queries","seriesData","map","query","data","getTimeSeries","id","datasetIndex","formattedName","visual","timeScale","paletteColor","querySettings","yAxisIndex","lineWidth","pointRadius","shouldStack","stack","undefined","minuteMs","showPoints","rangeMs","display","series","type","name","color","label","show","connectNulls","sampling","progressiveThreshold","showSymbol","showAllSymbol","symbolSize","lineStyle","width","areaStyle","opacity","areaOpacity","emphasis","focus","disabled","blur","getThresholdSeries","threshold","seriesIndex","datasetId","convertPercentThreshold","percent","max","min","percentDecimal","adjustedMax","findMax","adjustedMin","total","length","values","forEach","valueTuple","_","value","Math","abs","convertPanelYAxis","inputAxis","minValue","logBase","roundDown","yAxis","num","magnitude","floor","log10","firstDigit","pow","Number","toPrecision"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;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QAC1C,gEAAgE;QAChE,sDAAsD;QACtDgB,WAAW,CAACL;YACV,IAAIA,MAAMX,GAAG,IAAI,KAAKW,MAAMX,GAAG,IAAI,GAAG;gBACpC,2EAA2E;gBAC3E,OAAO;YACT;YAEA,yDAAyD;YACzD,wGAAwG;YACxG,IAAIW,MAAMX,GAAG,GAAG,GAAG;gBACjB,OAAOkB,UAAUP,MAAMX,GAAG,GAAG5D;YAC/B,OAAO;gBACL,OAAO8E,UAAUP,MAAMX,GAAG,GAAG3D;YAC/B;QACF;IACF;IAEA,gCAAgC;IAChC,MAAM8E,QAA8B;QAClC1C,MAAMsC,WAAWtC,QAAQtC,eAAesC,IAAI;QAC5CuB,KAAKgB;QACLjB,KAAKgB,WAAWhB;IAClB;IAEA,gDAAgD;IAChD,IAAIgB,UAAUE,OAAO,KAAKlD,WAAW;QACnC,OAAO;YACL,GAAGoD,KAAK;YACR9C,MAAM;YACN4C,SAASF,UAAUE,OAAO;QAC5B;IACF;IAEA,OAAOE;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASD,UAAUE,GAAW;IACnC,MAAMC,YAAYT,KAAKU,KAAK,CAACV,KAAKW,KAAK,CAACX,KAAKC,GAAG,CAACO;IACjD,MAAMI,aAAaZ,KAAKU,KAAK,CAACF,MAAMR,KAAKa,GAAG,CAAC,IAAIJ;IACjD,OAAOK,OAAO,AAACF,CAAAA,aAAaZ,KAAKa,GAAG,CAAC,IAAIJ,UAAS,EAAGM,WAAW,CAAC;AACnE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QuerySettingsOptions, TimeSeriesChartVisualOptions } from '../time-series-chart-model';
|
|
1
|
+
import type { QuerySettingsOptions, TimeSeriesChartVisualOptions } from '../time-series-chart-model';
|
|
2
2
|
export interface SeriesColorProps {
|
|
3
3
|
categoricalPalette: string[];
|
|
4
4
|
visual: TimeSeriesChartVisualOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette-gen.d.ts","sourceRoot":"","sources":["../../../src/utils/palette-gen.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"palette-gen.d.ts","sourceRoot":"","sources":["../../../src/utils/palette-gen.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAGrG,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,MAAM,EAAE,4BAA4B,CAAC;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAgC9D;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"}
|
package/lib/utils/palette-gen.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { getConsistentColor } from
|
|
13
|
+
import { getConsistentColor } from "./palette.js";
|
|
14
14
|
/**
|
|
15
15
|
* Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative
|
|
16
16
|
*/ export function getSeriesColor(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/palette-gen.ts"],"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 { QuerySettingsOptions, TimeSeriesChartVisualOptions } from '../time-series-chart-model';\nimport { getConsistentColor } from './palette';\n\nexport interface SeriesColorProps {\n categoricalPalette: string[];\n visual: TimeSeriesChartVisualOptions;\n muiPrimaryColor: string;\n seriesName: string;\n seriesIndex: number;\n querySettings?: QuerySettingsOptions;\n queryHasMultipleResults?: boolean;\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 {\n categoricalPalette,\n visual,\n muiPrimaryColor,\n seriesName,\n seriesIndex,\n querySettings,\n queryHasMultipleResults,\n } = props;\n\n // Use color overrides defined in query settings in priority, if applicable\n if (querySettings) {\n if (querySettings.colorMode === 'fixed' && querySettings.colorValue) {\n return querySettings.colorValue;\n } else if (querySettings.colorMode === 'fixed-single' && !queryHasMultipleResults && querySettings.colorValue) {\n return querySettings.colorValue;\n }\n }\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 // Explicit way to always cycle through classical palette instead of changing when based on number of series.\n if (visual.palette?.mode === 'categorical') {\n return getCategoricalPaletteColor(categoricalPalette, seriesIndex, fallbackColor);\n }\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","visual","muiPrimaryColor","seriesName","seriesIndex","querySettings","queryHasMultipleResults","colorMode","colorValue","fallbackColor","Array","isArray","palette","mode","getCategoricalPaletteColor","getAutoPaletteColor","name","generatedColor","getConsistentSeriesNameColor","undefined","paletteTotalColors","length","paletteIndex","seriesColor","inputString","toLowerCase","includes"],"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;AAGjC,SAASA,kBAAkB,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/palette-gen.ts"],"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 type { QuerySettingsOptions, TimeSeriesChartVisualOptions } from '../time-series-chart-model';\nimport { getConsistentColor } from './palette';\n\nexport interface SeriesColorProps {\n categoricalPalette: string[];\n visual: TimeSeriesChartVisualOptions;\n muiPrimaryColor: string;\n seriesName: string;\n seriesIndex: number;\n querySettings?: QuerySettingsOptions;\n queryHasMultipleResults?: boolean;\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 {\n categoricalPalette,\n visual,\n muiPrimaryColor,\n seriesName,\n seriesIndex,\n querySettings,\n queryHasMultipleResults,\n } = props;\n\n // Use color overrides defined in query settings in priority, if applicable\n if (querySettings) {\n if (querySettings.colorMode === 'fixed' && querySettings.colorValue) {\n return querySettings.colorValue;\n } else if (querySettings.colorMode === 'fixed-single' && !queryHasMultipleResults && querySettings.colorValue) {\n return querySettings.colorValue;\n }\n }\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 // Explicit way to always cycle through classical palette instead of changing when based on number of series.\n if (visual.palette?.mode === 'categorical') {\n return getCategoricalPaletteColor(categoricalPalette, seriesIndex, fallbackColor);\n }\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","visual","muiPrimaryColor","seriesName","seriesIndex","querySettings","queryHasMultipleResults","colorMode","colorValue","fallbackColor","Array","isArray","palette","mode","getCategoricalPaletteColor","getAutoPaletteColor","name","generatedColor","getConsistentSeriesNameColor","undefined","paletteTotalColors","length","paletteIndex","seriesColor","inputString","toLowerCase","includes"],"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;AAGjC,SAASA,kBAAkB,QAAQ,eAAY;AAY/C;;CAEC,GACD,OAAO,SAASC,eAAeC,KAAuB;IACpD,MAAM,EACJC,kBAAkB,EAClBC,MAAM,EACNC,eAAe,EACfC,UAAU,EACVC,WAAW,EACXC,aAAa,EACbC,uBAAuB,EACxB,GAAGP;IAEJ,2EAA2E;IAC3E,IAAIM,eAAe;QACjB,IAAIA,cAAcE,SAAS,KAAK,WAAWF,cAAcG,UAAU,EAAE;YACnE,OAAOH,cAAcG,UAAU;QACjC,OAAO,IAAIH,cAAcE,SAAS,KAAK,kBAAkB,CAACD,2BAA2BD,cAAcG,UAAU,EAAE;YAC7G,OAAOH,cAAcG,UAAU;QACjC;IACF;IAEA,kGAAkG;IAClG,MAAMC,gBACJC,MAAMC,OAAO,CAACX,uBAAuBA,kBAAkB,CAAC,EAAE,GACrDA,kBAAkB,CAAC,EAAE,CAAY,6DAA6D;OAC/FE;IAEN,6GAA6G;IAC7G,IAAID,OAAOW,OAAO,EAAEC,SAAS,eAAe;QAC1C,OAAOC,2BAA2Bd,oBAAoBI,aAAaK;IACrE;IAEA,OAAOM,oBAAoBZ,YAAYM;AACzC;AAEA;;;CAGC,GACD,OAAO,SAASM,oBAAoBC,IAAY,EAAEP,aAAqB;IACrE,qEAAqE;IACrE,MAAMQ,iBAAiBC,6BAA6BF;IACpD,OAAOC,kBAAkBR;AAC3B;AAEA;;CAEC,GACD,OAAO,SAASK,2BAA2BF,OAAiB,EAAER,WAAmB,EAAEK,aAAqB;IACtG,IAAIG,YAAYO,WAAW;QACzB,OAAOV;IACT;IACA,+CAA+C;IAC/C,MAAMW,qBAAqBR,QAAQS,MAAM,IAAI;IAC7C,MAAMC,eAAelB,cAAcgB;IACnC,0CAA0C;IAC1C,MAAMG,cAAcX,OAAO,CAACU,aAAa,IAAIb;IAC7C,OAAOc;AACT;AAEA;;CAEC,GACD,OAAO,SAASL,6BAA6BM,WAAmB;IAC9D,OAAO3B,mBAAmB2B,aAAaA,YAAYC,WAAW,GAAGC,QAAQ,CAAC;AAC5E"}
|
package/lib/utils/palette.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import ColorHash from
|
|
13
|
+
import ColorHash from "color-hash";
|
|
14
14
|
// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
|
|
15
15
|
// More info: https://github.com/zenozeng/color-hash#custom-hue
|
|
16
16
|
// Picked min of 20 and max of 360 to exclude common threshold colors (red).
|
package/lib/utils/palette.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/palette.ts"],"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 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[]
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/palette.ts"],"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 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,+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,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"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { formatWithTimeZone } from
|
|
13
|
+
import { formatWithTimeZone } from "@perses-dev/components";
|
|
14
14
|
const DAY_MS = 86400000;
|
|
15
15
|
const MONTH_MS = 2629440000;
|
|
16
16
|
const YEAR_MS = 31536000000;
|
package/mf-manifest.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"name": "TimeSeriesChart",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.14.0-beta.
|
|
8
|
+
"buildVersion": "0.14.0-beta.2",
|
|
9
9
|
"buildName": "@perses-dev/timeseries-chart-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/TimeSeriesChart.
|
|
12
|
+
"name": "__mf/js/TimeSeriesChart.b9caac04.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"zip": "",
|
|
20
20
|
"api": ""
|
|
21
21
|
},
|
|
22
|
-
"globalName": "
|
|
22
|
+
"globalName": "TimeSeriesChart_0_14_0_beta_2",
|
|
23
23
|
"pluginVersion": "2.6.0",
|
|
24
|
-
"getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/TimeSeriesChart/\"; }"
|
|
24
|
+
"getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/TimeSeriesChart~0.14.0-beta.2/\"; }"
|
|
25
25
|
},
|
|
26
26
|
"shared": [
|
|
27
27
|
{
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"js": {
|
|
35
35
|
"async": [],
|
|
36
36
|
"sync": [
|
|
37
|
-
"__mf/js/async/274.
|
|
37
|
+
"__mf/js/async/274.e4ed32f7.js"
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"css": {
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"js": {
|
|
55
55
|
"async": [],
|
|
56
56
|
"sync": [
|
|
57
|
-
"__mf/js/async/235.
|
|
58
|
-
"__mf/js/async/616.
|
|
57
|
+
"__mf/js/async/235.76fd7af2.js",
|
|
58
|
+
"__mf/js/async/616.804d525d.js"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"css": {
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"js": {
|
|
76
76
|
"async": [],
|
|
77
77
|
"sync": [
|
|
78
|
-
"__mf/js/async/587.
|
|
79
|
-
"__mf/js/async/968.
|
|
78
|
+
"__mf/js/async/587.828c454a.js",
|
|
79
|
+
"__mf/js/async/968.2dd830b3.js"
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
82
|
"css": {
|
|
@@ -89,20 +89,20 @@
|
|
|
89
89
|
{
|
|
90
90
|
"id": "TimeSeriesChart:@perses-dev/components",
|
|
91
91
|
"name": "@perses-dev/components",
|
|
92
|
-
"version": "0.55.0-beta.
|
|
92
|
+
"version": "0.55.0-beta.6",
|
|
93
93
|
"singleton": true,
|
|
94
|
-
"requiredVersion": "^0.55.0-beta.
|
|
94
|
+
"requiredVersion": "^0.55.0-beta.6",
|
|
95
95
|
"assets": {
|
|
96
96
|
"js": {
|
|
97
97
|
"async": [],
|
|
98
98
|
"sync": [
|
|
99
|
-
"__mf/js/async/
|
|
99
|
+
"__mf/js/async/463.f5dc7759.js"
|
|
100
100
|
]
|
|
101
101
|
},
|
|
102
102
|
"css": {
|
|
103
103
|
"async": [],
|
|
104
104
|
"sync": [
|
|
105
|
-
"__mf/css/async/
|
|
105
|
+
"__mf/css/async/463.85c2cbf6.css"
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
108
|
},
|
|
@@ -111,14 +111,14 @@
|
|
|
111
111
|
{
|
|
112
112
|
"id": "TimeSeriesChart:@perses-dev/dashboards",
|
|
113
113
|
"name": "@perses-dev/dashboards",
|
|
114
|
-
"version": "0.55.0-beta.
|
|
114
|
+
"version": "0.55.0-beta.6",
|
|
115
115
|
"singleton": true,
|
|
116
|
-
"requiredVersion": "^0.55.0-beta.
|
|
116
|
+
"requiredVersion": "^0.55.0-beta.6",
|
|
117
117
|
"assets": {
|
|
118
118
|
"js": {
|
|
119
119
|
"async": [],
|
|
120
120
|
"sync": [
|
|
121
|
-
"__mf/js/async/
|
|
121
|
+
"__mf/js/async/522.806db24f.js"
|
|
122
122
|
]
|
|
123
123
|
},
|
|
124
124
|
"css": {
|
|
@@ -131,14 +131,14 @@
|
|
|
131
131
|
{
|
|
132
132
|
"id": "TimeSeriesChart:@perses-dev/plugin-system",
|
|
133
133
|
"name": "@perses-dev/plugin-system",
|
|
134
|
-
"version": "0.55.0-beta.
|
|
134
|
+
"version": "0.55.0-beta.6",
|
|
135
135
|
"singleton": true,
|
|
136
|
-
"requiredVersion": "^0.55.0-beta.
|
|
136
|
+
"requiredVersion": "^0.55.0-beta.6",
|
|
137
137
|
"assets": {
|
|
138
138
|
"js": {
|
|
139
139
|
"async": [],
|
|
140
140
|
"sync": [
|
|
141
|
-
"__mf/js/async/
|
|
141
|
+
"__mf/js/async/612.b2f31132.js"
|
|
142
142
|
]
|
|
143
143
|
},
|
|
144
144
|
"css": {
|
|
@@ -158,27 +158,7 @@
|
|
|
158
158
|
"js": {
|
|
159
159
|
"async": [],
|
|
160
160
|
"sync": [
|
|
161
|
-
"__mf/js/async/192.
|
|
162
|
-
]
|
|
163
|
-
},
|
|
164
|
-
"css": {
|
|
165
|
-
"async": [],
|
|
166
|
-
"sync": []
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
"fallback": ""
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"id": "TimeSeriesChart:echarts",
|
|
173
|
-
"name": "echarts",
|
|
174
|
-
"version": "5.5.0",
|
|
175
|
-
"singleton": true,
|
|
176
|
-
"requiredVersion": "^undefined",
|
|
177
|
-
"assets": {
|
|
178
|
-
"js": {
|
|
179
|
-
"async": [],
|
|
180
|
-
"sync": [
|
|
181
|
-
"__mf/js/async/873.04a201bf.js"
|
|
161
|
+
"__mf/js/async/192.66c6659d.js"
|
|
182
162
|
]
|
|
183
163
|
},
|
|
184
164
|
"css": {
|
|
@@ -198,7 +178,7 @@
|
|
|
198
178
|
"js": {
|
|
199
179
|
"async": [],
|
|
200
180
|
"sync": [
|
|
201
|
-
"__mf/js/async/392.
|
|
181
|
+
"__mf/js/async/392.8cb3dcaa.js"
|
|
202
182
|
]
|
|
203
183
|
},
|
|
204
184
|
"css": {
|
|
@@ -218,7 +198,7 @@
|
|
|
218
198
|
"js": {
|
|
219
199
|
"async": [],
|
|
220
200
|
"sync": [
|
|
221
|
-
"__mf/js/async/470.
|
|
201
|
+
"__mf/js/async/470.beedcbcc.js"
|
|
222
202
|
]
|
|
223
203
|
},
|
|
224
204
|
"css": {
|
|
@@ -238,27 +218,7 @@
|
|
|
238
218
|
"js": {
|
|
239
219
|
"async": [],
|
|
240
220
|
"sync": [
|
|
241
|
-
"__mf/js/async/121.
|
|
242
|
-
]
|
|
243
|
-
},
|
|
244
|
-
"css": {
|
|
245
|
-
"async": [],
|
|
246
|
-
"sync": []
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
"fallback": ""
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
"id": "TimeSeriesChart:date-fns-tz",
|
|
253
|
-
"name": "date-fns-tz",
|
|
254
|
-
"version": "3.2.0",
|
|
255
|
-
"singleton": true,
|
|
256
|
-
"requiredVersion": "^3.2.0",
|
|
257
|
-
"assets": {
|
|
258
|
-
"js": {
|
|
259
|
-
"async": [],
|
|
260
|
-
"sync": [
|
|
261
|
-
"__mf/js/async/978.a9865b23.js"
|
|
221
|
+
"__mf/js/async/121.fde1320e.js"
|
|
262
222
|
]
|
|
263
223
|
},
|
|
264
224
|
"css": {
|
|
@@ -277,31 +237,27 @@
|
|
|
277
237
|
"assets": {
|
|
278
238
|
"js": {
|
|
279
239
|
"sync": [
|
|
280
|
-
"__mf/js/async/955.
|
|
281
|
-
"__mf/js/async/
|
|
282
|
-
"__mf/js/async/
|
|
283
|
-
"__mf/js/async/
|
|
284
|
-
"__mf/js/async/
|
|
285
|
-
"__mf/js/async/__federation_expose_TimeSeriesChart.0f989a8c.js"
|
|
240
|
+
"__mf/js/async/955.52ca0671.js",
|
|
241
|
+
"__mf/js/async/182.9e1e293f.js",
|
|
242
|
+
"__mf/js/async/865.cb917066.js",
|
|
243
|
+
"__mf/js/async/724.f74ffa12.js",
|
|
244
|
+
"__mf/js/async/__federation_expose_TimeSeriesChart.4ddb01e0.js"
|
|
286
245
|
],
|
|
287
246
|
"async": [
|
|
288
|
-
"__mf/js/async/
|
|
289
|
-
"__mf/js/async/
|
|
290
|
-
"__mf/js/async/
|
|
291
|
-
"__mf/js/async/
|
|
292
|
-
"__mf/js/async/
|
|
293
|
-
"__mf/js/async/
|
|
294
|
-
"__mf/js/async/
|
|
295
|
-
"__mf/js/async/
|
|
296
|
-
"__mf/js/async/491.85194549.js",
|
|
297
|
-
"__mf/js/async/187.f5e8932b.js",
|
|
298
|
-
"__mf/js/async/177.2fef2962.js"
|
|
247
|
+
"__mf/js/async/730.058dea58.js",
|
|
248
|
+
"__mf/js/async/384.f40367cc.js",
|
|
249
|
+
"__mf/js/async/525.8b92c616.js",
|
|
250
|
+
"__mf/js/async/663.892b9ad5.js",
|
|
251
|
+
"__mf/js/async/lib-router.ecb51f08.js",
|
|
252
|
+
"__mf/js/async/356.52455d93.js",
|
|
253
|
+
"__mf/js/async/597.0c5bd6dd.js",
|
|
254
|
+
"__mf/js/async/700.25c7e5dd.js"
|
|
299
255
|
]
|
|
300
256
|
},
|
|
301
257
|
"css": {
|
|
302
258
|
"sync": [],
|
|
303
259
|
"async": [
|
|
304
|
-
"__mf/css/async/
|
|
260
|
+
"__mf/css/async/463.85c2cbf6.css"
|
|
305
261
|
]
|
|
306
262
|
}
|
|
307
263
|
},
|