If you want to set the axisCrossingValue dynamically, you would need to wait for the Chart to bind and then you can set the second crossing value to match this number of categories generated in the category axis:
categoriesLen = chart.options.categoryAxis.categories.length;
chart.options.categoryAxis.axisCrossingValue = [0, categoriesLen];
I use this approach as compared to setting the configuration with setOptions
method because the latter completely recreates the Chart, plus it should not be used in the dataBound
event. The redraw
method only repaints the Chart using its assigned options.
Here is a Dojo where you can test the result:
I hope this suggestion helps. Let me know if you have any additional questions.