Home › forums › Using CanvasJS › How to render histograms
Tagged: datapointwidth, histogram
This topic contains 4 replies, has 3 voices, and was last updated by Vishwas R 1 month ago.
Histograms have usually no space between their bar/column shapes, like here below (on the right):
1) How can I set the bar/column shape width to the maximum allowed? I tried with dataPointWidth and dataPointMaxWidth, but it’s not optimum.
2) Also, how can I remove the left/right padding between the bars/columns and the Y axis, or at the right?
1) By setting dataPointWidth based on axis width and number of dataPoints in column chart, histogram chart can be rendered. Please check this jsfiddle.
2) You can remove left/right padding between column and axis by setting minimum/maximum.
This fails when zooming in. Seems to need the visible x-axis and the visible number of datapoints. Is that possible?
When the chart is zoomed, you can find whether a dataPoint is within the viewport range or outside with the help of rangeChanged event. Please take a look at this JSFiddle for nearest possible solution to set the dataPointWidth by finding the number of dataPoints within the viewport range.
You must be logged in to reply to this topic.