private void setDataByRow(final IPentahoResultSet data) {
    // TODO Make this routine MDX friendly
    if (data == null) {
      noDataMessage =
          Messages.getInstance().getString("CHART.USER_NO_DATA_AVAILABLE"); // $NON-NLS-1$
      return; // No data so we've got nothing to set
      // TODO come up with some sort of error strategy here.
    }
    Class timePeriodClass =
        TimeSeriesCollectionChartDefinition.getTimePeriodClass(getDomainPeriodType());
    Object[] rowData = data.next();
    while (rowData != null) {
      String seriesName = (String) rowData[0];
      TimeSeries wrkSeries = new TimeSeries(seriesName, timePeriodClass);
      for (int column = 1; column < rowData.length - 1; column = column + 2) {
        Date keyDate = getValidDate(rowData[column]);
        TimeSeriesDataItem timeSeriesDataItem =
            new TimeSeriesDataItem(
                RegularTimePeriod.createInstance(
                    timePeriodClass, keyDate, RegularTimePeriod.DEFAULT_TIME_ZONE),
                ((Number) rowData[column + 1]).doubleValue());
        wrkSeries.add(timeSeriesDataItem);
      }
      addSeries(wrkSeries);
      rowData = data.next();
    }

    if ((data.getRowCount() > 0) && (this.getSeriesCount() <= 0)) {
      noDataMessage =
          Messages.getInstance().getString("CHART.USER_INCORRECT_DATA_FORMAT"); // $NON-NLS-1$
    }
  }
 private void setDataByColumn(final IPentahoResultSet data) {
   // TODO Make this routine MDX friendly
   if (data == null) {
     noDataMessage =
         Messages.getInstance().getString("CHART.USER_NO_DATA_AVAILABLE"); // $NON-NLS-1$
     return; // No data so we've got nothing to set
     // TODO come up with some sort of error strategy here.
   }
   boolean firstPass = true;
   String lastSeries = ""; // $NON-NLS-1$
   String seriesName = ""; // $NON-NLS-1$
   Class timePeriodClass =
       TimeSeriesCollectionChartDefinition.getTimePeriodClass(getDomainPeriodType());
   Object[] rowData = data.next();
   TimeSeries wrkSeries = null;
   while (rowData != null) {
     seriesName = (String) rowData[0];
     if (firstPass || !seriesName.equalsIgnoreCase(lastSeries)) {
       if (!firstPass) {
         addSeries(wrkSeries);
       }
       wrkSeries = new TimeSeries(seriesName, timePeriodClass);
       lastSeries = seriesName;
       firstPass = false;
     }
     Date keyDate = getValidDate(rowData[1]);
     RegularTimePeriod regularTimePeriod =
         RegularTimePeriod.createInstance(
             timePeriodClass, keyDate, RegularTimePeriod.DEFAULT_TIME_ZONE);
     TimeSeriesDataItem timeSeriesDataItem =
         new TimeSeriesDataItem(regularTimePeriod, ((Number) rowData[2]).doubleValue());
     if (wrkSeries != null) {
       wrkSeries.add(timeSeriesDataItem);
     }
     rowData = data.next();
   }
   if (!firstPass) {
     addSeries(wrkSeries);
   }
   if ((data.getRowCount() > 0) && (this.getSeriesCount() <= 0)) {
     noDataMessage =
         Messages.getInstance().getString("CHART.USER_INCORRECT_DATA_FORMAT"); // $NON-NLS-1$
   }
 }
  @Override
  public Dataset createChart(final Document doc) {
    if (actionPath != null) { // if we have a solution then get the values
      values = getActionData();
    } else {
      // TODO support other methods of getting data
    }

    if (values == null) {
      // we could not get any data
      return null;
    }
    // get the chart node from the document
    Node chartAttributes =
        doc.selectSingleNode("//" + AbstractChartComponent.CHART_NODE_NAME); // $NON-NLS-1$
    // create the definition
    TimeSeriesCollectionChartDefinition chartDefinition =
        new TimeSeriesCollectionChartDefinition(
            (IPentahoResultSet) values, byRow, chartAttributes, getSession());

    // set the misc values from chartDefinition
    setChartType(chartDefinition.getChartType());
    setTitle(chartDefinition.getTitle());

    // get the URL template
    Node urlTemplateNode =
        chartAttributes.selectSingleNode(AbstractChartComponent.URLTEMPLATE_NODE_NAME);
    if (urlTemplateNode != null) {
      setUrlTemplate(urlTemplateNode.getText());
    }

    // get the additional parameter
    Node paramName2Node = chartAttributes.selectSingleNode(AbstractChartComponent.PARAM2_NODE_NAME);
    if (paramName2Node != null) {
      seriesName = paramName2Node.getText();
    }

    if ((chartDefinition.getWidth() != -1) && (width == -1)) {
      setWidth(chartDefinition.getWidth());
    }
    if ((chartDefinition.getHeight() != -1) && (height == -1)) {
      setHeight(chartDefinition.getHeight());
    }

    return chartDefinition;
  }
 public void setChartType(final Node chartTypeNode) {
   if (chartTypeNode != null) {
     String typeStr = chartTypeNode.getText();
     setChartType(TimeSeriesCollectionChartDefinition.getChartType(typeStr));
   }
 }