Skip to content

Commit 4eaba3f

Browse files
[FEATURE] TimeSeriesChart: support opacity & line style overrides (#386)
* Move query settings to a dedicated tab Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * Add area opacity to query settings Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * Add line style to query settings Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * make colorMode and colorValue optional Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * add add/remove buttons for each option Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * Gather in a common "+" button Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * factorize the section logic Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * misc Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * review comments Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> * ignore npmjs.com links validation Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr> --------- Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr>
1 parent a344a55 commit 4eaba3f

10 files changed

Lines changed: 415 additions & 96 deletions

.mdox.validate.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ validators:
66
- regex: 'github\.com'
77
type: 'ignore'
88
- regex: 'perses\.dev'
9+
type: 'ignore'
10+
# getting 403 forbidden in the CI
11+
- regex: 'npmjs\.com'
912
type: 'ignore'

timeserieschart/schemas/time-series.cue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ spec: close({
3838
#visual: {
3939
display?: "line" | "bar"
4040
lineWidth?: number & >=0.25 & <=3
41-
lineStyle?: "solid" | "dashed" | "dotted"
42-
areaOpacity?: number & >=0 & <=1
41+
lineStyle?: #lineStyle
42+
areaOpacity?: #areaOpacity
4343
showPoints?: "auto" | "always"
4444
palette?: #palette
4545
pointRadius?: number & >=0 & <=6
@@ -59,7 +59,12 @@ spec: close({
5959
}
6060

6161
#querySettings: [...{
62-
queryIndex: int & >=0
63-
colorMode: "fixed" | "fixed-single" // NB: "palette" could be added later
64-
colorValue: =~"^#(?:[0-9a-fA-F]{3}){1,2}$" // hexadecimal color code
62+
queryIndex: int & >=0
63+
colorMode?: "fixed" | "fixed-single" // NB: "palette" could be added later
64+
colorValue?: =~"^#(?:[0-9a-fA-F]{3}){1,2}$" // hexadecimal color code
65+
lineStyle?: #lineStyle
66+
areaOpacity?: #areaOpacity
6567
}]
68+
69+
#lineStyle: "solid" | "dashed" | "dotted"
70+
#areaOpacity: number & >=0 & <=1 // transparency level from 0 (transparent) to 1 (opaque)

timeserieschart/src/TimeSeriesChartOptionsEditorSettings.tsx renamed to timeserieschart/src/GeneralSettingsEditor.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ import {
3030
} from './time-series-chart-model';
3131
import { VisualOptionsEditor, VisualOptionsEditorProps } from './VisualOptionsEditor';
3232
import { YAxisOptionsEditor, YAxisOptionsEditorProps } from './YAxisOptionsEditor';
33-
import { QuerySettingsEditor, QuerySettingsEditorProps } from './QuerySettingsEditor';
3433

35-
export function TimeSeriesChartOptionsEditorSettings(props: TimeSeriesChartOptionsEditorProps): ReactElement {
34+
export function TimeSeriesChartGeneralSettings(props: TimeSeriesChartOptionsEditorProps): ReactElement {
3635
const { onChange, value } = props;
3736

3837
const handleLegendChange: LegendOptionsEditorProps['onChange'] = (newLegend) => {
@@ -60,14 +59,6 @@ export function TimeSeriesChartOptionsEditorSettings(props: TimeSeriesChartOptio
6059
);
6160
};
6261

63-
const handleQuerySettingsChange: QuerySettingsEditorProps['onChange'] = (newQuerySettings) => {
64-
onChange(
65-
produce(value, (draft: TimeSeriesChartOptions) => {
66-
draft.querySettings = newQuerySettings;
67-
})
68-
);
69-
};
70-
7162
const handleThresholdsChange: ThresholdsEditorProps['onChange'] = (thresholds) => {
7263
onChange(
7364
produce(value, (draft: TimeSeriesChartOptions) => {
@@ -87,20 +78,18 @@ export function TimeSeriesChartOptionsEditorSettings(props: TimeSeriesChartOptio
8778
</OptionsEditorColumn>
8879
<OptionsEditorColumn>
8980
<ThresholdsEditor hideDefault thresholds={value.thresholds} onChange={handleThresholdsChange} />
90-
<QuerySettingsEditor querySettingsList={value.querySettings} onChange={handleQuerySettingsChange} />
9181
<OptionsEditorGroup title="Reset Settings">
9282
<Button
9383
variant="outlined"
9484
color="secondary"
9585
onClick={() => {
9686
onChange(
9787
produce(value, (draft: TimeSeriesChartOptions) => {
98-
// reset button removes all optional panel options
88+
// reset button removes all general panel options
9989
draft.yAxis = undefined;
10090
draft.legend = undefined;
10191
draft.visual = undefined;
10292
draft.thresholds = undefined;
103-
draft.querySettings = undefined;
10493
})
10594
);
10695
}}

0 commit comments

Comments
 (0)