Skip to content

[折线图]如何能实现在设置color通道之后还能对每根折线设置渐变(相同渐变规则也可以)? #5206

Answered by pearmini
ChristmasFox asked this question in Q&A
Discussion options

You must be logged in to vote

看看这个 PR 有没有解决问题:#5225

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',
    },
  };
}

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ChristmasFox
Comment options

@pearmini
Comment options

@ChristmasFox
Comment options

@pearmini
Comment options

Answer selected by ChristmasFox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants