import org.knowm.xchart.RadarChart;
import org.knowm.xchart.RadarChartBuilder;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.style.RadarStyler;
import org.knowm.xchart.style.Styler;
import org.knowm.xchart.style.markers.SeriesMarkers;
/**
* Radar Chart
*
* Demonstrates the following:
*
*
* - Radar Chart
*
- Circular style
*
- Tool tips
*
- GGPlot2 Theme
*/
public class xchart_radar2 {
public static void main(String[] args) {
RadarChart chart = getChart();
new SwingWrapper<>(chart).displayChart();
}
static public RadarChart getChart() {
// Create Chart
RadarChart chart =
new RadarChartBuilder()
.width(600)
.height(400)
.title("Circular Radar Chart with GGplot2 Theme")
.theme(Styler.ChartTheme.GGPlot2)
.build();
chart.getStyler().setToolTipsEnabled(true);
chart.getStyler().setRadarRenderStyle(RadarStyler.RadarRenderStyle.Circle);
chart.getStyler().setSeriesFilled(false);
chart.getStyler().setRadiiTickMarksCount(4);
chart.getStyler().setLegendPosition(Styler.LegendPosition.OutsideS);
chart.getStyler().setLegendLayout(Styler.LegendLayout.Horizontal);
// Series
chart.setRadiiLabels(
new String[] {
"Math",
"Biology",
"German",
"English",
"Chemistry",
"PhyEd",
"Band",
"Physics",
"Programming"
});
chart
.addSeries(
"Mark",
new double[] {
3.9 / 4.0, 2.9 / 4.0, 3.4 / 4.0, 2.8 / 4.0, 4 / 4.0, 2.4 / 4.0, 3.1 / 4.0, 2.9 / 4.0,
3.8 / 4.0
})
.setMarker(SeriesMarkers.NONE);
chart
.addSeries(
"Mary",
new double[] {
2.6 / 4.0, 3.3 / 4.0, 3.7 / 4.0, 3.1 / 4.0, 3.6 / 4.0, 3.2 / 4.0, 3.8 / 4.0,
3.7 / 4.0, 3.1 / 4.0
})
.setMarker(SeriesMarkers.NONE);
return chart;
}
}