[Chartjs]-How to select context or scale on chart in chartjs quickchart io to run getValueForPixel?

1👍

The full chart context is unavailable in the Community version of QuickChart at this time for security reasons. You’ll either have to upgrade to Professional or self-host the service.

However, there is a built-in function getGradientFillHelper that wraps some of this access and may achieve the desired effect.

Here’s an exmaple:

{
  type: 'line',
  data: {
    labels: [2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020],
    datasets: [
      {
        data: [12, 6, 5, 18, 12, 20, 50, 80, 90],
        fill: false,
        borderColor: getGradientFillHelper('vertical', [
          '#eb3639',
          '#a336eb',
          '#36a2eb',
        ]),
        borderWidth: 5,
        pointRadius: 0,
      },
    ],
  },
  options: {
    legend: {
      display: false,
    },
  },
}

Chart.js on QuickChart with gradient line

Link to this chart in Quickchart editor

getGradientFillHelper documentation

Leave a comment