Skip to content

Commit

Permalink
fix: option to disable the isolated point styles on line and area cha…
Browse files Browse the repository at this point in the history
…rts (#2472)
  • Loading branch information
nickofthyme authored Jun 24, 2024
1 parent 040c354 commit ae16815
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 10 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions e2e/tests/test_cases_stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ test.describe('Test cases stories', () => {
});

test.describe('Isolated point styles', () => {
test('should disable isolated point styles', async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
'http://localhost:9001/?path=/story/test-cases--point-style-overrides&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-disable isolated point styles=true&knob-series type=line&knob-point.stroke - theme level=red&knob-isolatedPoint.stroke - theme level=green&knob-use series overrides=&knob-point.stroke - series level=blue&knob-use series iso overrides=&knob-isolatedPoint.stroke - series level=orange&knob-use point style overrides=&knob-stroke - pointStyleAccessor=black',
);
});

test('should override theme point and iso point styles with series styles', async ({ page }) => {
await common.expectChartAtUrlToMatchScreenshot(page)(
'http://localhost:9001/?path=/story/test-cases--point-style-overrides&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-isolatedPoint.stroke - series level=orange&knob-isolatedPoint.stroke - theme level=green&knob-point.stroke - series level=blue&knob-point.stroke - theme level=red&knob-series type=line&knob-stroke - pointStyleAccessor=black&knob-use point style overrides=false&knob-use series iso overrides=false&knob-use series overrides=true',
Expand Down
8 changes: 6 additions & 2 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ export interface AreaSeriesStyle {
area: AreaFitStyle;
};
// (undocumented)
isolatedPoint: PointStyle;
isolatedPoint: {
enabled: boolean;
} & PointStyle;
// (undocumented)
line: LineStyle;
// (undocumented)
Expand Down Expand Up @@ -2000,7 +2002,9 @@ export interface LineSeriesStyle {
line: LineFitStyle;
};
// (undocumented)
isolatedPoint: PointStyle;
isolatedPoint: {
enabled: boolean;
} & PointStyle;
// (undocumented)
line: LineStyle;
// (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion packages/charts/src/chart_types/xy_chart/rendering/area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function renderArea(
isBandedSpec,
markSizeOptions,
false,
true,
style.isolatedPoint.enabled,
pointStyleAccessor,
);

Expand Down
10 changes: 5 additions & 5 deletions packages/charts/src/chart_types/xy_chart/rendering/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function renderLine(
curve: CurveType,
hasY0Accessors: boolean,
xScaleOffset: number,
seriesStyle: LineSeriesStyle,
style: LineSeriesStyle,
markSizeOptions: MarkSizeOptions,
hasFit: boolean,
pointStyleAccessor?: PointStyleAccessor,
Expand All @@ -56,12 +56,12 @@ export function renderLine(
yScale,
panel,
color,
seriesStyle.point,
seriesStyle.isolatedPoint,
style.point,
style.isolatedPoint,
hasY0Accessors,
markSizeOptions,
false,
true,
style.isolatedPoint.enabled,
pointStyleAccessor,
);

Expand All @@ -77,7 +77,7 @@ export function renderLine(
y: 0,
},
seriesIdentifier: getSeriesIdentifierFromDataSeries(dataSeries),
style: seriesStyle,
style,
clippedRanges,
shouldClip: hasFit,
};
Expand Down
2 changes: 2 additions & 0 deletions packages/charts/src/utils/themes/dark_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const DARK_THEME: Theme = {
opacity: 1,
},
isolatedPoint: {
enabled: true,
visible: true,
stroke: ColorVariant.Series,
strokeWidth: 1,
Expand Down Expand Up @@ -79,6 +80,7 @@ export const DARK_THEME: Theme = {
opacity: 1,
},
isolatedPoint: {
enabled: true,
visible: true,
stroke: ColorVariant.Series,
strokeWidth: 1,
Expand Down
2 changes: 2 additions & 0 deletions packages/charts/src/utils/themes/legacy_dark_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const LEGACY_DARK_THEME: Theme = {
opacity: 1,
},
isolatedPoint: {
enabled: true,
visible: true,
stroke: ColorVariant.Series,
strokeWidth: 1,
Expand Down Expand Up @@ -88,6 +89,7 @@ export const LEGACY_DARK_THEME: Theme = {
opacity: 1,
},
isolatedPoint: {
enabled: true,
visible: true,
stroke: ColorVariant.Series,
strokeWidth: 1,
Expand Down
2 changes: 2 additions & 0 deletions packages/charts/src/utils/themes/legacy_light_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const LEGACY_LIGHT_THEME: Theme = {
opacity: 1,
},
isolatedPoint: {
enabled: true,
visible: true,
stroke: ColorVariant.Series,
strokeWidth: 1,
Expand Down Expand Up @@ -88,6 +89,7 @@ export const LEGACY_LIGHT_THEME: Theme = {
opacity: 1,
},
isolatedPoint: {
enabled: true,
visible: true,
stroke: ColorVariant.Series,
strokeWidth: 1,
Expand Down
2 changes: 2 additions & 0 deletions packages/charts/src/utils/themes/light_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const LIGHT_THEME: Theme = {
opacity: 1,
},
isolatedPoint: {
enabled: true,
visible: true,
stroke: ColorVariant.Series,
strokeWidth: 1,
Expand Down Expand Up @@ -79,6 +80,7 @@ export const LIGHT_THEME: Theme = {
opacity: 1,
},
isolatedPoint: {
enabled: true,
visible: true,
stroke: ColorVariant.Series,
strokeWidth: 1,
Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/utils/themes/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ export interface BubbleSeriesStyle {
export interface LineSeriesStyle {
line: LineStyle;
point: PointStyle;
isolatedPoint: PointStyle;
isolatedPoint: { enabled: boolean } & PointStyle;
fit: {
line: LineFitStyle;
};
Expand All @@ -746,7 +746,7 @@ export interface AreaSeriesStyle {
area: AreaStyle;
line: LineStyle;
point: PointStyle;
isolatedPoint: PointStyle;
isolatedPoint: { enabled: boolean } & PointStyle;
fit: {
line: LineFitStyle;
area: AreaFitStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const defaultlineStyles = {
};

export const Example: ChartsStory = (_, { title, description }) => {
const enablePointStyles = !boolean('disable isolated point styles', false);
const [Series] = customKnobs.enum.xySeries('series type', 'line', { exclude: ['bar', 'bubble'] });
const themeLevelStroke = color('point.stroke - theme level', 'red');
const themeLevelStrokeIso = color('isolatedPoint.stroke - theme level', 'green');
Expand All @@ -51,6 +52,7 @@ export const Example: ChartsStory = (_, { title, description }) => {
isolatedPoint: {
stroke: themeLevelStrokeIso,
...defaultPointStyles,
enabled: enablePointStyles,
},
},
lineSeriesStyle: {
Expand All @@ -63,6 +65,7 @@ export const Example: ChartsStory = (_, { title, description }) => {
isolatedPoint: {
stroke: themeLevelStrokeIso,
...defaultPointStyles,
enabled: enablePointStyles,
},
},
}}
Expand Down

0 comments on commit ae16815

Please sign in to comment.