Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

amCharts set maximum Y axis and X axis values are missing from bar labels charts

I am using amCharts to prepare bar chart

Please check the Fiddle for my bar chart as follows:

FIDDLE

  • I am getting the maximum value of Y axis as 150. I need maximum value of Y axis as 100.
  • I am getting the X-axis values as 1,4,7,10 only. I need the values in all bars as 1,2,3...10.
  • I need label of Y axis as percentage and X axis as question numbers

What I tried to putting Maximum for Y axis as follows:

I have added this lines for handling Y axis as follows:

    valueAxis.autoGridCount = false;
    valueAxis.gridCount = 10;
    valueAxis.labelFrequency = 100;

But not getting. Please guide me!

like image 608
Santhucool Avatar asked Feb 10 '23 06:02

Santhucool


1 Answers

Value axis scale

To set fixed scale for your value axis, use minimum and maximum properties:

valueAxis.minimum = 0;
valueAxis.maximum = 100;

Category (horizontal) axis label frequency

The chart automatically tries to determine the frequency of the labels based on available space so that the axis does not seem cluttered.

To force a certain number of grid lines on a category axis, use autoGridCount and gridCount properties of the chart's categoryAxis. (note that it's categoryAxis, not valueAxis as you have in your code)

chart.categoryAxis.autoGridCount = false;
chart.categoryAxis.gridCount = 10;

Adding percent sign to value axis labels

You can use value axis' unit and unitPosition properties to add any characters next to the values.

valueAxis.unit = "%";
valueAxis.unitPosition = "right";

Here's your fiddle updated with all of the above.

like image 97
martynasma Avatar answered Feb 12 '23 01:02

martynasma