Multiple value axes on XY / Scatter chart

Martynas Majeris -

It is possible to have multiple value axis on XYChart.

You just need to create additional ValueAxis (use position="right" if you want to place it on the right), then assign some graphs to it:

// Y
var yAxis = new AmCharts.ValueAxis();
yAxis.position = "left";
chart.addValueAxis(yAxis);

// Another Y
var yAxis2 = new AmCharts.ValueAxis();
yAxis2.position = "left"; // set this to "right" if you want it on the right
yAxis2.offset = 30;
chart.addValueAxis(yAxis2);

// GRAPHS
// graph #1
var graph1 = new AmCharts.AmGraph();
graph1.lineColor = "#FF6600";
graph1.xField = "ax";
graph1.yField = "ay";
chart.addGraph(graph1);

// graph #2
var graph2 = new AmCharts.AmGraph();
graph2.lineColor = "#FCD202";
graph2.xField = "bx";
graph2.yField = "by";
graph2.yAxis = yAxis2; // we need to assign at least one graph to a value axis or it's not shown
chart.addGraph(graph2);

Have more questions? Submit a request

Comments

  • Avatar
    New chao

    very useful, thanks guy.

Powered by Zendesk