Skip to content

Help: Shadows on line charts #9966

Answered by LeeLenaleee
ayushsoni1010 asked this question in Q&A
Discussion options

You must be logged in to vote

I guess this behaviour is comming from that you override the canvas stroke function with your own function where you give it a shadow. If you dont do this it works fine: https://jsfiddle.net/Leelenaleee/x7ao5419/5/

class lineWithShadow extends Chart.controllers.line {
  draw() {
    const ctx = this._ctx;
    ctx.shadowColor = "rgba(39, 127, 254, 1)";
    ctx.shadowBlur = 5;
    ctx.shadowOffsetX = 0;
    ctx.shadowOffsetY = 4;
    super.draw();
  }
}

lineWithShadow.id = 'lineWithShadow';
Chart.register(lineWithShadow);

const options = {
  type: 'lineWithShadow',
  data: {
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [{
        label: '# of Votes',

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by ayushsoni1010
Comment options

You must be logged in to vote
1 reply
@LeeLenaleee
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #9964 on December 06, 2021 19:20.