Skip to content

Commit e1a6a22

Browse files
authored
feat: Add indicator theme variables (#2344)
Adds theme variables for indicator
1 parent 0305522 commit e1a6a22

10 files changed

Lines changed: 67 additions & 0 deletions

File tree

packages/chart/src/ChartTheme.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@
2121
ocean-color: var(--dh-color-chart-geo-ocean);
2222
lake-color: var(--dh-color-chart-geo-lake);
2323
river-color: var(--dh-color-chart-geo-river);
24+
25+
/* Indicator */
26+
indicator-increasing: var(--dh-color-chart-indicator-increase);
27+
indicator-decreasing: var(--dh-color-chart-indicator-decrease);
28+
indicator-gauge: var(--dh-color-chart-indicator-gauge);
2429
}

packages/chart/src/ChartTheme.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export interface ChartTheme {
2828
ocean_color: string;
2929
lake_color: string;
3030
river_color: string;
31+
32+
// Indicator
33+
indicator_increasing: string;
34+
indicator_decreasing: string;
35+
indicator_gauge: string;
3136
}
3237

3338
export function defaultChartTheme(): Readonly<ChartTheme> {
@@ -65,6 +70,10 @@ export function defaultChartTheme(): Readonly<ChartTheme> {
6570
ocean_color: chartTheme['ocean-color'],
6671
lake_color: chartTheme['lake-color'],
6772
river_color: chartTheme['river-color'],
73+
// Indicator
74+
indicator_increasing: chartTheme['indicator-increasing'],
75+
indicator_decreasing: chartTheme['indicator-decreasing'],
76+
indicator_gauge: chartTheme['indicator-gauge'],
6877
});
6978
}
7079

packages/chart/src/ChartUtils.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type {
1717
AxisType as PlotlyAxisType,
1818
MarkerSymbol,
1919
Template,
20+
Delta,
2021
} from 'plotly.js';
2122
import { assertNotNull, bindAllMethods, type Range } from '@deephaven/utils';
2223
import { type ChartTheme } from './ChartTheme';
@@ -2038,6 +2039,9 @@ class ChartUtils {
20382039
ohlc_increasing,
20392040
ohlc_decreasing,
20402041
title_color,
2042+
indicator_increasing,
2043+
indicator_decreasing,
2044+
indicator_gauge,
20412045
} = theme;
20422046

20432047
return {
@@ -2075,6 +2079,20 @@ class ChartUtils {
20752079
},
20762080
},
20772081
],
2082+
indicator: [
2083+
{
2084+
title: { font: { color: title_color } },
2085+
delta: {
2086+
decreasing: {
2087+
color: indicator_decreasing,
2088+
} as Delta['increasing'],
2089+
increasing: {
2090+
color: indicator_increasing,
2091+
} as Delta['decreasing'],
2092+
},
2093+
gauge: { bar: { color: indicator_gauge } },
2094+
},
2095+
],
20782096
},
20792097
/* eslint-enable camelcase */
20802098
layout: this.makeDefaultLayout(theme),

packages/chart/src/__snapshots__/ChartTheme.test.ts.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ exports[`defaultChartTheme should create the default chart theme 1`] = `
66
"colorway": "chartTheme['colorway']",
77
"error_band_line_color": "chartTheme['error-band-line-color']",
88
"gridcolor": "chartTheme['gridcolor']",
9+
"indicator_decreasing": "chartTheme['indicator-decreasing']",
10+
"indicator_gauge": "chartTheme['indicator-gauge']",
11+
"indicator_increasing": "chartTheme['indicator-increasing']",
912
"lake_color": "chartTheme['lake-color']",
1013
"land_color": "chartTheme['land-color']",
1114
"legend_color": "chartTheme['legend-color']",

packages/chart/src/__snapshots__/ChartUtils.test.ts.snap

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ exports[`makeDefaultTemplate should create a default template 1`] = `
1212
},
1313
},
1414
],
15+
"indicator": [
16+
{
17+
"delta": {
18+
"decreasing": {
19+
"color": "ChartTheme['indicator_decreasing']",
20+
},
21+
"increasing": {
22+
"color": "ChartTheme['indicator_increasing']",
23+
},
24+
},
25+
"gauge": {
26+
"bar": {
27+
"color": "ChartTheme['indicator_gauge']",
28+
},
29+
},
30+
"title": {
31+
"font": {
32+
"color": "ChartTheme['title_color']",
33+
},
34+
},
35+
},
36+
],
1537
"ohlc": [
1638
{
1739
"decreasing": {

packages/components/src/theme/theme-dark/theme-dark-semantic-chart.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@
4747
--dh-color-chart-geo-ocean: var(--dh-color-gray-300);
4848
--dh-color-chart-geo-lake: var(--dh-color-blue-200);
4949
--dh-color-chart-geo-river: var(--dh-color-blue-200);
50+
51+
/* Indicator */
52+
--dh-color-chart-indicator-increase: var(--dh-color-visual-green);
53+
--dh-color-chart-indicator-decrease: var(--dh-color-visual-red);
54+
--dh-color-chart-indicator-gauge: var(--dh-color-green-1000);
5055
}

packages/components/src/theme/theme-light/theme-light-semantic-chart.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@
4747
--dh-color-chart-geo-ocean: var(--dh-color-gray-300);
4848
--dh-color-chart-geo-lake: var(--dh-color-blue-400);
4949
--dh-color-chart-geo-river: var(--dh-color-blue-400);
50+
51+
/* Indicator */
52+
--dh-color-chart-indicator-increase: var(--dh-color-visual-green);
53+
--dh-color-chart-indicator-decrease: var(--dh-color-visual-red);
54+
--dh-color-chart-indicator-gauge: var(--dh-color-green-1000);
5055
}
2.67 KB
Loading
4.66 KB
Loading
823 Bytes
Loading

0 commit comments

Comments
 (0)