## RadarChartOLAPDataModel: Basic Requirements

The main responsibility of a RadarChartOLAPDataModel is to map data members from an OLAP data structure to variable roles in a Radar 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 Radar chart's primary variable roles are

CategoryVariable
  Specifies a classification variable whose values determine the number and arrangement of spokes in the radar chart. A RadarChartOLAPDataModel maps this role to an OLAP column or row level, depending on the OLAP structure.
ResponseVariable
  Specifies an analysis variable whose values are represented by the radar spokes. A RadarChartOLAPDataModel maps this role to the first measure in the OLAP structure.
SubgroupVariable
  Generates a separate star for each subgroup value. A RadarChartOLAPDataModel uses this role if the OLAP axis that supplies the CategoryVariable role has more than one level and the RadarChart's subgroupEnabled field is true.

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 RadarChart, you must

- create an OLAPDataSet, either from the result set of a query that is executed on an OLAP provider or from the metadata that has been mapped to the OLAP data
- assign the OLAPDataSet to a RadarChartOLAPDataModel
- assign the RadarChartOLAPDataModel to a RadarChart.

The following code fragment generates a Radar chart that graphs the causes of failure for different cleaning processes that were used by a manufacturing system.

    // Create strings to store an SQL query, the OLAP server name,
    // and the connection port.
       String OLAP_QUERY="SELECT "
                       + "{[CAUSE].MEMBERS} ON COLUMNS,"
                       + "{[TIME].[MONTH].MEMBERS} ON ROWS "
                       + "FROM MYOLAPCUBE WHERE ([Measures].[COUNT])"; // specify a valid OLAP data source
       String OLAP_SERVER="myOlapServer.com"; // use a valid server name
       int OLAP_PORT=8800;                    // use a valid port

    // Create a RadarChartOLAPDataModel from an OLAPDataSet. The final argument
    // on the model constructor sets the chart's subgroupEnabled field to false.
       RadarChartOLAPDataModel olapDataModel = null;
       try {
            // OLAPDataSet arguments: host, port, username, pwd, query
               olapDataModel=new RadarChartOLAPDataModel(
               new OLAPDataSet(OLAP_SERVER, OLAP_PORT, "myUsername", "myPwd",
                               OLAP_QUERY), false);
           } catch (Exception ex) { ex.printStackTrace(); }

    // Create a RadarChart that uses the RadarChartOLAPDataModel as its data model
       RadarChart radarChart=new RadarChart();
       radarChart.setDataModel(olapDataModel);

Example
RadarChart Using OLAP Data: Swing-based code, Servlet-based code