The main responsibility of a PieChartOLAPDataModel is to map data members from an OLAP data structure to variable roles in a pie chart.
In your code, you can explicitly select measures in the OLAP data, or allow the component's OLAP data model to select measures by default.
A pie chart's primary variable roles are
To access OLAP data for a graph, you must know the name of the OLAP host server and connect to that server with a valid username and password. To use the OLAP data in a PieChart, you must
The following code fragment generates a pie chart that shows product sums for selected products, years, and countries.
// Create strings to store an SQL query, the OLAP server name,
// and the connection port.
String OLAP_QUERY="SELECT CROSSJOIN({[GEOGRAPHIC].[COUNTRY].MEMBERS},"
+ "{[PRODUCTLINE].[PRODUCT].MEMBERS}) ON COLUMNS,"
+ "{[TIME].[YEAR].MEMBERS} ON ROWS "
+ "FROM MYOLAPCUBE WHERE ([Measures].[ACTUAL_SUM])"; // specify valid OLAP source
String OLAP_SERVER="myOlapServer.com"; // specify a valid server name
int OLAP_PORT=8800; // specify a valid port
// Create a PieChartOLAPDataModel from an OLAPDataSet. The final argument
// on the model constructor sets the chart's subgroupEnabled field to true.
PieChartOLAPDataModel olapDataModel = null;
try {
// OLAPDataSet arguments: host, port, username, pwd, query
olapDataModel=new PieChartOLAPDataModel(
new OLAPDataSet(OLAP_SERVER, OLAP_PORT, "myUsername", "myPwd",
OLAP_QUERY), true);
} catch (Exception ex) { ex.printStackTrace(); }
// Create a PieChart that uses the PieChartOLAPDataModel as its data model
PieChart pieChart=new PieChart();
pieChart.setDataModel(olapDataModel);