Search code examples
javascripthtmlcanvaschartscanvasjs

Canvas.js doughnut chart thickness


I'm currently working on some doughnut charts using Canvas.JS, and I'm not able to find a proper way to set the chart's thickness.

The docs are pretty extensive (you can go over here to check them out) but I can't seem to find a proper solution for my "problem".

Right now I'm generating the chart with the following code:

CanvasJS.addColorSet('circColors', [
  '#7583B2',
  '#E6866A'
]);

var circChartOptions = {
  animationEnabled: true,
  colorSet: 'circColors',
  data: [
    {
      labelFontColor: '#9EA4AC',
      labelFontFamily: 'Lato, sans-serif',
      labelFontWeight: 'normal',
      indexLabelLineColor: 'white',
      type: 'doughnut',
      startAngle:-90,
      toolTipContent: '{label}: {y} - <strong>#percent%</strong>',
      indexLabel: '{label} #percent%',
      dataPoints: [
        { y: 37.47, label: 'Mobile' },
        { y: 62.53, label: 'Desktop' }
      ]
    }
  ]
};

$('#circChart').CanvasJSChart(circChartOptions);

Does Canvas.JS even provide a way to control the chart's thickness? Any help will be appreciated.

Thanks!


Solution

  • data: [
    {
      labelFontColor: '#9EA4AC',
      labelFontFamily: 'Lato, sans-serif',
      labelFontWeight: 'normal',
      indexLabelLineColor: 'white',
      type: 'doughnut',
      innerRadius: "85%",
      startAngle:-90,
      toolTipContent: '{label}: {y} - <strong>#percent%</strong>',
      indexLabel: '{label} #percent%',
      dataPoints: [
        { y: 37.47, label: 'Mobile' },
        { y: 62.53, label: 'Desktop' }
      ]
    }
    

    use innerRadius to control the tickness