0

I found a example of what I want here Chart JS plugin to change line color depending on value

but I'm not able to make it work right. Trying to simply it down to figure it out. Playing with this.

const gradientFill = c.ctx.createLinearGradient( x_start, y_start, x_end, y_end);
                gradientFill.addColorStop(0, "red");
                gradientFill.addColorStop(1, "blue");

             
 
 
                const model = x.data.datasets[0]._meta[Object.keys(dataset._meta)[0]].dataset._model;
                model.borderColor = gradientFill;

this works but I do not want the gradient color, just a two tone red or blue.

user2144480
  • 1,083
  • 7
  • 11
  • Doesn't the standard solution to create a two-color pattern work for you? i.e., `gradientFill.addColorStop(0, "red");` `gradientFill.addColorStop(0.5, "red");` `gradientFill.addColorStop(0.5 "blue");` `gradientFill.addColorStop(1, "blue");` – kikon Aug 10 '23 at 16:19
  • 1
    yeah that works, a comma was missed but figure it out after some looking. thx for this. – user2144480 Aug 11 '23 at 14:46

0 Answers0