//a general legend configuration to use in all our charts.
ChartLegendConfig legendConfig1 = ChartLegendConfig.create();
//a first cartesian chart.
CartesianChartConfig chartConfig = CartesianChartConfig.create().cast();
chartConfig.categoryKey("date");
chartConfig.dataProvider(data1);
chartConfig.render("#chart1");
chartConfig.legend(legendConfig1);
chartConfig.axe("category", AxisConfig.create().
keys(new String[]{"date"}).
styles(AxisStyle.create().
label(AxisStyle.Label.create().rotation(45).fontSize("9px"))
).
type("category")
);
CartesianChart chart1 = Y.newChart(chartConfig).cast();
chart1.boundingBox().getNode("parentNode").getNode("parentNode").
append("<p>a default chart with custom axes</p>");
//now a second chart of type columns and a custom legend style. use the same config object
chartConfig.type(ChartBase.TYPE_COLUMN);
chartConfig.render("#chart2");
chartConfig.legend(ChartLegendConfig.create().position("left"));
CartesianChart chart2 = Y.newChart(chartConfig).cast().cast();
chart2.boundingBox().getNode("parentNode").getNode("parentNode").
append("<p>A <b>column</b> chart with custom axes and legend style</p>");
//now the same chart of type bar and custom bar colors
chartConfig.type(ChartBase.TYPE_BAR);
chartConfig.render("#chart3");
chartConfig.legend(ChartLegendConfig.create().position("bottom"));
chartConfig.seriesCollection(new CartesianSeries[]{
// CartesianSeries.C
});
CartesianChart chart3 = Y.newChart(chartConfig).cast().cast();
chart3.boundingBox().getNode("parentNode").getNode("parentNode").
append("<p>the same as before but type <b>bar</b> and bottom legend and and custom bar colors.</p>");
chartConfig.type(ChartBase.TYPE_MARKERSERIES);
chartConfig.render("#chart4");
chartConfig.legend(ChartLegendConfig.create().position("bottom"));
CartesianChart chart4 = Y.newChart(chartConfig).cast().cast();
chart4.boundingBox().getNode("parentNode").getNode("parentNode").
append("<p>the same as before but type <b>markseries</b></p>");
}