Ejemplo n.º 1
0
  /** @generated */
  protected void set(SampleData src) {

    // children

    if (src.getBaseSampleData() != null) {
      EList<BaseSampleData> list = getBaseSampleData();
      for (BaseSampleData element : src.getBaseSampleData()) {
        list.add(element.copyInstance());
      }
    }

    if (src.getOrthogonalSampleData() != null) {
      EList<OrthogonalSampleData> list = getOrthogonalSampleData();
      for (OrthogonalSampleData element : src.getOrthogonalSampleData()) {
        list.add(element.copyInstance());
      }
    }

    if (src.getAncillarySampleData() != null) {
      EList<BaseSampleData> list = getAncillarySampleData();
      for (BaseSampleData element : src.getAncillarySampleData()) {
        list.add(element.copyInstance());
      }
    }
  }
Ejemplo n.º 2
0
  private SampleData getConvertedSampleData(
      SampleData currentSampleData, int iSeriesDefinitionIndex) {
    // Do NOT convert the base sample data since the base axis is not being
    // changed

    // Convert orthogonal sample data
    EList<OrthogonalSampleData> osdList = currentSampleData.getOrthogonalSampleData();
    for (int i = 0; i < osdList.size(); i++) {
      if (i == iSeriesDefinitionIndex) {
        OrthogonalSampleData osd = osdList.get(i);
        osd.setDataSetRepresentation(
            getConvertedOrthogonalSampleDataRepresentation(osd.getDataSetRepresentation()));
        currentSampleData.getOrthogonalSampleData().set(i, osd);
      }
    }
    return currentSampleData;
  }
Ejemplo n.º 3
0
  public static final Chart createSeriesScript() {
    ChartWithAxes cwaBar = ChartWithAxesImpl.create();
    cwaBar.setType("Bar Chart"); // $NON-NLS-1$
    cwaBar.setSubType("Side-by-side"); // $NON-NLS-1$

    cwaBar.setScript(
        "function beforeDrawSeries(series, renderer, scriptContext)" //$NON-NLS-1$
            + "{series.getLabel().getCaption().getColor().set(12, 232, 182);}" //$NON-NLS-1$
        );

    cwaBar.getLegend().setVisible(false);
    cwaBar.getTitle().getLabel().getCaption().setValue("Chart with Series Script"); // $NON-NLS-1$

    // X-Axis
    Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];
    xAxisPrimary.setType(AxisType.TEXT_LITERAL);
    xAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITERAL);

    // Y-Axis
    Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(xAxisPrimary);
    yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
    yAxisPrimary.setType(AxisType.LINEAR_LITERAL);

    // Data Set
    TextDataSet categoryValues =
        TextDataSetImpl.create(
            new String[] {
              "Item 1", "Item 2", "Item 3", "Item 4", "Item 5"
            }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    NumberDataSet orthoValues = NumberDataSetImpl.create(new double[] {8, 18, -15, -8, 10});

    SampleData sd = DataFactory.eINSTANCE.createSampleData();
    BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData();
    sdBase.setDataSetRepresentation(""); // $NON-NLS-1$
    sd.getBaseSampleData().add(sdBase);

    OrthogonalSampleData sdOrthogonal = DataFactory.eINSTANCE.createOrthogonalSampleData();
    sdOrthogonal.setDataSetRepresentation(""); // $NON-NLS-1$
    sdOrthogonal.setSeriesDefinitionIndex(0);
    sd.getOrthogonalSampleData().add(sdOrthogonal);

    cwaBar.setSampleData(sd);

    // X-Series
    Series seCategory = SeriesImpl.create();
    seCategory.setDataSet(categoryValues);

    SeriesDefinition sdX = SeriesDefinitionImpl.create();
    xAxisPrimary.getSeriesDefinitions().add(sdX);
    sdX.getSeries().add(seCategory);

    // Y-Series
    BarSeries bs = (BarSeries) BarSeriesImpl.create();
    bs.setDataSet(orthoValues);
    bs.getLabel().setVisible(true);

    SeriesDefinition sdY = SeriesDefinitionImpl.create();
    yAxisPrimary.getSeriesDefinitions().add(sdY);
    sdY.getSeries().add(bs);

    return cwaBar;
  }