(config: PanelProps, rawData: SeriesData[], colorMode, inactiveSeries)
| 37 | }) |
| 38 | |
| 39 | export const parseOptions = (config: PanelProps, rawData: SeriesData[], colorMode, inactiveSeries):uPlot.Options => { |
| 40 | |
| 41 | |
| 42 | const textColor = colorMode == ColorMode.Light ? customColors.textColorRGB.light : customColors.textColorRGB.dark |
| 43 | const axesColor = colorMode == ColorMode.Light ? "rgba(0, 10, 23, 0.09)" : "rgba(240, 250, 255, 0.09)" |
| 44 | |
| 45 | // build series |
| 46 | const series = [] |
| 47 | // push time series option |
| 48 | series.push({ |
| 49 | label: "Time", |
| 50 | |
| 51 | }) |
| 52 | |
| 53 | // show its own units for negative-y series |
| 54 | const negativeYTarget = config.panel.overrides.find(override => findRuleInOverride(override, GraphRules.SeriesNegativeY)) |
| 55 | const negativeYUnit = findRuleInOverride(negativeYTarget, GraphRules.SeriesUnit) |
| 56 | |
| 57 | const yAxis = [{ |
| 58 | show: config.panel.plugins.graph.axis.showY, |
| 59 | grid: { |
| 60 | show: config.panel.plugins.graph.axis?.showGrid, |
| 61 | width: 0.5, |
| 62 | stroke: axesColor |
| 63 | }, |
| 64 | ticks: { show: true, stroke: 'rgba(0, 10, 23, 0.09)', width: 0.5, size: 4 }, |
| 65 | scale: 'y', |
| 66 | stroke: textColor, |
| 67 | space: axisSpace, |
| 68 | size: ((self, values, axisIdx) => { |
| 69 | return calculateAxisSize(self, values, axisIdx); |
| 70 | }), |
| 71 | values: (u, vals) => vals.map(v => { |
| 72 | // console.log("here33333:",u, vals) |
| 73 | let units = config.panel.plugins.graph.value.units |
| 74 | if (negativeYTarget && negativeYUnit && v < 0) { |
| 75 | units = negativeYUnit.units |
| 76 | } |
| 77 | |
| 78 | return formatUnit(v, units, config.panel.plugins.graph.value.decimal) ?? round(v, config.panel.plugins.graph.value.decimal) |
| 79 | }), |
| 80 | units: config.panel.plugins.graph.value.units, |
| 81 | side: 3 |
| 82 | }] |
| 83 | |
| 84 | rawData.forEach((d, i) => { |
| 85 | const override: OverrideItem = findOverride(config.panel, d.rawName) |
| 86 | let opacity = config.panel.plugins.graph.styles.fillOpacity / 100 |
| 87 | const fillOverride = findRuleInOverride(override, GraphRules.SeriesFill) |
| 88 | if (!isEmpty(fillOverride)) { |
| 89 | opacity = fillOverride / 100 |
| 90 | } |
| 91 | |
| 92 | let style = config.panel.plugins.graph.styles.style |
| 93 | let styleOverride = findRuleInOverride(override, GraphRules.SeriesStyle) |
| 94 | if (styleOverride) { |
| 95 | style = styleOverride |
| 96 | } |
no test coverage detected