Handle MTableChartHandler

This section provides information on the usage of MTable utility class by the application to build the dataset from MTable.

Perform the following steps to use the MTable utility functions to build the dataset.

1. Initialize the MTable with corresponding column key. Following is an example of education specific MTable initialization.

private MTable mDataTable = new MTable("SanityTable", 0);
mDataTable.addColumn("Quiz", 10, 4, 0);
mDataTable.addColumn("Value1", 10, 4, 0);
mDataTable.addColumn("Value2", 10, 4, 0);

2. Create the instance of MTableChartHandler and pass the Mtable instance to it. Date format can be passed through the constructor, or else default format is taken.

MTableChartHandler  mChartHandler = new MTableChartHandler(mDataTable);

3. Using the instance of MTableChartHandler, build the XYseries using the corresponding key.

buildXYSeries(…) takes four parameters:

  • Parameter 1 – Series Unique Key
  • Parameter 2 – Column Key of the MTable
  • Parameter 3 – Row Key of the MTable
  • Parameter 4 – Y-Axis Scale
XYSeries series1 = mChartHandler.buildXYSeries("Series1", "Quiz", "Value1", 0);

XYSeries series2 = mChartHandler.buildXYSeries("Series2", "Quiz", "Value2", 0);


4. Use the chart factory method to create the graph view.

lineChartView = ChartFactory.getLineChartView(this.getActivity(), mDataset, mRenderer);

5. Add the returned graph view to your app’s view group for display.