dataPointMaxWidth: Number

dataPointMaxWidth sets the maximum width of dataPoints in column / bar, ohlc and candlestick, charts. This allows you to limit the width of dataPoints when there are very few of them in the chart. At the same time, when the number of dataPoints increase, chart reduces their width so that they don’t overlap.


Default : Automatically calculated based on the chart size.
Example : 10, 20, 30, etc.

Note
  • Supported in all types of column / bar charts, ohlc and candlestick charts

var  chart =  new  CanvasJS.Chart("container",
{
 .
 .
 dataPointMaxWidth: 20,
 .
 .
});
chart.render();


Try it Yourself by Editing the Code below.

  Also See:    



If you have any questions, please feel free to ask in our forums.Ask Question

Comments 9

  1. I am using Python Flask and Bootstrap. When I try to set the datapointmaxwidth property it is getting ignored (no errors thrown). Even if I copy and paste the sample script above, I cannot get the widths to change. Any advice or hints as to what is going wrong? Thanks!

  2. I’m using a stacked column chart with the latest CanvasJS and max width is being ignored for me as well. I add the data to the chart programmatically after the chart has been instanced. Is that the problem?

      • Nevermind. I figured it out. I was declaring the dataPointMaxWidth at the data series level instead of the data level. It’s working now.

        One other question relates to stacked range column charts. Are they possible?

  3. As well as dataPointMaxWidth, there should also be an option to specify the pixel-based grid width, and I don’t mean the gridLineThickness, I mean the actual grid width. Might not be important for 99.9% of the applications but consider the case that one wants to be able to set dataPointMaxWidth to 1 and the distance to 1 or even 0.

    • I just wanted to show different size of bars depends up on the data coming from backend. can you please suggest me on this

      • Jagadesan,

        Sorry, as of now this feature is not available. Currently you can control dataPointWith or dataPointMaxWith/dataPointMinWidth for all the dataSeries.

If you have any questions, please feel free to ask in our forums. Ask Question