Hitachi Vantara Pentaho Community Wiki
Child pages
  • Introduction to Pentaho ChartBeans

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
titlecreateChartTableModel: Dummy Data
private static ChartTableModel createChartTableModel() {
    // 21 rows and 3 columns
    Object[][] dataArray = { 
                             {   5.55,  10.11,  20.22 }, 
                             {  30.33,  40.44,  50.55 }, 
                             {  31.33,  99.44, 150.55 },
                             {  32.33,   1.44,  30.55 }, 
                             {  34.33,  88.44,  77.55 }, 
                             {  35.33,  22.44,  54.55 }, 
                             {  36.33,  33.44,  52.55 },
                             {  37.33,  76.44,  54.55 }, 
                             {  38.33,   7.44,  59.55 }, 
                             {  39.33,  48.44,  56.55 }, 
                             {  40.33,  19.44,  57.55 },
                             {  50.33, 104.44,  36.55 }, 
                             {  60.33,  23.44,  74.55 }, 
                             {  20.33,  90.44,  80.55 }, 
                             {  60.33,  18.44,  27.55 },
                             {  10.33,  22.44,  97.55 }, 
                             {  20.33,  59.44,  55.55 }, 
                             {  90.33, 140.44,  22.55 }, 
                             { 100.33,  56.44,  76.55 },
                             {  40.33,  50.44,  50.55 }, 
                             {  60.66,  70.77,  80.88 } 
                           };

    ChartTableModel data = new ChartTableModel();
    data.setData(dataArray);

    // give names to the categories
    data.setColumnName(0, "budget");
    data.setColumnName(1, "sales");
    data.setColumnName(2, "forecast");

    // give names to the series
    final String ROW_NAME_KEY = "row-name";
    data.setRowMetadata(0, ROW_NAME_KEY, "1");
    data.setRowMetadata(1, ROW_NAME_KEY, "2");
    // ----- lines omitted -----
    data.setRowMetadata(20, ROW_NAME_KEY, "21");
    return data;
  }

...