addChart(chart);
}
//
private void showCombinationMultipleAxes() {
InvientChartsConfig chartConfig = new InvientChartsConfig();
chartConfig.getTitle()
.setText("Average Monthly Weather Data for Tokyo");
chartConfig.getSubtitle().setText("Source: WorldClimate.com");
chartConfig
.getTooltip()
.setFormatterJsFunc(
"function() {"
+ " var unit = { "
+ " 'Rainfall': 'mm',"
+ " 'Temperature': '°C',"
+ " 'Sea-Level Pressure': 'mb'"
+ " }[this.series.name];"
+ " return '' + this.x + ': ' + this.y + ' ' + unit; "
+ "}");
Legend legend = new Legend();
legend.setLayout(Layout.VERTICAL);
legend.setPosition(new Position());
legend.getPosition().setAlign(HorzAlign.LEFT);
legend.getPosition().setVertAlign(VertAlign.TOP);
legend.getPosition().setX(120);
legend.getPosition().setY(80);
legend.setFloating(true);
legend.setBackgroundColor(new RGB(255, 255, 255));
chartConfig.setLegend(legend);
CategoryAxis xAxis = new CategoryAxis();
xAxis.setCategories(Arrays.asList("Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"));
LinkedHashSet<XAxis> xAxesSet = new LinkedHashSet<InvientChartsConfig.XAxis>();
xAxesSet.add(xAxis);
chartConfig.setXAxes(xAxesSet);
// Multiple axes
NumberYAxis temperatureAxis = new NumberYAxis();
temperatureAxis.setAllowDecimals(false);
temperatureAxis.setLabel(new YAxisDataLabel());
temperatureAxis.getLabel().setFormatterJsFunc(
"function() {" + " return this.value +'°C'; " + "}");
temperatureAxis.getLabel().setStyle("{ color: '#89A54E' }");
temperatureAxis.setTitle(new AxisTitle("Temperature"));
temperatureAxis.getTitle().setStyle(" { color: '#89A54E' }");
temperatureAxis.setOpposite(true);
LinkedHashSet<YAxis> yAxesSet = new LinkedHashSet<InvientChartsConfig.YAxis>();
yAxesSet.add(temperatureAxis);
// secondary y-axis
NumberYAxis rainfallAxis = new NumberYAxis();
rainfallAxis.setGrid(new Grid());
rainfallAxis.getGrid().setLineWidth(0);
rainfallAxis.setTitle(new AxisTitle("Rainfall"));
rainfallAxis.getTitle().setStyle(" { color: '#4572A7' }");
rainfallAxis.setLabel(new YAxisDataLabel());
rainfallAxis.getLabel().setStyle("{ color: '#4572A7' }");
rainfallAxis.getLabel().setFormatterJsFunc(
"function() {" + " return this.value +' mm'; " + "}");
yAxesSet.add(rainfallAxis);
// tertiary y-axis
NumberYAxis sealevelPressureAxis = new NumberYAxis();
sealevelPressureAxis.setGrid(new Grid());
sealevelPressureAxis.getGrid().setLineWidth(0);
sealevelPressureAxis.setTitle(new AxisTitle("Sea-Level Pressure"));
sealevelPressureAxis.getTitle().setStyle(" { color: '#AA4643' }");
sealevelPressureAxis.setLabel(new YAxisDataLabel());
sealevelPressureAxis.getLabel().setStyle("{ color: '#AA4643' }");
sealevelPressureAxis.getLabel().setFormatterJsFunc(
"function() {" + " return this.value +' mb'; " + "}");
sealevelPressureAxis.setOpposite(true);
yAxesSet.add(sealevelPressureAxis);
chartConfig.setYAxes(yAxesSet);
InvientCharts chart = new InvientCharts(chartConfig);
// Configuration of Rainfall series
ColumnConfig colCfg = new ColumnConfig();
colCfg.setColor(new RGB(69, 114, 167));