Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions timeserieschart/schemas/time-series.cue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ spec: close({
lineStyle?: #lineStyle
areaOpacity?: #areaOpacity
format?: common.#format
stack?: bool
}]

#lineStyle: "solid" | "dashed" | "dotted"
Expand Down
1 change: 1 addition & 0 deletions timeserieschart/sdk/go/time-series.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type QuerySettingsItem struct {
LineStyle string `json:"lineStyle,omitempty" yaml:"lineStyle,omitempty"`
AreaOpacity float64 `json:"areaOpacity,omitempty" yaml:"areaOpacity,omitempty"`
Format *common.Format `json:"format,omitempty" yaml:"format,omitempty"`
Stack *bool `json:"stack,omitempty" yaml:"stack,omitempty"`
}

type Option func(plugin *Builder) error
Expand Down
45 changes: 43 additions & 2 deletions timeserieschart/src/QuerySettingsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
MenuItem,
Slider,
Stack,
Switch,
TextField,
ToggleButton,
ToggleButtonGroup,
Expand Down Expand Up @@ -217,6 +218,24 @@
});
};

const addStack = (i: number): void => {
updateQuerySettings(i, (qs) => {
qs.stack = false;
});
};

const removeStack = (i: number): void => {
updateQuerySettings(i, (qs) => {
qs.stack = undefined;
});
};

const handleStackChange = (i: number, checked: boolean): void => {
updateQuerySettings(i, (qs) => {
qs.stack = checked;
});
};

const handleFormatChange = (i: number, format?: FormatOptions): void => {
updateQuerySettings(i, (qs) => {
qs.format = format;
Expand Down Expand Up @@ -287,6 +306,9 @@
onAddFormat={() => addFormat(i)}
onRemoveFormat={() => removeFormat(i)}
onFormatChange={(format) => handleFormatChange(i, format)}
onAddStack={() => addStack(i)}
onRemoveStack={() => removeStack(i)}
onStackChange={(checked) => handleStackChange(i, checked)}
/>
))
)}
Expand Down Expand Up @@ -319,10 +341,13 @@
onAddFormat: () => void;
onRemoveFormat: () => void;
onFormatChange: (format?: FormatOptions) => void;
onAddStack: () => void;
onRemoveStack: () => void;
onStackChange: (checked: boolean) => void;
}

function QuerySettingsInput({
querySettings: { queryIndex, colorMode, colorValue, lineStyle, areaOpacity, format },
querySettings: { queryIndex, colorMode, colorValue, lineStyle, areaOpacity, format, stack },
availableQueryIndexes,
onQueryIndexChange,
onColorModeChange,
Expand All @@ -340,6 +365,9 @@
onAddFormat,
onRemoveFormat,
onFormatChange,
onAddStack,
onRemoveStack,
onStackChange,
}: QuerySettingsInputProps): ReactElement {
// current query index should also be selectable
const selectableQueryIndexes = availableQueryIndexes.concat(queryIndex).sort((a, b) => a - b);
Expand All @@ -354,8 +382,9 @@
if (!lineStyle) options.push({ key: 'lineStyle', label: 'Line Style', action: onAddLineStyle });
if (areaOpacity === undefined) options.push({ key: 'opacity', label: 'Opacity', action: onAddAreaOpacity });
if (format === undefined) options.push({ key: 'format', label: 'Format', action: onAddFormat });
if (stack === undefined) options.push({ key: 'stack', label: 'Stack', action: onAddStack });
return options;
}, [colorMode, lineStyle, areaOpacity, format, onAddColor, onAddLineStyle, onAddAreaOpacity, onAddFormat]);
}, [colorMode, lineStyle, areaOpacity, format, stack, onAddColor, onAddLineStyle, onAddAreaOpacity, onAddFormat, onAddStack]);

Check failure on line 387 in timeserieschart/src/QuerySettingsEditor.tsx

View workflow job for this annotation

GitHub Actions / lint-npm

Replace `colorMode,·lineStyle,·areaOpacity,·format,·stack,·onAddColor,·onAddLineStyle,·onAddAreaOpacity,·onAddFormat,·onAddStack` with `⏎····colorMode,⏎····lineStyle,⏎····areaOpacity,⏎····format,⏎····stack,⏎····onAddColor,⏎····onAddLineStyle,⏎····onAddAreaOpacity,⏎····onAddFormat,⏎····onAddStack,⏎··`

const handleAddMenuClick = (event: React.MouseEvent<HTMLElement>): void => {
if (availableOptions.length === 1 && availableOptions[0]) {
Expand Down Expand Up @@ -472,6 +501,18 @@
</SettingsSection>
)}

{/* Stack section */}
{stack !== undefined && (
<SettingsSection label="Stack" onRemove={onRemoveStack}>
<Switch
checked={stack}
onChange={(e) => onStackChange(e.target.checked)}
slotProps={{ input: { 'aria-label': 'stack override' } }}
/>
<Box sx={{ flexGrow: 1 }} />
</SettingsSection>
)}

{/* Add Options Button - only show if there are available options */}
{availableOptions.length > 0 && (
<>
Expand Down
2 changes: 1 addition & 1 deletion timeserieschart/src/TimeSeriesChartBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
TooltipComponent,
} from 'echarts/components';
import { CanvasRenderer } from 'echarts/renderers';
import { getCommonTimeScale } from '@perses-dev/components';

Check failure on line 40 in timeserieschart/src/TimeSeriesChartBase.tsx

View workflow job for this annotation

GitHub Actions / lint-npm

'/home/runner/work/plugins/plugins/node_modules/@perses-dev/components/dist/index.js' imported multiple times
import {
ChartInstance,
Comment thread
SoWieMarkus marked this conversation as resolved.
ChartInstanceFocusOpts,
Expand All @@ -48,7 +49,6 @@
enableDataZoom,
FormatOptions,
getClosestTimestamp,
getCommonTimeScale,
getFormattedAxis,
getPointInGrid,
OnEventsType,
Expand All @@ -59,7 +59,7 @@
useChartsContext,
useTimeZone,
ZoomEventData,
} from '@perses-dev/components';

Check failure on line 62 in timeserieschart/src/TimeSeriesChartBase.tsx

View workflow job for this annotation

GitHub Actions / lint-npm

'/home/runner/work/plugins/plugins/node_modules/@perses-dev/components/dist/index.js' imported multiple times
import { DatasetOption } from 'echarts/types/dist/shared';
import { TimeScale, TimeSeries } from '@perses-dev/spec';
import { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter';
Expand Down
2 changes: 1 addition & 1 deletion timeserieschart/src/TimeSeriesChartPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
DEFAULT_LEGEND,
StepOptions,
formatValue,
getTimeSeriesValues,
} from '@perses-dev/components';

Check failure on line 45 in timeserieschart/src/TimeSeriesChartPanel.tsx

View workflow job for this annotation

GitHub Actions / lint-npm

'/home/runner/work/plugins/plugins/node_modules/@perses-dev/components/dist/index.js' imported multiple times
import { getTimeSeriesValues } from '@perses-dev/components';

Check failure on line 46 in timeserieschart/src/TimeSeriesChartPanel.tsx

View workflow job for this annotation

GitHub Actions / lint-npm

'/home/runner/work/plugins/plugins/node_modules/@perses-dev/components/dist/index.js' imported multiple times
import { TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec';
import {
Comment thread
SoWieMarkus marked this conversation as resolved.
TimeSeriesChartOptions,
Expand Down
2 changes: 1 addition & 1 deletion timeserieschart/src/VisualOptionsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function VisualOptionsEditor({ value, onChange }: VisualOptionsEditorProp
onChange={(__, newValue) => {
const updatedValue: TimeSeriesChartVisualOptions = {
...value,
stack: newValue.id === 'none' ? undefined : newValue.id, // stack is optional so remove property when 'None' is selected
stack: newValue.id === 'none' ? undefined : newValue.id,
};
// stacked area chart preset to automatically set area under a curve shading
if (newValue.id === 'all' && !value.areaOpacity) {
Expand Down
1 change: 1 addition & 0 deletions timeserieschart/src/time-series-chart-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface QuerySettingsOptions {
lineStyle?: LineStyleType;
areaOpacity?: number;
format?: FormatOptions;
stack?: boolean;
}

export type TimeSeriesChartOptionsEditorProps = OptionsEditorProps<TimeSeriesChartOptions>;
Expand Down
10 changes: 6 additions & 4 deletions timeserieschart/src/utils/data-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import type { YAXisComponentOption } from 'echarts';
import { LineSeriesOption, BarSeriesOption } from 'echarts/charts';
import { getCommonTimeScale } from '@perses-dev/components';

Check failure on line 16 in timeserieschart/src/utils/data-transform.ts

View workflow job for this annotation

GitHub Actions / lint-npm

'/home/runner/work/plugins/plugins/node_modules/@perses-dev/components/dist/index.js' imported multiple times
import {
OPTIMIZED_MODE_SERIES_LIMIT,
Comment thread
SoWieMarkus marked this conversation as resolved.
LegacyTimeSeries,
EChartsDataFormat,
EChartsValues,
TimeSeriesOption,
StepOptions,
getCommonTimeScale,
} from '@perses-dev/components';

Check failure on line 24 in timeserieschart/src/utils/data-transform.ts

View workflow job for this annotation

GitHub Actions / lint-npm

'/home/runner/work/plugins/plugins/node_modules/@perses-dev/components/dist/index.js' imported multiple times
import { useTimeSeriesQueries, PanelData } from '@perses-dev/plugin-system';
import { TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec';
import {
Expand Down Expand Up @@ -69,11 +69,13 @@
visual: TimeSeriesChartVisualOptions,
timeScale: TimeScale,
paletteColor: string,
querySettings?: { lineStyle?: LineStyleType; areaOpacity?: number },
querySettings?: { lineStyle?: LineStyleType; areaOpacity?: number; stack?: boolean },
yAxisIndex?: number
): TimeSeriesOption {
const lineWidth = visual.lineWidth ?? DEFAULT_LINE_WIDTH;
const pointRadius = visual.pointRadius ?? DEFAULT_POINT_RADIUS;
const shouldStack =

Check failure on line 77 in timeserieschart/src/utils/data-transform.ts

View workflow job for this annotation

GitHub Actions / lint-npm

Delete `⏎···`
querySettings?.stack !== undefined ? querySettings.stack : visual.stack === 'all';

Comment thread
SoWieMarkus marked this conversation as resolved.
// Shows datapoint symbols when selected time range is roughly 15 minutes or less
const minuteMs = 60000;
Expand All @@ -90,7 +92,7 @@
datasetIndex,
name: formattedName,
color: paletteColor,
stack: visual.stack === 'all' ? visual.stack : undefined,
stack: shouldStack ? 'all' : undefined,
yAxisIndex: yAxisIndex,
Comment on lines 75 to 96

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoWieMarkus, I can also confirm that the tooltip is not working anymore when it is stacked after your changes. I tested manually.

label: {
show: false,
Expand All @@ -106,7 +108,7 @@
name: formattedName,
connectNulls: visual.connectNulls ?? DEFAULT_CONNECT_NULLS,
color: paletteColor,
stack: visual.stack === 'all' ? visual.stack : undefined,
stack: shouldStack ? 'all' : undefined,
yAxisIndex: yAxisIndex,
sampling: 'lttb',
progressiveThreshold: OPTIMIZED_MODE_SERIES_LIMIT, // https://echarts.apache.org/en/option.html#series-lines.progressiveThreshold
Expand Down
Loading