Skip to content
Snippets Groups Projects
Commit 8c4c39eb authored by Carlos Lopez-Camey's avatar Carlos Lopez-Camey
Browse files

Merge branch 'develop' of github.com:timmolter/XChart into develop

parents ecfe997e d2973bc3
No related branches found
No related tags found
No related merge requests found
Showing
with 295 additions and 38 deletions
......@@ -109,11 +109,11 @@ For snapshots, add the following to your pom.xml file:
<dependency>
<groupId>org.knowm.xchart</groupId>
<artifactId>xchart</artifactId>
<version>2.6.2-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
</dependency>
```
Snapshots can be manually downloaded from Sonatyope: [https://oss.sonatype.org/content/groups/public/com/xeiam/xchart/xchart/](https://oss.sonatype.org/content/groups/public/com/xeiam/xchart/xchart/)
Snapshots can be manually downloaded from Sonatyope: [https://oss.sonatype.org/content/groups/public/org/knowm/xchart/xchart/](https://oss.sonatype.org/content/groups/public/org/knowm/xchart/xchart/)
### SBT
......@@ -140,7 +140,7 @@ libraryDependencies += "org.knowm.xchart" % "xchart" % "2.6.0" exclude("de.erich
## Running Demo
cd /path/to/xchart-demo/jar/
java -cp xchart-demo-2.6.0.jar:xchart-2.6.0.jar org.knowm.xchart.demo.XChartDemo
java -cp xchart-demo-2.6.1.jar:xchart-2.6.1.jar org.knowm.xchart.demo.XChartDemo
![](https://raw.githubusercontent.com/timmolter/XChart/develop/etc/XChart_Demo.png)
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.knowm.xchart</groupId>
<artifactId>xchart-parent</artifactId>
<version>2.6.2-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>XChart Parent</name>
<description>XChart is a light weight Java library for plotting data.</description>
......
......@@ -43,6 +43,7 @@ import org.knowm.xchart.demo.charts.bar.BarChart05;
import org.knowm.xchart.demo.charts.bar.BarChart06;
import org.knowm.xchart.demo.charts.bar.BarChart07;
import org.knowm.xchart.demo.charts.bar.BarChart08;
import org.knowm.xchart.demo.charts.bar.BarChart09;
import org.knowm.xchart.demo.charts.date.DateChart01;
import org.knowm.xchart.demo.charts.date.DateChart02;
import org.knowm.xchart.demo.charts.date.DateChart03;
......@@ -57,6 +58,8 @@ import org.knowm.xchart.demo.charts.line.LineChart03;
import org.knowm.xchart.demo.charts.line.LineChart04;
import org.knowm.xchart.demo.charts.line.LineChart05;
import org.knowm.xchart.demo.charts.line.LineChart06;
import org.knowm.xchart.demo.charts.line.LineChart07;
import org.knowm.xchart.demo.charts.pie.PieChart01;
import org.knowm.xchart.demo.charts.realtime.RealtimeChart01;
import org.knowm.xchart.demo.charts.realtime.RealtimeChart02;
import org.knowm.xchart.demo.charts.realtime.RealtimeChart03;
......@@ -217,6 +220,13 @@ public class XChartDemo extends JPanel implements TreeSelectionListener {
defaultMutableTreeNode = new DefaultMutableTreeNode(new ChartInfo("AreaLineChart03 - Combination Area & Line Chart", new AreaLineChart03().getChart()));
category.add(defaultMutableTreeNode);
// Pie category
category = new DefaultMutableTreeNode("Pie Charts");
top.add(category);
defaultMutableTreeNode = new DefaultMutableTreeNode(new ChartInfo("PieChart01 - Pie Chart with 4 Slices", new PieChart01().getChart()));
category.add(defaultMutableTreeNode);
// Line category
category = new DefaultMutableTreeNode("Line Charts");
top.add(category);
......@@ -239,6 +249,9 @@ public class XChartDemo extends JPanel implements TreeSelectionListener {
defaultMutableTreeNode = new DefaultMutableTreeNode(new ChartInfo("LineChart06 - Logarithmic Y-Axis with Error Bars", new LineChart06().getChart()));
category.add(defaultMutableTreeNode);
defaultMutableTreeNode = new DefaultMutableTreeNode(new ChartInfo("LineChart07 - Line Chart with Multiple Category Series", new LineChart07().getChart()));
category.add(defaultMutableTreeNode);
// Scatter category
category = new DefaultMutableTreeNode("Scatter Charts");
top.add(category);
......@@ -283,6 +296,9 @@ public class XChartDemo extends JPanel implements TreeSelectionListener {
defaultMutableTreeNode = new DefaultMutableTreeNode(new ChartInfo("BarChart08 - Histogram with Error Bars", new BarChart08().getChart()));
category.add(defaultMutableTreeNode);
defaultMutableTreeNode = new DefaultMutableTreeNode(new ChartInfo("BarChart09 - Category chart with Bar, Line and Scatter Series", new BarChart09().getChart()));
category.add(defaultMutableTreeNode);
// Theme category
category = new DefaultMutableTreeNode("Chart Themes");
top.add(category);
......
......@@ -16,6 +16,8 @@
*/
package org.knowm.xchart.demo.charts.bar;
import java.util.Arrays;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.StyleManager.ChartType;
......@@ -47,7 +49,7 @@ public class BarChart01 implements ExampleChart {
// Create Chart
Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("Score Histogram").xAxisTitle("Score").yAxisTitle("Number").build();
chart.addSeries("test 1", new double[] { 0, 1, 2, 3, 4 }, new double[] { 4, 5, 9, 6, 5 });
chart.addCategorySeries("test 1", Arrays.asList(new Integer[] { 0, 1, 2, 3, 4 }), Arrays.asList(new Integer[] { 4, 5, 9, 6, 5 }));
// Customize Chart
chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
......
......@@ -27,11 +27,11 @@ import java.util.Random;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesColor;
import org.knowm.xchart.StyleManager.ChartTheme;
import org.knowm.xchart.StyleManager.ChartType;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
import org.knowm.xchart.internal.style.MatlabTheme;
/**
* Date Categories
......@@ -75,8 +75,8 @@ public class BarChart02 implements ExampleChart {
xData.add(date);
yData.add(-1 * 0.00000001 * ((random.nextInt(i) + 1)));
}
Series series = chart.addSeries("Model 77", xData, yData);
series.setLineColor(SeriesColor.RED);
Series series = chart.addCategorySeries("Model 77", xData, yData);
series.setLineColor(MatlabTheme.RED);
chart.getStyleManager().setPlotGridLinesVisible(false);
chart.getStyleManager().setBarFilled(false);
chart.getStyleManager().setDatePattern("YYYY");
......
......@@ -16,6 +16,8 @@
*/
package org.knowm.xchart.demo.charts.bar;
import java.util.Arrays;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.StyleManager.ChartType;
......@@ -45,7 +47,7 @@ public class BarChart03 implements ExampleChart {
// Create Chart
Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("Score vs. Age").xAxisTitle("Age").yAxisTitle("Score").build();
chart.addSeries("males", new double[] { 10, 20, 30, 40 }, new double[] { 40, -30, -20, -60 });
chart.addCategorySeries("males", Arrays.asList(new Integer[] { 10, 20, 30, 40 }), Arrays.asList(new Integer[] { 40, -30, -20, -60 }));
return chart;
}
......
......@@ -16,6 +16,8 @@
*/
package org.knowm.xchart.demo.charts.bar;
import java.util.Arrays;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.StyleManager.ChartType;
......@@ -47,8 +49,8 @@ public class BarChart04 implements ExampleChart {
// Create Chart
Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("XFactor vs. Age").xAxisTitle("Age").yAxisTitle("XFactor").build();
chart.addSeries("female", new double[] { 10, 20, 30, 40, 50 }, new double[] { 50, 10, 20, 40, 35 });
chart.addSeries("male", new double[] { 10, 20, 30, 40, 50 }, new double[] { 40, 30, 20, 0, 60 });
chart.addCategorySeries("female", Arrays.asList(new Integer[] { 10, 20, 30, 40, 50 }), Arrays.asList(new Integer[] { 50, 10, 20, 40, 35 }));
chart.addCategorySeries("male", Arrays.asList(new Integer[] { 10, 20, 30, 40, 50 }), Arrays.asList(new Integer[] { 40, 30, 20, null, 60 }));
chart.getStyleManager().setYAxisMin(5);
chart.getStyleManager().setYAxisMax(70);
......
......@@ -49,10 +49,16 @@ public class BarChart05 implements ExampleChart {
// Create Chart
Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("Temperature vs. Color").xAxisTitle("Color").yAxisTitle("Temperature").theme(ChartTheme.GGPlot2).build();
chart.addSeries("fish", new ArrayList<String>(Arrays.asList(new String[] { "Blue", "Red", "Green", "Yellow", "Yellow" })), new ArrayList<Number>(Arrays.asList(new Number[] { -40, 30, 20, 60,
60 })));
chart.addSeries("worms", new ArrayList<String>(Arrays.asList(new String[] { "Blue", "Red", "Green", "Yellow", "Yellow" })), new ArrayList<Number>(Arrays.asList(new Number[] { 50, 10, -20, 40,
60 })));
chart.addCategorySeries("fish", new ArrayList<String>(Arrays.asList(new String[] { "Blue", "Red", "Green", "Yellow", "Orange" })), new ArrayList<Number>(Arrays.asList(new Number[] { -40, 30, 20,
60, 60 })));
chart.addCategorySeries("worms", new ArrayList<String>(Arrays.asList(new String[] { "Blue", "Red", "Green", "Yellow", "Orange" })), new ArrayList<Number>(Arrays.asList(new Number[] { 50, 10, -20,
40, 60 })));
chart.addCategorySeries("birds", new ArrayList<String>(Arrays.asList(new String[] { "Blue", "Red", "Green", "Yellow", "Orange" })), new ArrayList<Number>(Arrays.asList(new Number[] { 13, 22, -23,
-34, 37 })));
chart.addCategorySeries("ants", new ArrayList<String>(Arrays.asList(new String[] { "Blue", "Red", "Green", "Yellow", "Orange" })), new ArrayList<Number>(Arrays.asList(new Number[] { 50, 57, -14,
-20, 31 })));
chart.addCategorySeries("slugs", new ArrayList<String>(Arrays.asList(new String[] { "Blue", "Red", "Green", "Yellow", "Orange" })), new ArrayList<Number>(Arrays.asList(new Number[] { -2, 29, 49,
-16, -43 })));
return chart;
}
......
......@@ -53,8 +53,8 @@ public class BarChart06 implements ExampleChart {
Histogram histogram1 = new Histogram(getGaussianData(10000), 30, -30, 30);
Histogram histogram2 = new Histogram(getGaussianData(5000), 30, -30, 30);
chart.addSeries("histogram 1", histogram1.getxAxisData(), histogram1.getyAxisData());
chart.addSeries("histogram 2", histogram2.getxAxisData(), histogram2.getyAxisData());
chart.addCategorySeries("histogram 1", histogram1.getxAxisData(), histogram1.getyAxisData());
chart.addCategorySeries("histogram 2", histogram2.getxAxisData(), histogram2.getyAxisData());
// Customize Chart
chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
......
......@@ -53,9 +53,9 @@ public class BarChart07 implements ExampleChart {
Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("Score Histogram").xAxisTitle("Mean").yAxisTitle("Count").build();
Histogram histogram1 = new Histogram(getGaussianData(1000), 10, -30, 30);
chart.addSeries("histogram 1", histogram1.getxAxisData(), histogram1.getyAxisData());
chart.addCategorySeries("histogram 1", histogram1.getxAxisData(), histogram1.getyAxisData());
Histogram histogram2 = new Histogram(getGaussianData(1000), 10, -30, 30);
chart.addSeries("histogram 2", histogram2.getxAxisData(), histogram2.getyAxisData());
chart.addCategorySeries("histogram 2", histogram2.getxAxisData(), histogram2.getyAxisData());
// Customize Chart
chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
......
......@@ -52,7 +52,7 @@ public class BarChart08 implements ExampleChart {
Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("Histogram").xAxisTitle("Mean").yAxisTitle("Count").build();
Histogram histogram1 = new Histogram(getGaussianData(10000), 10, -10, 10);
chart.addSeries("histogram", histogram1.getxAxisData(), histogram1.getyAxisData(), getFakeErrorData(histogram1.getxAxisData().size()));
chart.addCategorySeries("histogram", histogram1.getxAxisData(), histogram1.getyAxisData(), getFakeErrorData(histogram1.getxAxisData().size()));
// Customize Chart
chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
......
/**
* Copyright 2015 Knowm Inc. (http://knowm.org) and contributors.
* Copyright 2011-2015 Xeiam LLC (http://xeiam.com) and contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.knowm.xchart.demo.charts.bar;
import java.util.ArrayList;
import java.util.Arrays;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.Series;
import org.knowm.xchart.Series.SeriesType;
import org.knowm.xchart.StyleManager.ChartTheme;
import org.knowm.xchart.StyleManager.ChartType;
import org.knowm.xchart.StyleManager.LegendPosition;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
/**
* Category chart with Bar, Line and Scatter Series
* <p>
* Demonstrates the following:
* <ul>
* <li>Mixed series types - Bar, Line and Scatter
* <li>Bar Chart styles - overlapped, bar width
*/
public class BarChart09 implements ExampleChart {
public static void main(String[] args) {
ExampleChart exampleChart = new BarChart09();
Chart chart = exampleChart.getChart();
new SwingWrapper(chart).displayChart();
}
@Override
public Chart getChart() {
// Create Chart
Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("Value vs. Letter").xAxisTitle("Letter").yAxisTitle("Value").theme(ChartTheme.GGPlot2).build();
chart.addCategorySeries("China", new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "C", "D", "E" })), new ArrayList<Number>(Arrays.asList(new Number[] { 11, 23, 20, 36, 5 })));
Series series2 = chart.addCategorySeries("Korea", new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "C", "D", "E" })), new ArrayList<Number>(Arrays.asList(new Number[] { 13, 25, 22, 38,
7 })), new ArrayList<Number>(Arrays.asList(new Number[] { 1, 3, 2, 1, 2 })));
series2.setSeriesType(SeriesType.Line);
Series series3 = chart.addCategorySeries("World Ave.", new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "C", "D", "E" })), new ArrayList<Number>(Arrays.asList(new Number[] { 20, 22,
18, 36, 32 })));
series3.setSeriesType(SeriesType.Scatter);
// Customize Chart
chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
chart.getStyleManager().setBarWidthPercentage(.55);
chart.getStyleManager().setBarsOverlapped(true);
return chart;
}
}
......@@ -21,11 +21,11 @@ import java.util.List;
import org.knowm.xchart.Chart;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesColor;
import org.knowm.xchart.SeriesLineStyle;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
import org.knowm.xchart.internal.style.XChartTheme;
/**
* Sine wave with customized series style
......@@ -65,9 +65,9 @@ public class LineChart02 implements ExampleChart {
// Series 1
Series series1 = chart.addSeries("y=sin(x)", xData, yData);
series1.setLineColor(SeriesColor.PURPLE);
series1.setLineColor(XChartTheme.PURPLE);
series1.setLineStyle(SeriesLineStyle.DASH_DASH);
series1.setMarkerColor(SeriesColor.GREEN);
series1.setMarkerColor(XChartTheme.GREEN);
series1.setMarker(SeriesMarker.SQUARE);
return chart;
......
......@@ -29,12 +29,12 @@ import java.util.Locale;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartColor;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesColor;
import org.knowm.xchart.SeriesLineStyle;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.StyleManager.LegendPosition;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
import org.knowm.xchart.internal.style.XChartTheme;
/**
* Extensive Chart Customization
......@@ -102,7 +102,7 @@ public class LineChart03 implements ExampleChart {
chart.getStyleManager().setLocale(Locale.GERMAN);
Series series = chart.addSeries("Fake Data", xData, yData);
series.setLineColor(SeriesColor.BLUE);
series.setLineColor(XChartTheme.BLUE);
series.setMarkerColor(Color.ORANGE);
series.setMarker(SeriesMarker.CIRCLE);
series.setLineStyle(SeriesLineStyle.SOLID);
......
......@@ -18,11 +18,11 @@ package org.knowm.xchart.demo.charts.line;
import org.knowm.xchart.Chart;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesColor;
import org.knowm.xchart.SeriesLineStyle;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
import org.knowm.xchart.internal.style.XChartTheme;
/**
* Hundreds of Series on One Plot
......@@ -50,10 +50,10 @@ public class LineChart04 implements ExampleChart {
for (int i = 0; i < 200; i++) {
Series series = chart.addSeries("A" + i, new double[] { Math.random() / 1000, Math.random() / 1000 }, new double[] { Math.random() / -1000, Math.random() / -1000 });
series.setLineColor(SeriesColor.BLUE);
series.setLineColor(XChartTheme.BLUE);
series.setLineStyle(SeriesLineStyle.SOLID);
series.setMarker(SeriesMarker.CIRCLE);
series.setMarkerColor(SeriesColor.BLUE);
series.setMarkerColor(XChartTheme.BLUE);
}
......
/**
* Copyright 2015 Knowm Inc. (http://knowm.org) and contributors.
* Copyright 2011-2015 Xeiam LLC (http://xeiam.com) and contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.knowm.xchart.demo.charts.line;
import java.util.Arrays;
import java.util.List;
import org.knowm.xchart.Chart;
import org.knowm.xchart.Series;
import org.knowm.xchart.Series.SeriesType;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.StyleManager.ChartTheme;
import org.knowm.xchart.StyleManager.ChartType;
import org.knowm.xchart.StyleManager.LegendPosition;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
/**
* Line chart with multiple Category Series
* <p>
* Demonstrates the following:
* <ul>
* <li>A Line Chart created from multiple category series types
* <li>GGPlot2 Theme
*/
public class LineChart07 implements ExampleChart {
public static void main(String[] args) {
ExampleChart exampleChart = new LineChart07();
Chart chart = exampleChart.getChart();
new SwingWrapper(chart).displayChart();
}
@Override
public Chart getChart() {
// Create Chart
Chart chart = new Chart(1024, 768, ChartTheme.GGPlot2);
chart.getStyleManager().setChartType(ChartType.Line);
// Customize Chart
chart.setChartTitle("ThreadPoolBenchmark");
chart.setXAxisTitle("Threads");
chart.setYAxisTitle("Executions");
chart.getStyleManager().setXAxisLabelRotation(270);
chart.getStyleManager().setLegendPosition(LegendPosition.OutsideE);
chart.getStyleManager().setBarWidthPercentage(0);
chart.getStyleManager().setBarsOverlapped(true);
// Declare data
List<String> xAxisKeys = Arrays.asList(new String[] { "release-0.5", "release-0.6", "release-0.7", "release-0.8", "release-0.9", "release-1.0.0", "release-1.1.0", "release-1.2.0", "release-1.3.0",
"release-2.0.0", "release-2.1.0", "release-2.2.0", "release-2.3.0", "release-2.4.0", "release-2.5.0", "release-2.6.0", "release-3.0.0", "release-3.1.0", "release-3.2.0", "release-3.3.0",
"release-3.4.0", "release-3.5.0", "release-3.6.0", "release-3.7.0", "release-3.8.0", "release-4.0.0", "release-4.1.0", "release-4.2.0", "release-4.3.0", "release-4.4.0", "release-4.4.1",
"release-4.4.2" });
String[] seriesNames = new String[] { "Threads:4", "Threads:10", "Threads:20", "Threads:50", "Threads:100", "Threads:150", "Threads:200", "Threads:250", "Threads:500", "Threads:750",
"Threads:1000", "Threads:1500", "Threads:2000", "Threads:2500" };
Integer[][] dataPerSeries = new Integer[][] { { 117355, 117594, 117551, 117719, 116553, 117304, 118945, 119067, 117803, 118080, 117676, 118599, 118224, 119263, 119455, 119393, 117961, 119254,
118447, 119428, 118812, 117947, 119405, 119329, 117749, 119331, 119354, 119519, 118494, 119780, 119766, 119742 }, { 127914, 128835, 128953, 128893, 128830, 129012, 129235, 129424, 129400,
129477, 129065, 129103, 129150, 129434, 129000, 129467, 128994, 129167, 129849, 128702, 134439, 134221, 134277, 134393, 134390, 134581, 134263, 134641, 134672, 137880, 137675, 137943 }, {
133396, 133977, 133992, 133656, 134406, 134657, 135194, 135497, 134881, 134873, 135065, 135045, 134480, 135004, 135111, 134720, 134639, 135505, 135831, 135974, 140965, 140759, 140545,
139959, 141063, 141339, 140967, 140927, 141972, 160884, 163402, 164572 }, { 122376, 122236, 122861, 122806, 122775, 122619, 122505, 122585, 122742, 122847, 122660, 122705, 122852,
122847, 122909, 122788, 122861, 123396, 123430, 122847, 121103, 121013, 120936, 120901, 121096, 120931, 121160, 121112, 121145, 175077, 174483, 175787 }, { 120048, 120226, 120745,
120669, 120647, 120683, 120499, 120533, 120628, 121059, 120901, 120838, 120845, 120954, 120963, 121055, 120948, 121111, 121239, 121094, 121422, 121249, 120924, 120918, 121061,
121063, 121065, 121098, 121011, 173280, 173179, 172193 }, { 119712, 119766, 120053, 120217, 119954, 120080, 120167, 119898, 120065, 120253, 120153, 120103, 120070, 120446,
120347, 120223, 120261, 120629, 120576, 120541, 121405, 121481, 121461, 121387, 121295, 121597, 121592, 121593, 121576, 171415, 170628, 169878 }, { 119807, 120232, 119745,
119892, 120024, 119854, 119818, 119908, 119685, 119816, 119848, 119919, 119627, 119906, 120242, 119974, 120116, 120472, 120304, 120294, 121308, 121338, 121278, 121292,
121418, 121570, 121564, 121541, 121571, 170597, 170346, 170434 }, { 121283, 121580, 120720, 120553, 121146, 120016, 119994, 120194, 120149, 120239, 120238, 120031,
120016, 120314, 120023, 120408, 120315, 120711, 121046, 120850, 121192, 121315, 121198, 121224, 121396, 121398, 121636, 121412, 121252, 168489, 169774, 168750 }, {
121219, 121594, 122576, 122368, 122874, 121831, 121386, 121433, 121722, 121600, 121158, 121653, 121306, 121652, 121982, 121775, 121819, 122243, 122128, 122067,
125185, 124972, 125023, 125004, 125120, 125320, 125395, 125134, 124838, 168492, 167673, 167087 }, { 121576, 122197, 121660, 121673, 122047, 120863, 120715,
120542, 120934, 120936, 120448, 120823, 120546, 121150, 120863, 120946, 120865, 121273, 120848, 121210, 124867, 124927, 124863, 124610, 124633, 124881,
124887, 124626, 124814, 167504, 167717, 165026 }, { 121822, 121540, 121488, 122055, 121253, 120728, 120626, 120474, 119848, 120129, 120082, 120075, 120429,
120859, 121228, 120390, 120161, 121465, 121085, 120682, 124287, 124029, 124162, 124185, 124024, 124416, 124558, 124206, 124109, 166816, 167583,
164828 }, { 121094, 121594, 121273, 121495, 121638, 120419, 119611, 119406, 119381, 120053, 119591, 120080, 120071, 119709, 120008, 120469, 119417,
120327, 120510, 119873, 123192, 123085, 123388, 123298, 123260, 122982, 123465, 123267, 122856, 164366, 163919, 166612 }, { 120639, 120628, 121443,
121160, 121245, 119819, 119865, 119300, 119466, 119478, 119870, 119720, 119671, 120333, 119718, 119528, 119581, 120716, 120624, 119585, 121685,
121978, 123017, 121433, 122190, 122330, 122458, 122090, 122234, 161976, 163628, 158023 }, { 120242, 120674, 120091, 120299, 120662, 119885,
119480, 119269, 118983, 119290, 119304, 119161, 119875, 118830, 119517, 119980, 119502, 120883, 118953, 119461, 120753, 120526, 120967,
120244, 122381, 121084, 122404, 121761, 121546, 161230, 160123, 160534 } };
// Add data series to chart
for (int i = 0; i < seriesNames.length; i++) {
Series series = chart.addCategorySeries(seriesNames[i], xAxisKeys, Arrays.asList(dataPerSeries[i]));
series.setMarker(SeriesMarker.NONE);
series.setSeriesType(SeriesType.Line);
}
chart.getStyleManager().setYAxisLogarithmic(true);
return chart;
}
}
/**
* Copyright 2015 Knowm Inc. (http://knowm.org) and contributors.
* Copyright 2011-2015 Xeiam LLC (http://xeiam.com) and contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.knowm.xchart.demo.charts.pie;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.StyleManager.ChartType;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
/**
* Pie Chart with 4 Slices
* <p>
* Demonstrates the following:
* <ul>
* <li>Pie Chart
* <li>ChartBuilder
*/
public class PieChart01 implements ExampleChart {
public static void main(String[] args) {
ExampleChart exampleChart = new PieChart01();
Chart chart = exampleChart.getChart();
new SwingWrapper(chart).displayChart();
}
@Override
public Chart getChart() {
// Create Chart
// TODO remove chartType(ChartType.Pie)
Chart chart = new ChartBuilder().chartType(ChartType.Pie).width(800).height(600).title(getClass().getSimpleName()).xAxisTitle("X").yAxisTitle("Y").build();
chart.addPieSeries("Pennies", 387);
chart.addPieSeries("Nickels", 234);
chart.addPieSeries("Dimes", 190);
chart.addPieSeries("Quarters", 270);
return chart;
}
}
......@@ -25,8 +25,6 @@ import java.util.List;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesLineStyle;
import org.knowm.xchart.StyleManager.ChartTheme;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.demo.charts.ExampleChart;
......@@ -104,8 +102,7 @@ public class ThemeChart03 implements ExampleChart {
e.printStackTrace();
}
Series series1 = chart.addSeries("downloads", xData, y1Data);
series1.setLineStyle(SeriesLineStyle.DOT_DOT);
chart.addSeries("downloads", xData, y1Data);
chart.addSeries("price", xData, y2Data);
return chart;
......
......@@ -20,10 +20,10 @@ import java.awt.Color;
import org.knowm.xchart.Chart;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesColor;
import org.knowm.xchart.SeriesLineStyle;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.internal.style.XChartTheme;
/**
* @author timmolter
......@@ -70,13 +70,13 @@ public class ErrorBarLogTest {
series2.setMarker(SeriesMarker.NONE);
series2.setLineColor(SeriesColor.RED);
series2.setLineColor(XChartTheme.RED);
series3.setLineStyle(SeriesLineStyle.DASH_DASH);
series3.setMarker(SeriesMarker.NONE);
series3.setLineColor(SeriesColor.RED);
series3.setLineColor(XChartTheme.RED);
new SwingWrapper(mychart).displayChart();
......
......@@ -20,10 +20,10 @@ import java.awt.Color;
import org.knowm.xchart.Chart;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesColor;
import org.knowm.xchart.SeriesLineStyle;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.internal.style.XChartTheme;
/**
* @author timmolter
......@@ -51,10 +51,10 @@ public class ErrorBarTest {
series1.setMarkerColor(Color.MAGENTA);
series2.setLineStyle(SeriesLineStyle.DASH_DASH);
series2.setMarker(SeriesMarker.NONE);
series2.setLineColor(SeriesColor.RED);
series2.setLineColor(XChartTheme.RED);
series3.setLineStyle(SeriesLineStyle.DASH_DASH);
series3.setMarker(SeriesMarker.NONE);
series3.setLineColor(SeriesColor.RED);
series3.setLineColor(XChartTheme.RED);
new SwingWrapper(mychart).displayChart();
}
......
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