|
How to set 8 different Y-axis in line chart |
Posted by Megha on Nov-13-2014 20:04 |
|
Hello
How to set 8 different Y-axis in line chart in java.I'am able to set dual y-axis but can't set
8 y-axis |
Re: How to set 8 different Y-axis in line chart |
Posted by Peter Kwan on Nov-14-2014 02:49 |
|
Hi Megha,
You may use XYChart.addAxis to add as many axes as you like. There is an example called
"Multiple Axes" that demonstrates using XYChart.addAxis.
http://www.advsofteng.com/doc/cdjava.htm#multiaxes.htm
Hope this can help.
Regards
Peter Kwan |
Re: How to set 8 different Y-axis in line chart |
Posted by Megha on Nov-14-2014 13:09 |
|
Hi Peter
Thanks for the reply.I'am able to draw dual Y-axis .But I'm not able to draw three y-
axis.My code is:-
<%@page import="ChartDirector.*" %>
<%
double[] data = vb.getcahrtavgvs1();
double[] data1= vb.beam_Current();
double[] data2 = vb.getcahrtavg();
String[] labels = vb.getChartTime();
XYChart c = new XYChart(600, 400);
c.setPlotArea(100, 70, 400, 180,0xffffff).setGridColor(0xcccccc, 0xcccccc);
c.addTitle("GRAPH FOR AVERAGE RING PRESSURE");
c.xAxis().setTitle("logtime");
c.xAxis().setLabels(labels);
c.xAxis().setLabelStep(360);
//Add a title to the primary (left) y axis
c.yAxis().setTitle("Average pressure");
c.yAxis().setColors(0xc00000, 0xc00000, 0xc00000);
c.yAxis2().setTitle("Beam_Current");
c.yAxis2().setColors(0x008000, 0x008000, 0x008000);
Axis leftAxis = c.addAxis(Chart.Left, 50);
c.addLineLayer(data, 0xc00000);
LineLayer lineLayer = c.addLineLayer(data1, 0x008000);
lineLayer.setUseYAxis2();
LineLayer layer2 = c.addLineLayer(data2, 0x0000cc, "vs1 pressure");
layer2.setUseYAxis(leftAxis);
// output the chart
String chart1URL = c.makeSession(request, "chart1");
// Include tool tip for the chart
String imageMap1 = c.getHTMLImageMap("", "",
"title='time {xLabel}: average {value} GBytes'");
%>
Please help me to draw the axis. |
Re: How to set 8 different Y-axis in line chart |
Posted by Peter Kwan on Nov-15-2014 02:27 |
|
Hi Megha,
I have tried your code with hard coded data, and it works normally. I can see three y-axis.
I have attached my test code and the resulting chart for your reference.
If you think the code is not working, is it possible to provide an example that I can run
(please use hard coded data instead of "vb.getcahrtavgvs1()" because otherwise I cannot
run your code), and also attached the chart image you obtained to help me understand
what is the issue?
Regards
Peter Kwan
|
Re: How to set 8 different Y-axis in line chart |
Posted by Megha on Nov-17-2014 12:39 |
|
Hi Peter
Thanks for the response, it worked .
Now i want to trim the values along y axis upto 2 decimals i.e 2.8000E-9 to 2.80E-9.How to
do that. |
Re: How to set 8 different Y-axis in line chart |
Posted by Peter Kwan on Nov-18-2014 02:22 |
|
Hi Megha,
You may use the format string "{value|E2}".
Hope this can help.
Regards
Peter Kwan |
Re: How to set 8 different Y-axis in line chart |
Posted by Megha on Nov-18-2014 12:36 |
|
Hello Peter
Thanks it worked. |
|