This is a migrated thread and some comments may be shown as answers.

y-axis not including 0 (zero)

1 Answer 372 Views
Charts
This is a migrated thread and some comments may be shown as answers.
merikmgrasp
Top achievements
Rank 1
merikmgrasp asked on 07 Feb 2012, 01:00 AM
***Edit - attached a full example that reproduces the problem shown in my attached screenshot. Tested under IE 9 and Firefox 10.0 - both are missing the zero Y-Axis value.... not sure why.

See attached image. For some reason the Y-axis is not including zero, but rather starts at the lowest value contained in my JSON file.

JSON data:
[
    {
        "CategoryText" : "Previous",
        "SeriesValue" : 321131.5225
    },
    {
        "CategoryText" : "Current",
        "SeriesValue" : 300059.4610
    }
]

This is my chart function that I re-use over and over, passing in a different DIV each time:
var DELAY = 400;

function
createGenericBarChart(ChartName, JsonPath, ChartType, Title, LegendVisible, LegendPosition, CategoryLabelRotation, ValueLabelRotation, Stacked, SeriesLabelsVisible,
SeriesLabelsFormat, ToolTipLabelFormat, CategoryAxisField, BarSeriesDefinition, Maximized) {
    $(ChartName).kendoChart({
        dataSource: {
            transport: {
                read: {
                    url: JsonPath,
                    dataType: "json"
                }
            }
        },
        title: {
            text: Title,
            font: '14px Arial'
        },
        legend: {
            position: LegendPosition,
            visible: LegendVisible,
            font: '8px Arial'
        },
        seriesDefaults: {
            type: ChartType,
            stack: Stacked,
            labels: {
                visible: SeriesLabelsVisible,
                position: "outsideEnd",
                format: SeriesLabelsFormat,
                font: '10px Arial'
            }
        },
        series: BarSeriesDefinition,
        valueAxis: {
            labels: {
                visible: true,
                rotation: ValueLabelRotation,
                font: '10px Arial'
            }
        },
        categoryAxis: {
            field: CategoryAxisField,
            labels: {
                rotation: CategoryLabelRotation,
                font: '10px Arial'
            }
        },
        tooltip: {
            visible: true,
            font: '12px Arial'
        }
    });
}


Here is the HTML /script thats used to call the above function, passing in the arguments:
<div id="dshitem1_1_divChart" class="Chart" style="z-index:8999;">1</div>
    <script>function DashboardCaller1(chartid, maximized) {
var BarSeries = [{
    field: "SeriesValue",
    name: "SeriesValue"
}];
 
createGenericBarChart(chartid, '2626_1_Bar - Airline Contract AC -SUN_.json?id=59bd4fee-511f-480b-bbee-88c3051b800d', 'column', 'Bar - Airline Contract AC -SUN', false, 'top', -45, 0, false, false,
'{0:N2}', '{0:N2}', 'CategoryText', BarSeries, maximized);
}
 
setTimeout(function() {
DashboardCaller1('#dshitem1_1_divChart', false);
}, 1 * DELAY);
 
</script>
 
</div>

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 09 Feb 2012, 11:42 AM
Hi Erik,

 You are able to configure the range of axes via setting min and max values in chart's configuration. For more detailed examples please check the corresponding documentation.

In your case default min value is different from zero, because your data numbers are very large and it would be hard to outline the difference between them. The following code will set Y-axis to start 
from zero:

valueAxis: {
            labels: {
                visible: true,
                rotation: ValueLabelRotation,
                font: '10px Arial'
            },
            min: 0 // set Y-axis to start from zeto
        },

I also updated your project. Please check the attachment.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Charts
Asked by
merikmgrasp
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or