コード例 #1
0
  /*
   * (non-Javadoc)
   *
   * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildChart()
   */
  protected void createChart() {
    data = adapter.getData();
    while (data.length == 0) {
      data = adapter.getData();
    }
    IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore();
    xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS);
    ySeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS);
    maxItems = store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS);
    viewableItems = store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS);

    chart = ChartWithAxesImpl.create();

    chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL);
    chart.setType("Scatter Chart");

    // Plot
    // chart.getBlock( ).setBackground(ColorDefinitionImpl.WHITE( ) );
    //  Plot p = chart.getPlot( );
    ///  p.getClientArea( ).setBackground(GradientImpl.create( ColorDefinitionImpl.create(
    // 225,225,255 ),ColorDefinitionImpl.create( 255, 255, 225 ),-35,false ) );
    // p.getOutline( ).setVisible( true );
    // Title        cwaBar.getTitle( )                .getLabel()                .getCaption( )
    //           .setValue( "Bar Chart with        Multiple Y Series" );//$NON-NLS-1$
    // Legend
    // Legend lg = cwaBar.getLegend( );
    // lg.getText(
    // ).getFont( ).setSize( 16 );        lg.getInsets( ).set( 10, 5, 0, 0 );
    // lg.setAnchor( Anchor.NORTH_LITERAL );

  }
コード例 #2
0
ファイル: SeriesScript.java プロジェクト: carlthronson/birt
  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;
  }