1

I am using chartjs to draw a line chart on my application. I have dates onx-axis but as a category scale. Means labels are strings but are dates. On the y-axis i have numeric values. I am changing the chart on some functionality and after change i want to highlight some area of the chart. Is there any way i can highlight an area on the line chart? I have searched but did not find anything.

I want to do this pragmatically like there are some specific dates which i want to highlight so i want to have this type of effect.

enter image description here Any kind of help would be much appreciated. I am very beginner in charts and javascript stuff.

P.S this is specifically for the line chart not for the doughnut

fat potato
  • 503
  • 1
  • 9
  • 29
  • @Artier This is not a doughnut chart. – fat potato Dec 14 '17 at 15:26
  • Same as https://stackoverflow.com/questions/31244698/chart-js-line-chart-with-different-background-colors-for-each-section – Artier Dec 14 '17 at 15:49
  • @Artier Mate i dont know why you are giving me the links but not reading my question. This is in chartjs1. Secondly ok i want to change the background but how ? My questions are not addressed in both questions you have given me. – fat potato Dec 14 '17 at 16:04
  • To everyone who googled this: [here's a much better answer](https://stackoverflow.com/questions/47108389/how-to-make-rectangle-in-chart-js) – ᴍᴇʜᴏᴠ Dec 10 '20 at 15:49

1 Answers1

4

I use this https://github.com/chartjs/chartjs-plugin-annotation lib to do something like this.check on it. I think this will helpful.

Janaka Pushpakumara
  • 4,769
  • 5
  • 29
  • 34