1

Hi I am working on Chartnew.js for plotting bar chart.I have defined the x and y axis labels and have plotted the bars in it.

1)How can i fixed the width of each bar in this chart(width should be equal say 20 px)

2)What is the maximum number of bars this chart can handle ?

3) If the number of bars increases , can i make the bar chart scrollable ?

4)Also if it could scroll , on my pageshow eent , can i scroll my chart region to a particular bar offset(say it should appear centred or highlighted based on some index) ? 5)I tried using chart.js as well but could not work this out.

Any help would be appreciated

Thanks

cssyphus
  • 37,875
  • 18
  • 96
  • 111
Vikas Ojha
  • 27
  • 1
  • 5

1 Answers1

0

I fixed this my adding below code in ChartNew.js

while (barWidth > 80) {
  config.barValueSpacing = config.barValueSpacing + 10;
  barWidth = (valueHop - Math.ceil(ctx.chartLineScale * config.scaleGridLineWidth) * 2 - (Math.ceil(ctx.chartSpaceScale * config.barValueSpacing) * 2) - (Math.ceil(ctx.chartSpaceScale * config.barDatasetSpacing) * nrOfBars - 1) - ((Math.ceil(ctx.chartLineScale * config.barStrokeWidth) / 2) * nrOfBars - 1)) / nrOfBars;
}

In above code 80 is max size that you want to set. Put this code exactly at line number 3883, below line:

barWidth = (valueHop - Math.ceil(ctx.chartLineScale * config.scaleGridLineWidth) * 2 - (Math.ceil(ctx.chartSpaceScale * config.barValueSpacing) * 2) - (Math.ceil(ctx.chartSpaceScale * config.barDatasetSpacing) * nrOfBars - 1) - ((Math.ceil(ctx.chartLineScale * config.barStrokeWidth) / 2) * nrOfBars - 1)) / nrOfBars;

For more reference, put this code inside function: var Bar = function(data, config, ctx) {}, below the line where barWidth is set.

Its working ace for me.

Pranit
  • 168
  • 1
  • 8