Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Pie Chart through Chart API
Rapporter
Hi Everyone,
I am trying to generate pie chart through Chart API. My generated chart has legend but chart is not coming up. There is no exception even. Please help.
I am using the following code:-
ElementFactory designFactory = objReportDesignHandle.getElementFactory();
ChartWithoutAxes newChart = ChartWithoutAxesImpl.create();
newChart.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL);
newChart.setType("Pie Chart"); //$NON-NLS-1$ cwoaPie.setSubType( "Standard Pie Chart" );
newChart.setSubType( "Standard Pie Chart" );
newChart.getBlock().setBackground(ColorDefinitionImpl.WHITE());
newChart.getBlock().setBounds(BoundsImpl.create(0, 0, 800, 150));
Plot p = newChart.getPlot();
p.getClientArea().setBackground(ColorDefinitionImpl.create(255, 204, 255));
newChart.getTitle().setVisible(false);
Legend lg = newChart.getLegend();
LineAttributes lia = lg.getOutline();
lg.getText().getFont().setSize(8);
lia.setStyle(LineStyle.SOLID_LITERAL);
lg.getInsets().set(1, 1, 1, 1);
lg.getOutline().setVisible(false);
lg.setAnchor(Anchor.NORTH_LITERAL);
Series seCategory = SeriesImpl.create();
Query query = QueryImpl.create("row["" + strXParameter + ""]");
seCategory.getDataDefinition().add(query);
PieSeries ls1 = (PieSeries) PieSeriesImpl.create();
ls1.setSeriesIdentifier(strYParameter);
Query query1 = QueryImpl.create("row["" + strYParameter + ""]");
ls1.getDataDefinition().add(query1);
/*ls1.getLineAttributes().setColor(ColorDefinitionImpl.RED());
ls1.getMarker().setType(MarkerType.CIRCLE_LITERAL);
ls1.getLabel().setVisible(true);*/
ls1.getLabel().getCaption().setValue(strXParameter);
SeriesDefinition sdX = SeriesDefinitionImpl.create();
sdX.getSeriesPalette().update(0);
newChart.getSeriesDefinitions().add(sdX);
sdX.getSeries().add(seCategory);
SeriesDefinition sdY1 = SeriesDefinitionImpl.create();
sdY1.getSeriesPalette().update(0);
sdY1.getSeries().add(ls1);
sdY1.getQuery().setDefinition(""" + strYParameter + """);
sdY1.getSeries().add(ls1);
ExtendedItemHandle extendedItemHandle = designFactory.newExtendedItem(null, mDealsConstantsUtility.STR_REPORT_CHART);
extendedItemHandle.getReportItem().setProperty(mDealsConstantsUtility.STR_REPORT_CHART_INSTANCE, newChart);
try {
extendedItemHandle.setDataSet(objReportDesignHandle.findDataSet(strDataSetName));
extendedItemHandle.setHeight(mDealsConstantsUtility.STR_REPORT_CHART_HEIGHT);
extendedItemHandle.setWidth(mDealsConstantsUtility.STR_REPORT_CHART_WIDTH);
} catch (SemanticException e) {
e.printStackTrace();
}
PropertyHandle cs = extendedItemHandle.getColumnBindings();
ComputedColumn cs1 = StructureFactory.createComputedColumn();
cs1.setName(strXParameter);
cs1.setExpression((new StringBuilder("dataSetRow["")).append(strXParameter).append(""]").toString());
cs.addItem(cs1);
ComputedColumn cs2 = StructureFactory.createComputedColumn();
cs2.setName(strYParameter);
cs2.setExpression("dataSetRow["" + strYParameter + ""]");
cs.addItem(cs2);
objReportDesignHandle.getBody().add(extendedItemHandle);
Find more posts tagged with
Comments
There are no comments yet