Divide by Zero
Divide by Zero

Reputation: 1474

AmCharts Line chart disconnected from Axis

My graph is disconnected from my y-axis on creation. I was wondering if anyone had the same problem? I tried playing with the axis-offset as you can see. does not fix the problem.

Image Link

enter image description here

            AmCharts.ready(function () {
            chart = new AmCharts.AmSerialChart();
            chart.dataProvider = chartData;
            chart.categoryField = "timestamp";
            chart.startDuration = 0;
            chart.pathToImages = "/design/javascripts/amcharts/images/";
            chart.zoomOutButton = {

            var valueAxis = new AmCharts.ValueAxis();
            valueAxis.title = "{t}Impressions{/t}";
            valueAxis.offset = -25;
            valueAxis.stackType = "regular";
            valueAxis.position = "left";
            valueAxis.gridAlpha = 0.1;
            valueAxis.axisAlpha = 0.2;
            valueAxis.dashLength = 1;
            chart.addValueAxis(valueAxis);
                backgroundColor: '#000000',
                backgroundAlpha: 0.15
            };

Please help

Upvotes: 0

Views: 532

Answers (1)

Diego López
Diego López

Reputation: 1609

Set the startOnAxis property of the categoryAxis object to true

chart.categoryAxis.startOnAxis = true;

http://docs.amcharts.com/javascriptcharts/CategoryAxis

EDIT: As martynasma suggested, you should note that this won't work if you have chart.categoryAxis.parseDates set to true unless you also set chart.categoryAxis.equalSpacing to true. As stated on the amcharts CategoryAxis documentation about "startOnAxis" property:

Specifies whether the graph should start on axis or not. In case you display columns, it is recommended to set this to false. If parseDates is set to true, startOnAxis will allways be false, unless equalSpacing is set to true.

Upvotes: 1

Related Questions