public static MElementDataset getChartDataset(
      ANode parent, JRChartDataset jrObject, int newIndex) {
    if (jrObject == null) return null;
    if (parent instanceof MChart) {
      JRDesignChart chart = (JRDesignChart) parent.getValue();
      if (chart.getChartType() == JRDesignChart.CHART_TYPE_MULTI_AXIS) return null;
    }
    if (jrObject instanceof JRDesignCategoryDataset)
      return new MChartCategoryDataset(
          parent, (JRDesignCategoryDataset) jrObject, parent.getJasperDesign());
    if (jrObject instanceof JRDesignGanttDataset)
      return new MChartGanttDataset(
          parent, (JRDesignGanttDataset) jrObject, parent.getJasperDesign());
    if (jrObject instanceof JRDesignHighLowDataset)
      return new MChartHighLowDataset(
          parent, (JRDesignHighLowDataset) jrObject, parent.getJasperDesign());
    if (jrObject instanceof JRDesignPieDataset)
      return new MChartPieDataset(parent, (JRDesignPieDataset) jrObject, parent.getJasperDesign());
    if (jrObject instanceof JRDesignTimePeriodDataset)
      return new MChartTimePeriodDataset(
          parent, (JRDesignTimePeriodDataset) jrObject, parent.getJasperDesign());
    if (jrObject instanceof JRDesignTimeSeriesDataset)
      return new MChartTimeSeriesDataset(
          parent, (JRDesignTimeSeriesDataset) jrObject, parent.getJasperDesign());
    if (jrObject instanceof JRDesignValueDataset)
      return new MChartValueDataset(
          parent, (JRDesignValueDataset) jrObject, parent.getJasperDesign());
    if (jrObject instanceof JRDesignXyDataset)
      return new MChartXYDataset(parent, (JRDesignXyDataset) jrObject, parent.getJasperDesign());
    if (jrObject instanceof JRDesignXyzDataset)
      return new MChartXYZDataset(parent, (JRDesignXyzDataset) jrObject, parent.getJasperDesign());

    return new MChartDataset(parent, jrObject, parent.getJasperDesign());
  }
  public Object createObject(Attributes attrs) {
    JRDesignChart chart = (JRDesignChart) digester.peek();

    JRDesignTimeSeriesDataset dataset = null;

    if (chart.getDataset() == null) {
      dataset = new JRDesignTimeSeriesDataset(chart.getDataset());
    } else {
      dataset = (JRDesignTimeSeriesDataset) chart.getDataset();
    }

    String timePeriod = attrs.getValue(ATTRIBUTE_timePeriod);
    if (timePeriod != null && timePeriod.length() > 0) {
      dataset.setTimePeriod(JRXmlConstants.getTimePeriod(timePeriod));
    }

    chart.setDataset(dataset);

    return dataset;
  }