AmCharts Smoothed Line Serial Multiple Y Axis is not Showing - javascript
I try to make multiple line using amcharts. The type I'm gonna use is smoothed lines (view demo here). I've seen it's possible to draw multiple line charts and multiple value axis on this link. So, I try to implement it on smoothed lines using:
a. 2 lines
b. Both of them are different in scale, so I need two Y axis.
The problem is: only one Y axis appears.
Here's the code I wrote using javascript:
<script type="text/javascript">
var chart;
var graph;
var chartData = [
{"year":"1950", "v1":0.2, "v2":-26},
{"year":"1951", "v1":-0.2, "v2":-45},
{"year":"1952", "v1":1, "v2":-14},
{"year":"1953", "v1":0.2, "v2":6},
{"year":"1954", "v1":-0.5, "v2":18},
{"year":"1955", "v1":0.8, "v2":-8},
{"year":"1956", "v1":-0.4, "v2":-35},
{"year":"1957", "v1":-0.4, "v2":-37},
{"year":"1958", "v1":-0.2, "v2":27},
{"year":"1959", "v1":1.3, "v2":-14},
{"year":"1960", "v1":1, "v2":8},
{"year":"1961", "v1":0, "v2":-6},
{"year":"1962", "v1":0.4, "v2":9},
{"year":"1963", "v1":-0.3, "v2":-38},
{"year":"1964", "v1":0.7, "v2":-3},
{"year":"1965", "v1":0, "v2":-10},
{"year":"1966", "v1":0.7, "v2":-48},
{"year":"1967", "v1":0.2, "v2":22},
{"year":"1968", "v1":1.1, "v2":-22},
{"year":"1969", "v1":-0.2, "v2":-49},
{"year":"1970", "v1":1.5, "v2":-2},
{"year":"1971", "v1":-0.3, "v2":-37},
{"year":"1972", "v1":1, "v2":-44},
{"year":"1973", "v1":-0.4, "v2":18},
{"year":"1974", "v1":1.2, "v2":-17},
{"year":"1975", "v1":-0.3, "v2":-33},
{"year":"1976", "v1":0.6, "v2":-45},
{"year":"1977", "v1":-0.2, "v2":2},
{"year":"1978", "v1":0.5, "v2":18},
{"year":"1979", "v1":-0.3, "v2":-24},
{"year":"1980", "v1":0.5, "v2":14},
{"year":"1981", "v1":-0.5, "v2":-28},
{"year":"1982", "v1":0.7, "v2":-6},
{"year":"1983", "v1":1.1, "v2":-1},
{"year":"1984", "v1":0.9, "v2":-26},
{"year":"1985", "v1":0.8, "v2":0},
{"year":"1986", "v1":1.5, "v2":-27},
{"year":"1987", "v1":1.4, "v2":26},
{"year":"1988", "v1":-0.5, "v2":26},
{"year":"1989", "v1":0.8, "v2":-45},
{"year":"1990", "v1":0.3, "v2":-23},
{"year":"1991", "v1":1.2, "v2":-21},
{"year":"1992", "v1":-0.2, "v2":-31},
{"year":"1993", "v1":0.8, "v2":-12},
{"year":"1994", "v1":0.3, "v2":-35},
{"year":"1995", "v1":1.1, "v2":-1},
{"year":"1996", "v1":0.9, "v2":-14},
{"year":"1997", "v1":-0.1, "v2":11},
{"year":"1998", "v1":1.1, "v2":-29},
{"year":"1999", "v1":-0.2, "v2":11},
{"year":"2000", "v1":-0.4, "v2":-18},
{"year":"2001", "v1":0.6, "v2":-12},
{"year":"2002", "v1":1.5, "v2":-3},
{"year":"2003", "v1":0.6, "v2":-47},
{"year":"2004", "v1":1.5, "v2":-43},
{"year":"2005", "v1":0.1, "v2":-18},
{"year":"2006", "v1":0, "v2":7},
{"year":"2007", "v1":0.5, "v2":-25},
{"year":"2008", "v1":1.5, "v2":-50},
{"year":"2009", "v1":0.4, "v2":28},
{"year":"2010", "v1":0.7, "v2":25},
{"year":"2011", "v1":0.4, "v2":-16},
{"year":"2012", "v1":-0.2, "v2":5},
{"year":"2013", "v1":0.2, "v2":-17},
{"year":"2014", "v1":-0.5, "v2":-22}
];
AmCharts.ready(function () {
// SERIAL CHART
chart = new AmCharts.AmSerialChart();
chart.pathToImages = "../amcharts/images/";
chart.dataProvider = chartData;
chart.marginLeft = 10;
chart.categoryField = "year";
chart.dataDateFormat = "YYYY";
chart.addListener("dataUpdated", zoomChart);
// AXES
// category
var categoryAxis = chart.categoryAxis;
categoryAxis.parseDates = true;
categoryAxis.minPeriod = "YYYY";
categoryAxis.dashLength = 3;
categoryAxis.minorGridEnabled = true;
categoryAxis.minorGridAlpha = 0.1;
// value
var valueAxis = new AmCharts.ValueAxis();
valueAxis.id = "ax1";
valueAxis.axisAlpha = 0;
valueAxis.inside = true;
valueAxis.dashLength = 3;
valueAxis.position = "right";
chart.addValueAxis(valueAxis);
var valueAxis2 = new AmCharts.ValueAxis();
valueAxis2.id = "ax2";
valueAxis2.axisAlpha = 0;
valueAxis2.inside = true;
valueAxis2.dashLength = 3;
valueAxis2.baseValue = -20;
valueAxis2.position = "left";
chart.addValueAxis(valueAxis2);
// GRAPH
graph = new AmCharts.AmGraph();
graph.valueaxis = "ax1";
graph.type = "smoothedLine";
graph.lineColor = "#d1655d";
graph.negativeLineColor = "#637bb6";
graph.bullet = "square";
graph.bulletSize = 8;
graph.bulletBorderColor = "#FFFFFF";
graph.bulletBorderAlpha = 1;
graph.bulletBorderThickness = 2;
graph.lineThickness = 2;
graph.valueField = "v1";
graph.title = "title v1";
graph.balloonText = "[[category]]<br><b><span style='font-size:14px;'>[[value]]</span></b>";
chart.addGraph(graph);
graph2 = new AmCharts.AmGraph();
graph2.valueaxis = "ax2";
graph2.type = "smoothedLine";
graph2.lineColor = "#d1655d";
graph2.negativeLineColor = "#637bb6";
graph2.bullet = "round";
graph2.bulletSize = 8;
graph2.bulletBorderColor = "#FFFFFF";
graph2.bulletBorderAlpha = 1;
graph2.bulletBorderThickness = 2;
graph2.lineThickness = 2;
graph2.valueField = "v2";
graph2.title = "title v2";
graph2.balloonText = "[[category]]<br><b><span style='font-size:14px;'>[[value]]</span></b>";
chart.addGraph(graph2);
// CURSOR
var chartCursor = new AmCharts.ChartCursor();
chartCursor.cursorAlpha = 0;
chartCursor.cursorPosition = "mouse";
chartCursor.categoryBalloonDateFormat = "YYYY";
chart.addChartCursor(chartCursor);
// SCROLLBAR
var chartScrollbar = new AmCharts.ChartScrollbar();
chart.addChartScrollbar(chartScrollbar);
chart.creditsPosition = "bottom-right";
// WRITE
chart.write("chartdiv");
});
Anyone having similar issues? How to overcome this?
It's all very simple, you have a typo:
graph.valueaxis should be graph.valueAxis
Related
Need to show data points with the separate date column of same date
In above picture there are 2 data points on 150 (y-axis) and date is same, issue is that 2 data points are overlapping on each other, I need to show them separately, So both points which are overlapping with 2 date x-axis point instead of 1, please suggest any solution. Here is the code: chartBP = new AmCharts.AmSerialChart(); chartBP.path = "../../js/amcharts/"; chartBP.dataDateFormat = "YYYY-MM-DD"; chartBP.dataProvider = bp_array; chartBP.categoryField = "created_at"; var bpDateAxix = chartBP.categoryAxis; bpDateAxix.parseDates = true; bpDateAxix.minorGridEnabled = true; bpDateAxix.axisColor = "#FF7418"; bpDateAxix.twoLineMode = true; var bpValueAxis = new AmCharts.ValueAxis(); bpValueAxis.gridAlpha = 0.15; chartBP.addValueAxis(bpValueAxis); bpValueAxis.axisColor = "#FF6600"; bpValueAxis.title = "Blood Pressure ("+uom+")"; bpValueAxis.minimum = 0; var sysGraph = new AmCharts.AmGraph(); sysGraph.valueAxis = bpValueAxis; sysGraph.valueField = "systolic"; sysGraph.balloonText = "SYS:[[systolic]] "+uom+"<br><p style='font-size:9px;max-width:300px; word-wrap: break-word;'>[[alert_text]]</p>"; sysGraph.bullet = "round"; sysGraph.colorField = "bullet_color"; sysGraph.lineColor = "#808080"; chartBP.addGraph(sysGraph); var diaGraph = new AmCharts.AmGraph(); diaGraph.valueAxis = bpValueAxis; diaGraph.valueField = "diastolic"; diaGraph.balloonText = "DIA:[[diastolic]] "+uom+"<br><p style='font-size:9px;max-width:300px; word-wrap: break-word;'>[[alert_text]]</p>"; diaGraph.colorField = "bullet_color"; diaGraph.lineColor = "#808080"; diaGraph.bullet = "square"; chartBP.addGraph(diaGraph); var chartScrollbar = new AmCharts.ChartScrollbar(); chartScrollbar.scrollbarHeight = 20; chartScrollbar.color = "#000000"; chartScrollbar.dragIcon = "/amcharts/images/dragIconRoundSmall.svg"; chartScrollbar.dragIconHeight = 22; chartScrollbar.dragIconWidth = 22; chartBP.addChartScrollbar(chartScrollbar); chartBP.write(elementId); AmCharts.checkEmptyData(chartBP);
AM charts display fixed range in axes
Really Hope you can help! I am using AMCharts and Ive added some data through a simple php function (pulled from database) I've added some upper and lower limits, using the below function // HORIZONTAL GREEN RANGE var guide = new AmCharts.Guide(); guide.value =11.00; guide.toValue = 11.80; guide.fillColor = "#00CC00"; guide.inside = true; guide.fillAlpha = 0.2; guide.lineAlpha = 0; valueAxis.addGuide(guide); var guideRED = new AmCharts.Guide(); guideRED.value = 11.80; guideRED.toValue = 11.90; guideRED.fillColor = "orange"; guideRED.inside = true; guideRED.fillAlpha = 0.2; guideRED.lineAlpha = 0; valueAxis.addGuide(guideRED); var guideblue = new AmCharts.Guide(); guideblue.value = 11.00; guideblue.toValue = 10.90; guideblue.fillColor = "orange"; guideblue.inside = true; guideblue.fillAlpha = 0.2; guideblue.lineAlpha = 0; valueAxis.addGuide(guideblue); but I need to set the display range on the Y (top to bottom???) to 11.90 and 10.50 respectivly so the operator can see the plotted line, and its relationship to the red and orange zones. At present the graph simply renders the chart to +1 the max and min it has in value form. Here is the graph functions AmCharts.ready(function () { // SERIAL CHART chart = new AmCharts.AmSerialChart(); chart.dataProvider = chartData; chart.dataDateFormat = "DD-MM-YY"; chart.categoryField = "date"; // AXES // category var categoryAxis = chart.categoryAxis; // categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true // categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD categoryAxis.gridAlpha = 0.1; categoryAxis.minorGridAlpha = 0.1; categoryAxis.axisAlpha = 0; categoryAxis.minorGridEnabled = true; categoryAxis.inside = true; // value var valueAxis = new AmCharts.ValueAxis(); valueAxis.tickLength = 4; valueAxis.axisAlpha = 0; valueAxis.showFirstLabel = false; valueAxis.showLastLabel = false; valueAxis.autoGridCount = true; valueAxis.gridCount = 500; chart.addValueAxis(valueAxis); // GRAPH var graph = new AmCharts.AmGraph(); graph.dashLength = 2; graph.lineColor = "#00CC00"; graph.valueField = "value"; graph.dashLength = 3; graph.bullet = "round"; graph.balloonText = "[[category]]<br><b><span style=\'font-size:14px;\'>value:[[value]]</span></b>"; chart.addGraph(graph); (this is all within a tag hence the escape char's Many thanks.
To force the value axis to particular scale, first set it's minimum and maximum properties. The chart will still try to use whole numbers. To disable that set strictMinMax. I.e.: var valueAxis = new AmCharts.ValueAxis(); valueAxis.minimum = 10.5; valueAxis.maximum = 11.90; valueAxis.strictMinMax = true;
How to generate dynamic graph at runtime in amcharts..?
Following is the code of Multiple Value Axes: In that we want to show the graph by using random data dynamically. when we run this code nothing will be happened. <script> var chart; var chartData = []; // generate some random data, quite different range function generateChartData() { var firstDate = new Date(); firstDate.setDate(firstDate.getDate() - 50); var v = []; var a = []; for (var i = 0; i < 50; i++) { var newDate = new Date(firstDate); newDate.setDate(newDate.getDate() + i);} for (var j = 1; j < 4; j++) { v[j] = Math.round(Math.random() * 40 *j) + 100; chartData.push({ date: newDate, a + j.toString():v[j] // a + j = stringValue - 0; //var a[j]:v[j], }); } } } // this method is called when chart is first inited as we listen for "dataUpdated" event function zoomChart() { // different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues chart.zoomToIndexes(10, 20); } // create chart AmCharts.ready(function() { // generate some random data first generateChartData(); // SERIAL CHART chart = new AmCharts.AmSerialChart(); chart.marginTop = 0; chart.autoMarginOffset = 5; chart.pathToImages = "http://www.amcharts.com/lib/images/"; chart.zoomOutButton = { backgroundColor: '#000000', backgroundAlpha: 0.15 }; chart.dataProvider = chartData; chart.categoryField = "date"; // listen for "dataUpdated" event (fired when chart is inited) and call zoomChart method when it happens chart.addListener("dataUpdated", zoomChart); // AXES // category var categoryAxis = chart.categoryAxis; categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD categoryAxis.dashLength = 2; categoryAxis.gridAlpha = 0.15; categoryAxis.axisColor = "#DADADA"; // first value axis (on the left) var valueAxis1 = new AmCharts.ValueAxis(); valueAxis1.axisColor = "#FF6600"; valueAxis1.axisThickness = 2; valueAxis1.gridAlpha = 0; chart.addValueAxis(valueAxis1); // second value axis (on the right) var valueAxis2 = new AmCharts.ValueAxis(); valueAxis2.position = "right"; // this line makes the axis to appear on the right valueAxis2.axisColor = "#FCD202"; valueAxis2.gridAlpha = 0; valueAxis2.axisThickness = 2; chart.addValueAxis(valueAxis2); // third value axis (on the left, detached) valueAxis3 = new AmCharts.ValueAxis(); valueAxis3.offset = 50; // this line makes the axis to appear detached from plot area valueAxis3.gridAlpha = 0; valueAxis3.axisColor = "#B0DE09"; valueAxis3.axisThickness = 2; chart.addValueAxis(valueAxis3); var graph = []; var v ; for (var j = 1; j < 4; j++) { graph[j] = new AmCharts.AmGraph(); graph[j].valueAxis = valueAxis1; // we have to indicate which value axis should be used graph[j].title = "red line"; v = a + j.toString(); graph[j].valueField = v; graph[j].bullet = "round"; graph[j].hideBulletsCount = 30; chart.addGraph(graph[j]); } // CURSOR var chartCursor = new AmCharts.ChartCursor(); chartCursor.cursorPosition = "mouse"; chart.addChartCursor(chartCursor); // SCROLLBAR var chartScrollbar = new AmCharts.ChartScrollbar(); chart.addChartScrollbar(chartScrollbar); // LEGEND var legend = new AmCharts.AmLegend(); legend.marginLeft = 110; chart.addLegend(legend); // WRITE chart.write("chartdiv"); }); </script> <body> <div id="chartdiv" style="width: 640px: hieght: 400px: overflow: hidden: text-align: left;"> </div> </body>
It seems that you're looking to produce 4 graphs with random values. If that is correct, there is a number of issues with your code: The values for each of the graph need to be consolidated into a single data point for each category. So that we get one object per category: [ { date: '2015-01-01', value1: 100, value2: 200, value3: 300, value4, 400 }, { date: '2015-01-02', value1: 101, value2: 201, value3: 302, value4, 404 }, // etc. ] The best way to achieve that is to create an item with a date part, then generate a value for each graph and add them to the same object. Only then push that object into chart data array. function generateChartData() { var firstDate = new Date(); firstDate.setDate(firstDate.getDate() - 50); for (var i = 0; i < 50; i++) { var newDate = new Date(firstDate); newDate.setDate(newDate.getDate() + i); var item = { date: newDate }; for (var j = 1; j < 4; j++) { item[j.toString()] = Math.round(Math.random() * 40 * j) + 100;; } chartData.push(item); } } The same with adding actual graph objects. Just need to assign valueField to the same key as we did with data: var v; for (var j = 1; j < 4; j++) { graph[j] = new AmCharts.AmGraph(); graph[j].valueAxis = valueAxis1; // we have to indicate which value axis should be used graph[j].title = "red line"; v = j.toString(); graph[j].valueField = v; graph[j].bullet = "round"; graph[j].hideBulletsCount = 30; chart.addGraph(graph[j]); } Here's the complete working code: var chart; var chartData = []; // generate some random data, quite different range function generateChartData() { var firstDate = new Date(); firstDate.setDate(firstDate.getDate() - 50); for (var i = 0; i < 50; i++) { var newDate = new Date(firstDate); newDate.setDate(newDate.getDate() + i); var item = { date: newDate }; for (var j = 1; j < 4; j++) { item[j.toString()] = Math.round(Math.random() * 40 * j) + 100;; } chartData.push(item); } } // this method is called when chart is first inited as we listen for "dataUpdated" event function zoomChart() { // different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues chart.zoomToIndexes(10, 20); } // create chart AmCharts.ready(function() { // generate some random data first generateChartData(); // SERIAL CHART chart = new AmCharts.AmSerialChart(); chart.marginTop = 0; chart.autoMarginOffset = 5; chart.zoomOutButton = { backgroundColor: '#000000', backgroundAlpha: 0.15 }; chart.dataProvider = chartData; chart.categoryField = "date"; // listen for "dataUpdated" event (fired when chart is inited) and call zoomChart method when it happens chart.addListener("dataUpdated", zoomChart); // AXES // category var categoryAxis = chart.categoryAxis; categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD categoryAxis.dashLength = 2; categoryAxis.gridAlpha = 0.15; categoryAxis.axisColor = "#DADADA"; // first value axis (on the left) var valueAxis1 = new AmCharts.ValueAxis(); valueAxis1.axisColor = "#FF6600"; valueAxis1.axisThickness = 2; valueAxis1.gridAlpha = 0; chart.addValueAxis(valueAxis1); // second value axis (on the right) var valueAxis2 = new AmCharts.ValueAxis(); valueAxis2.position = "right"; // this line makes the axis to appear on the right valueAxis2.axisColor = "#FCD202"; valueAxis2.gridAlpha = 0; valueAxis2.axisThickness = 2; chart.addValueAxis(valueAxis2); // third value axis (on the left, detached) valueAxis3 = new AmCharts.ValueAxis(); valueAxis3.offset = 50; // this line makes the axis to appear detached from plot area valueAxis3.gridAlpha = 0; valueAxis3.axisColor = "#B0DE09"; valueAxis3.axisThickness = 2; chart.addValueAxis(valueAxis3); var graph = []; var v; for (var j = 1; j < 4; j++) { graph[j] = new AmCharts.AmGraph(); graph[j].valueAxis = valueAxis1; // we have to indicate which value axis should be used graph[j].title = "red line"; v = j.toString(); graph[j].valueField = v; graph[j].bullet = "round"; graph[j].hideBulletsCount = 30; chart.addGraph(graph[j]); } // CURSOR var chartCursor = new AmCharts.ChartCursor(); chartCursor.cursorPosition = "mouse"; chart.addChartCursor(chartCursor); // SCROLLBAR var chartScrollbar = new AmCharts.ChartScrollbar(); chart.addChartScrollbar(chartScrollbar); // LEGEND var legend = new AmCharts.AmLegend(); legend.marginLeft = 110; chart.addLegend(legend); // WRITE chart.write("chartdiv"); }); #chartdiv { width: 100%; height: 500px; font-size: 11px; } <script src="http://www.amcharts.com/lib/3/amcharts.js"></script> <script src="http://www.amcharts.com/lib/3/serial.js"></script> <script src="http://www.amcharts.com/lib/3/themes/light.js"></script> <div id="chartdiv"></div>
amcharts showing value inside bar
I'm using amCharts, and i want to show values inside bar This is how it looks at the moment: and I want it to be like this: This is my code to display chart: AmCharts.ready(function() { generateWidgetData('week'); // SERIAL CHART chart = new AmCharts.AmSerialChart(); chart.dataProvider = graphData; chart.categoryField = 'date'; chart.startDuration = 1; chart.columnWidth = 0.60; chart.dataDateFormat = 'YYYY-MM-DD'; chart.startEffect = 'easeInSine'; chart.stackType = 'regular'; // AXES // category var categoryAxis = chart.categoryAxis; categoryAxis.parseDates = true; categoryAxis.minPeriod = 'DD'; categoryAxis.plotAreaBorderAlpha = 0.01; categoryAxis.labelRotation = 90; categoryAxis.axisThickness = 0; categoryAxis.stackType = 'regular'; categoryAxis.gridThickness = 0; categoryAxis.inside = false; //categoryAxis.gridPosition = 'start'; //categoryAxis.startDate = '2014-05-08'; // value // in case you don't want to change default settings of value axis, // you don't need to create it, as one value axis is created automatically. // GRAPH var graph = new AmCharts.AmGraph(); graph.maxColumns = 1; graph.valueField = 'Self-entered'; graph.balloonText = '[[category]]: <b>[[value]]</b>'; graph.type = 'column'; graph.lineAlpha = 0; graph.labelText = '[[value]]'; graph.fillAlphas = 0.8; graph.stackType = 'regular'; chart.addGraph(graph); graph.cornerRadiusTop = 8; // CURSOR var chartCursor = new AmCharts.ChartCursor(); chartCursor.cursorAlpha = 0; chartCursor.zoomable = false; chartCursor.categoryBalloonEnabled = false; chart.addChartCursor(chartCursor); chart.creditsPosition = 'top-right'; chart.write('stepschart'); }); Thanks in advance.
I fixed this so i will post answer, maybe it will help to someone its really simple all you need to do is to add 2 lines of code: graph.labelText = '[[value]]'; // this will insert values in labels graph.labelPosition = 'inside'; // and with this we put our label inside bar Hope this will help to someone who also need to do same thing
AmCharts - graphs connected by starting and ending points
I have multiple graphs per chart and for some unknown(to me) reason each graph is connected by the start and the end points of it e.g. Simple question: How to remove it? I couldn't find anything in the documentation that controls it. My code as follows: lineChart = function(id, period) { var chart, data = []; var cData = chartData[id]; AmCharts.ready(function() { for (item in cData) { var i = cData[item]; data.push({ date: new Date(i.date), impressions: i.impressions, clicks: i.clicks, conversions: i.conversions, ctr: i.ctr, profit: i.profit, cost: i.cost, revenue: i.revenue }); } chart = new AmCharts.AmSerialChart(); chart.dataProvider = data; chart.categoryField = "date"; chart.balloon.color = "#000000"; // AXES // category var categoryAxis = chart.categoryAxis; categoryAxis.fillAlpha = 1; categoryAxis.fillColor = "#FAFAFA"; categoryAxis.gridAlpha = 0; categoryAxis.axisAlpha = 0; categoryAxis.minPeriod = period; categoryAxis.parseDates = true; categoryAxis.gridPosition = "start"; categoryAxis.position = "bottom"; // value var valueAxis = new AmCharts.ValueAxis(); valueAxis.dashLength = 5; valueAxis.axisAlpha = 0; valueAxis.integersOnly = true; valueAxis.gridCount = 10; chart.addValueAxis(valueAxis); // GRAPHS // Impressions graph var graph = new AmCharts.AmGraph(); graph.title = "Impressions"; graph.valueField = "impressions"; graph.balloonText = "[[title]]: [[value]]"; //graph.lineAlpha = 1; graph.bullet = "round"; chart.addGraph(graph); // Clicks graph var graph = new AmCharts.AmGraph(); graph.title = "Clicks"; graph.valueField = "clicks"; graph.balloonText = "[[title]]: [[value]]"; graph.bullet = "round"; chart.addGraph(graph); // Conversions graph var graph = new AmCharts.AmGraph(); graph.title = "Conversion"; graph.valueField = "conversions"; graph.balloonText = "[[title]]: [[value]]"; graph.bullet = "round"; chart.addGraph(graph); // LEGEND var legend = new AmCharts.AmLegend(); legend.markerType = "circle"; chart.addLegend(legend); var chartCursor = new AmCharts.ChartCursor(); chartCursor.cursorPosition = "mouse"; if(period == 'hh') chartCursor.categoryBalloonDateFormat = "MMM DD, JJ:00"; chart.addChartCursor(chartCursor); // WRITE chart.write(id); }); };
This looks like the data issue. Make sure your data points are strictly in consecutive ascending order. To verify how your actual data looks like, add the second line below to your code. Then run your chart in Google Chrome with Console open (F12 then select Console tab) chart.dataProvider = data; console.debug(data); Check the datapoints for irregularities. Especially the last two ones.
The problem was that each chart was rendered within it's own AmCharts.ready method. The documentation states that it's allowed, however it didn't work for me, therefore I wrapped all rendering within one ready method and the issue was fixed.