Chartjs line graph with ranges - chart.js

So I need to create a CUSUM control chart and would like to use ChartJS (https://www.chartjs.org/) to do so (example here: https://www.spcforexcel.com/knowledge/variable-control-charts/keeping-process-target-cusum-charts). Basically this chart has a standard line graph but with an upper target (control limit) and a lower target marked to show when the line has moved outside the desired range.
Is this possible with ChartJS and if so how? I have looked at the examples and I'm not seeing how to do it.

Related

Chart.js scatter/bubble pointstyle custom text

I'm looking for a solution in which custom text is rendered instead of a point for a scatter or bubble diagram using chart.js. For example, if plotting baseball players' batting average vs slugging percentage, I want the player's name to appear centered horizontally and vertically over the underlying x,y coordinate, such as 'MANTLE' or 'RUTH', instead of the typical dot/square/triangle/bubble pointstyles. I noticed a callback function lets me program custom axis labels, but I need to do something similar for the actual point of the graph.
If this is not possible, can you recommend another library that can do this.
Thank you in advance...
chartjs-plugin-datalabels does what you're looking for. The positioning of the labels is largely customizable. A custom label formatter function for example lets you display text other than the data values.
Please take a look at the chartjs-plugin-datalabels samples, especially at Custom Labels.
Keep in mind that this plugin registers itself globally, meaning that once imported, all charts will display labels. In case you want it enabled only for a few charts, you first need to unregister it globally. Then, you can enabled the plugin for specific charts.

how to highlight a specific area on chartjs line chart

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.
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
I use this https://github.com/chartjs/chartjs-plugin-annotation lib to do something like this.check on it. I think this will helpful.

Highlight external element on ChartJS hover

I want to be able to generate a chart and when parts of the chart are hovered (i.e. the point on a line graph), I want corresponding elements to have a class added to it on hover. Presumably by passing an array of elements to the hovered data point.
Is this possible in ChartJS? If not, can you recommend a chart software that is capable of this?
I achieved what I wanted with this answer:
https://stackoverflow.com/a/26258671/874691.
Here is my prototype: http://srgunltd.co.uk/chart.html

Place my own controls overlapping Google visualization chart

I'd like to add paging controls to my Google Visualization bar chart, similar to the one described here (keywords: thenez101 Google Visualization BarChart Paging), but instead of flowing my paging controls around the Google bar chart, I'd like to place them on top of the chart. When I place my controls inside the chart's div, however, I see them only until the chart is drawn.
Assigning my controls a CSS class whose z-index property I have changed to positive and negative has not worked. Perhaps I can change their z position after my ready event has fired? Has anyone succeeded in getting this working?
Thanks, BH

Google Charts API - Overlapping X axis labels

I have a chart generated from Google Charts that can be found here: Chart generate by Google Charts API. As you can see the x axis labels are being overlapped.
Anyone knows how to solve this?
See the docs under Bar Width and Spacing (chbh). There's this snippet:
a - space_between_bars and space_between_groups are given in
absolute units (or default absolute values, if not specified). Bars
will be resized so that all bars will fit in the chart.
So just add chbh=a to the options. Here's the example with this option added.