Apache POI add a Series name into LineChart

It was pretty straight forward, just instead of using:

data.addSeries(xs, ys);

I had to be using:

LineChartSeries chartSeries = data.addSeries(xs, ys);
chartSeries.setTitle("My Title");

Didn't look at the API that using data.addSeries(xs, ys); returns a single LineChartSeries object onto which I can set a title.


From Apache POI version 3.16 onwards, use setTitleText("Title Name") instead. Also the correct class name is LineChartSeries not LineChartSerie. So, the above solution would look like:

LineChartSeries chartSeries = data.addSeries(xs,ys);
chartSeries.setTitleText("My Title");

for Apache POI 3.16 onwards.