diff --git a/docs/@views/styles/config.md b/docs/@views/styles/config.md index 42ea74eac..f8e5766da 100644 --- a/docs/@views/styles/config.md +++ b/docs/@views/styles/config.md @@ -358,7 +358,15 @@ const styles = { // } // }] features: [] - } + }, + grid: { // 优先取副图指标的grid样式,如果没有则取全局的grid配置 + horizontal: { + show: true, + }, + vertical: { + show: true, + }, + }, }, xAxis: { show: true, diff --git a/src/common/Styles.ts b/src/common/Styles.ts index 82a341aa2..a0bba50e0 100644 --- a/src/common/Styles.ts +++ b/src/common/Styles.ts @@ -278,6 +278,7 @@ export interface IndicatorStyle { circles: IndicatorPolygonStyle[] lastValueMark: IndicatorLastValueMarkStyle tooltip: IndicatorTooltipStyle + grid: GridStyle [key: string]: unknown } @@ -613,7 +614,8 @@ function getDefaultIndicatorStyle (): IndicatorStyle { defaultValue: 'n/a' }, features: [] - } + }, + grid: getDefaultGridStyle() } } diff --git a/src/extension/styles/dark.ts b/src/extension/styles/dark.ts index 94afee0e9..4641417d6 100644 --- a/src/extension/styles/dark.ts +++ b/src/extension/styles/dark.ts @@ -54,6 +54,14 @@ const dark: DeepPartial = { legend: { color: '#929AA5' } + }, + grid: { + horizontal: { + color: '#292929' + }, + vertical: { + color: '#292929' + } } }, xAxis: { diff --git a/src/extension/styles/light.ts b/src/extension/styles/light.ts index ac49e59de..4eae0e605 100644 --- a/src/extension/styles/light.ts +++ b/src/extension/styles/light.ts @@ -54,6 +54,14 @@ const light: DeepPartial = { legend: { color: '#76808F' } + }, + grid: { + horizontal: { + color: '#EDEDED' + }, + vertical: { + color: '#EDEDED' + } } }, xAxis: { diff --git a/src/view/GridView.ts b/src/view/GridView.ts index 0bc3e248b..5ec0601c7 100644 --- a/src/view/GridView.ts +++ b/src/view/GridView.ts @@ -13,8 +13,10 @@ */ import type { LineAttrs } from '../extension/figure/line' +import type { GridStyle } from '../common/Styles' import View from './View' +import { PaneIdConstants } from '../pane/types' export default class GridView extends View { override drawImp (ctx: CanvasRenderingContext2D): void { @@ -23,7 +25,11 @@ export default class GridView extends View { const chart = pane.getChart() const bounding = widget.getBounding() - const styles = chart.getStyles().grid + // 判断是否为副图面板,如果是则使用indicator.grid配置,否则使用全局grid配置 + const paneId = pane.getId() + const isIndicatorPane = paneId !== PaneIdConstants.CANDLE && paneId !== PaneIdConstants.X_AXIS // indicator指标的paneId可以自定义 + const allStyles = chart.getStyles() + const styles: GridStyle = isIndicatorPane ? allStyles.indicator.grid : allStyles.grid const show = styles.show if (show) {