Skip to content
Snippets Groups Projects
Commit b6e69245 authored by Tim Molter's avatar Tim Molter
Browse files

issue #55 allow passing into a Series int arrays

parent 5556b944
No related branches found
No related tags found
No related merge requests found
......@@ -46,11 +46,11 @@ public class LineChart06 implements ExampleChart {
@Override
public Chart getChart() {
double[] xData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
int[] xData = new int[] { 0, 1, 2, 3, 4, 5, 6 };
double[] yData1 = new double[] { 100, 100, 100, 60, 10, 10, 10 };
int[] yData1 = new int[] { 100, 100, 100, 60, 10, 10, 10 };
double[] errdata = new double[] { 50, 20, 10, 52, 9, 2, 1 };
int[] errdata = new int[] { 50, 20, 10, 52, 9, 2, 1 };
Chart chart = new Chart(800, 600);
......
......@@ -176,6 +176,52 @@ public class Chart {
return chartPainter.getAxisPair().addSeries(seriesName, xDataNumber, yDataNumber, errorBarDataNumber);
}
/**
* Add a series to the chart using double arrays
*
* @param seriesName
* @param xData the X-Axis data
* @param xData the Y-Axis data
* @return A Series object that you can set properties on
*/
public Series addSeries(String seriesName, int[] xData, int[] yData) {
return addSeries(seriesName, xData, yData, null);
}
/**
* Add a series to the chart using double arrays with error bars
*
* @param seriesName
* @param xData the X-Axis data
* @param xData the Y-Axis data
* @param errorBars the error bar data
* @return A Series object that you can set properties on
*/
public Series addSeries(String seriesName, int[] xData, int[] yData, int[] errorBars) {
List<Double> xDataNumber = null;
if (xData != null) {
xDataNumber = new ArrayList<Double>();
for (int d : xData) {
xDataNumber.add(new Double(d));
}
}
List<Double> yDataNumber = new ArrayList<Double>();
for (int d : yData) {
yDataNumber.add(new Double(d));
}
List<Double> errorBarDataNumber = null;
if (errorBars != null) {
errorBarDataNumber = new ArrayList<Double>();
for (int d : errorBars) {
errorBarDataNumber.add(new Double(d));
}
}
return chartPainter.getAxisPair().addSeries(seriesName, xDataNumber, yDataNumber, errorBarDataNumber);
}
/**
* Set the chart title
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment