Hi,
I need to set the properties of the second value axis, i.e font family to Arial and font height to 10. I tried the following code, but it gives a null pointer exception.
chart.getSecondValueAxis().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontDataEx("Arial"));
chart.getSecondValueAxis().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(10f);
The entire code is:
ChartEx chart = sld.getShapes().addChart(ChartTypeEx.ClusteredColumn, 30, 60, 500, 480);
//Setting chart Title
chart.getChartTitle().getText().setText( "DC Wise Coverage");
chart.getChartTitle().getText().getParagraphs().get_Item(0).getPortions().get_Item(0).setLatinFont(new FontDataEx("Arial"));
chart.getChartTitle().getText().setCenterText(true);
chart.getChartTitle().getText().getParagraphs().get_Item(0).getPortions().get_Item(0).setFontHeight(12f);
chart.hasTitle(true);
//Set first series to Show Values
chart.getValueAxis().getMajorGridLines().getFillFormat().setFillType(FillTypeEx.NoFill);
chart.getValueAxis().setMinorTickMark(2);
chart.getValueAxis().setMajorTickMark(3);
chart.getCategoryAxis().setMajorTickMark(3);
chart.getCategoryAxis().setMinorTickMark(2);
chart.getLegend().setPosition(0);
//
chart.getCategoryAxis().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontDataEx("Arial"));
chart.getCategoryAxis().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(10f);
//
chart.getValueAxis().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontDataEx("Arial"));
chart.getValueAxis().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(10f);
//
chart.getLegend().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontDataEx("Arial"));
chart.getLegend().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(10f);
//
//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
//Getting the chart data worksheet
ChartDataCellFactory fact = chart.getChartData().getChartDataCellFactory();
//Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
int s = chart.getChartData().getSeries().getCapacity();
s = chart.getChartData().getCategories().getCapacity();
int chart_id = chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, "Target"), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, "Covered"), chart.getType());
int i = 1;
for (int j=1;j<=2;j++) {
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, i, 0, j));
ChartSeriesEx series = chart.getChartData().getSeries().get_Item(0);
series.getValues().add(fact.getCell(defaultWorksheetIndex, i, 1, 40));
series = chart.getChartData().getSeries().get_Item(1);
series.getValues().add(fact.getCell(defaultWorksheetIndex, i, 2, 20));
i++;
}
chart.getChartData().getSeries().get_Item(0).getLabels().setShowValue(true);
chart.getChartData().getSeries().get_Item(0).getLabels().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontDataEx("Arial"));
chart.getChartData().getSeries().get_Item(0).getLabels().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(10f);
chart.getChartData().getSeries().get_Item(1).getLabels().setShowValue(true);
chart.getChartData().getSeries().get_Item(1).getLabels().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontDataEx("Arial"));
chart.getChartData().getSeries().get_Item(1).getLabels().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(10f);
chart.getChartData().getSeries().get_Item(1).setPlotOnSecondAxis(true);
chart.getSecondValueAxis().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setLatinFont(new FontDataEx("Arial"));
chart.getSecondValueAxis().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(10f);
Request you to guide me solve this issue.
Regards,
Kiran B.