Skip to content

Commit

Permalink
fix(line): series gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed Jun 25, 2023
1 parent 0194cae commit 1a19741
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions __tests__/plots/static/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,4 @@ export { disastersPointBubbleLegendRight } from './disasters-point-bubble-legend
export { mockLegendColor } from './mock-legend-color';
export { mockLegendColorSize } from './mock-legend-color-size';
export { weatherLineMultiAxesLegend } from './weather-line-multi-axes-legend';
export { stocksLineSeriesGradient } from './stocks-line-series-gradient';
23 changes: 23 additions & 0 deletions __tests__/plots/static/stocks-line-series-gradient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { G2Spec } from '../../../src';

export function stocksLineSeriesGradient(): G2Spec {
return {
type: 'line',
data: {
type: 'fetch',
value: 'data/stocks.csv',
},
encode: {
x: (d) => new Date(d.date),
y: 'price',
series: 'symbol',
color: 'price',
},
legend: { size: false },
style: {
gradient: 'y',
strokeWidth: 10,
shape: 'smooth',
},
};
}
5 changes: 3 additions & 2 deletions src/transform/maybeGradient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export type MaybeGradientOptions = Record<string, never>;
*/
export const MaybeGradient: TC<MaybeGradientOptions> = () => {
return (I, mark) => {
const { style = {} } = mark;
const { style = {}, encode } = mark;
const { series } = encode;
const { gradient } = style;
if (!gradient) return [I, mark];
if (!gradient || series) return [I, mark];
return [
I,
deepMix({}, mark, {
Expand Down

0 comments on commit 1a19741

Please sign in to comment.