Home » Archived » BIRT » How to update a PriChart with new datas
How to update a PriChart with new datas [message #655966] |
Wed, 23 February 2011 15:15 |
kkt8 Mising name Messages: 27 Registered: November 2010 |
Junior Member |
|
|
Hello,
I create a PieChart in a view like this :
public constructorDemaclass(){
...
produceChart();
}
public Chart produceChart(){
{
...
objectsCODE[0] = new DataObject("CODE", "startup", 32.);
objectsCODE[1] = new DataObject("CODE", "thandlers", 408.);
objectsCODE[2] = new DataObject("CODE", "text", 152560.);
PieChartCode = new PieChartFactory(objectsCODE, labelField, null);
chart1 = PieChartCode.producePieChart(null, "CODE");
...
}
}
public void createPartControl(Composite parent) {
cParent = parent;
try {
paintCanvas = new Canvas( parent, SWT.BORDER |SWT.V_SCROLL );
paintCanvas.getVerticalBar().setEnabled(false);
paintCanvas.setLayoutData( new GridData( GridData.FILL_BOTH ) );
paintCanvas.setBackground( Display.getDefault( ).getSystemColor( SWT.COLOR_WHITE ) );
chartViewer = new ChartViewer( );
paintCanvas.addPaintListener( chartViewer );
paintCanvas.addControlListener( chartViewer );
chartViewer.setViewer( paintCanvas );
createActions(parent);
IActionBars actionBars = getViewSite().getActionBars();
initToolBar(actionBars.getToolBarManager());
chartViewer.renderModel(chart1);
saveChartAction.setChart(chart1);
saveChartAction.setBounds(chartViewer.getBounds());
saveXMLAction.setChart(chart1);
if (chart instanceof ChartWithoutAxes){
valueSeriesDetailsAction = new ValueSeriesDetailsAction(this);
getViewSite().getActionBars().getToolBarManager().add(valueSeriesDetailsAction);
}
else {
coloredByAction = new ColoredByAction(this);
getViewSite().getActionBars().getToolBarManager().add(coloredByAction);
}
getViewSite().getActionBars().getToolBarManager().update(true);
} catch (Throwable _)
{
Status s = new Status(
Status.ERROR,
Activator.PLUGIN_ID,
Status.ERROR,
"Error when creating AWT Frame...",
_);
Activator.getDefault().getLog().log(s);
}
}
public Chart producePieChart(IChartField valField,String title)
{
ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
cwoaPie.setSeriesThickness( 20 );
cwoaPie.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
//cwoaPie.getBlock( ).setBounds(BoundsImpl.create(0,0,252,288));
Bounds bd = cwoaPie.getBlock( ).getBounds();
cwoaPie.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL);
// Plot
Plot p = cwoaPie.getPlot( );
p.getClientArea( ).setBackground( null );
p.getClientArea( ).getOutline( ).setVisible( false );
// Legend
Legend lg = cwoaPie.getLegend( );
lg.getOutline( ).setVisible( false );
lg.getText( ).getFont( ).setSize( 8 );
lg.getClientArea().setBackground(ColorDefinitionImpl.create(255, 255, 204));
((ColorDefinitionImpl)lg.getClientArea().getBackground()).brighter();
lg.setAnchor(Anchor.NORTH_LITERAL);
lg.setItemType( LegendItemType.CATEGORIES_LITERAL );
// Title
cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue(title);
cwoaPie.getTitle( ).getOutline( ).setVisible( false );
//Base Data Set
List<String> textLabelsCODE = new ArrayList<String>();
for (DataObject obj : objData) {
textLabelsCODE.add(obj.sousSection);
}
TextDataSet categoryCODEValues = TextDataSetImpl.create(textLabelsCODE );
// Base Series
Series seCategoryCODE = SeriesImpl.create( );
seCategoryCODE.setDataSet( categoryCODEValues );
SeriesDefinition sdBase = SeriesDefinitionImpl.create( );
cwoaPie.getSeriesDefinitions( ).add( sdBase );
sdBase.getSeries( ).add( seCategoryCODE );
// Personnalise les couleurs
sdBase.getSeriesPalette().getEntries().clear();
int nbCode = sectSize.GetNbCode();
for(int i = 0; i<nbCode; i++)
{
sdBase.getSeriesPalette().getEntries().add(ColorDefinitionImpl.create(255, (i*(200/nbCode)), 0));
}
int nbData = sectSize.GetNbData();
for(int i = 0; i<nbData; i++)
{
sdBase.getSeriesPalette().getEntries().add(ColorDefinitionImpl.create(0, (i*(200/nbData)), 255));
}
SeriesDefinition sdValue = SeriesDefinitionImpl.create( );
sdBase.getSeriesDefinitions( ).add( sdValue );
List<Double> doubleValues = new ArrayList<Double>();
for (DataObject obj : objData) {
doubleValues.add(obj.size);
}
NumberDataSet Values = NumberDataSetImpl.create(doubleValues);
// Pie Series
PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
sePie.setExplosion(2);
sePie.setDataSet( Values );
sePie.getLabel().getCaption().getFont().setSize(8);
sePie.setLeaderLineStyle(LeaderLineStyle.FIXED_LENGTH_LITERAL);
sePie.setLeaderLineLength(15);
DataPointComponent dpc = DataPointComponentImpl.create( DataPointComponentType.ORTHOGONAL_VALUE_LITERAL,JavaNumberFormatSpecifierImpl.create( "###.###,00" ) );
sePie.getDataPoint( ).getComponents( ).clear( );
sePie.getDataPoint( ).getComponents( ).add( dpc );
//By default the title of the Value Series is not visible
sePie.getTitle().setVisible(false);
//Mouse over the Serie to Show Tooltips
setTriggering(sePie,lg);
sdValue.getSeries( ).add( sePie);
return cwoaPie;
}
It works very well
but I want, in a event, to update the PieChart with new datas.
I try to modify directly the collections of datas but no it dosen't work !
Have you an idea ??
Many thanks !!!
ç
|
|
|
Re: How to update a PriChart with new datas [message #655983 is a reply to message #655966] |
Wed, 23 February 2011 16:03 |
|
Here is a class from the source that shows how to do this. I have
modified it slightly.
/*********************************************************** ************
* Copyright (c) 2004, 2007 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
************************************************************ ***********/
package my.swt.live.viewer;
import org.eclipse.birt.chart.api.ChartEngine;
import org.eclipse.birt.chart.device.IDeviceRenderer;
import org.eclipse.birt.chart.exception.ChartException;
import org.eclipse.birt.chart.factory.GeneratedChartState;
import org.eclipse.birt.chart.factory.Generator;
import org.eclipse.birt.chart.log.ILogger;
import org.eclipse.birt.chart.log.Logger;
import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.ChartWithAxes;
import org.eclipse.birt.chart.model.ChartWithoutAxes;
import org.eclipse.birt.chart.model.attribute.AxisType;
import org.eclipse.birt.chart.model.attribute.Bounds;
import org.eclipse.birt.chart.model.attribute.ChartDimension;
import org.eclipse.birt.chart.model.attribute.IntersectionType;
import org.eclipse.birt.chart.model.attribute.LineAttributes;
import org.eclipse.birt.chart.model.attribute.LineStyle;
import org.eclipse.birt.chart.model.attribute.Marker;
import org.eclipse.birt.chart.model.attribute.MarkerType;
import org.eclipse.birt.chart.model.attribute.Position;
import org.eclipse.birt.chart.model.attribute.RiserType;
import org.eclipse.birt.chart.model.attribute.TickStyle;
import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl;
import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionI mpl;
import org.eclipse.birt.chart.model.component.Axis;
import org.eclipse.birt.chart.model.component.Series;
import org.eclipse.birt.chart.model.component.impl.SeriesImpl;
import org.eclipse.birt.chart.model.data.BaseSampleData;
import org.eclipse.birt.chart.model.data.DataFactory;
import org.eclipse.birt.chart.model.data.NumberDataSet;
import org.eclipse.birt.chart.model.data.OrthogonalSampleData;
import org.eclipse.birt.chart.model.data.SampleData;
import org.eclipse.birt.chart.model.data.SeriesDefinition;
import org.eclipse.birt.chart.model.data.TextDataSet;
import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl;
import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl;
import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl;
import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl;
import org.eclipse.birt.chart.model.layout.Legend;
import org.eclipse.birt.chart.model.layout.Plot;
import org.eclipse.birt.chart.model.type.BarSeries;
import org.eclipse.birt.chart.model.type.LineSeries;
import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl;
import org.eclipse.birt.chart.model.type.impl.LineSeriesImpl;
import org.eclipse.birt.core.framework.PlatformConfig;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class SwtLiveChartViewer extends Composite implements PaintListener
{
private IDeviceRenderer idr = null;
private Chart cm = null;
private GeneratedChartState gcs = null;
private static SwtLiveChartViewer c3dViewer;
/**
* Used in building the chart for the first time
*/
private boolean bFirstPaint = true;
//private static ILogger logger = Logger.getLogger(
JavaScriptViewer.class.getName( ) );
/**
* execute application
*
* @param args
*/
public static void main( String[] args )
{
Display display = Display.getDefault( );
Shell shell = new Shell( display, SWT.CLOSE );
shell.setSize( 600, 400 );
shell.setLayout( new GridLayout( ) );
c3dViewer = new SwtLiveChartViewer( shell, SWT.NO_BACKGROUND );
c3dViewer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
c3dViewer.addPaintListener( c3dViewer );
shell.open( );
while ( !shell.isDisposed( ) )
{
if ( !display.readAndDispatch( ) )
display.sleep( );
}
display.dispose( );
}
/**
* Constructor
*/
SwtLiveChartViewer( Composite parent, int style )
{
super( parent, style );
try
{
PlatformConfig config = new PlatformConfig( );
config.setProperty( "STANDALONE", "true" ); //$NON-NLS-1$ //$NON-NLS-2$
idr = ChartEngine.instance( config ).getRenderer( "dv.SWT"
);//$NON-NLS-1$
}
catch ( ChartException pex )
{
//logger.log( pex );
}
cm = createLiveChart( );
}
public static final Chart createLiveChart( )
{
ChartWithAxes cwaBar = ChartWithAxesImpl.create( );
// Plot
cwaBar.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
Plot p = cwaBar.getPlot( );
p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,
255,
225 ) );
// Legend
Legend lg = cwaBar.getLegend( );
LineAttributes lia = lg.getOutline( );
lg.getText( ).getFont( ).setSize( 16 );
lia.setStyle( LineStyle.SOLID_LITERAL );
lg.getInsets( ).setLeft( 10 );
lg.getInsets( ).setRight( 10 );
// Title
cwaBar.getTitle( )
.getLabel( )
.getCaption( )
.setValue( "Live Chart Demo" );//$NON-NLS-1$
// X-Axis
Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];
xAxisPrimary.setType( AxisType.TEXT_LITERAL );
xAxisPrimary.getOrigin( ).setType( IntersectionType.VALUE_LITERAL );
xAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
xAxisPrimary.getTitle( )
.getCaption( )
.setValue( "Category Text X-Axis" );//$NON-NLS-1$
xAxisPrimary.setTitlePosition( Position.BELOW_LITERAL );
xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 75 );
xAxisPrimary.setLabelPosition( Position.BELOW_LITERAL );
xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
xAxisPrimary.getMajorGrid( )
.getLineAttributes( )
.setStyle( LineStyle.DOTTED_LITERAL );
xAxisPrimary.getMajorGrid( )
.getLineAttributes( )
.setColor( ColorDefinitionImpl.create( 64, 64, 64 ) );
xAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
// Y-Axis
Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );
yAxisPrimary.getLabel( ).getCaption( ).setValue( "Price Axis"
);//$NON-NLS-1$
yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 37 );
yAxisPrimary.setLabelPosition( Position.LEFT_LITERAL );
yAxisPrimary.setTitlePosition( Position.LEFT_LITERAL );
yAxisPrimary.getTitle( ).getCaption( ).setValue( "Linear Value Y-Axis"
);//$NON-NLS-1$
yAxisPrimary.setType( AxisType.LINEAR_LITERAL );
yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
yAxisPrimary.getMajorGrid( )
.getLineAttributes( )
.setStyle( LineStyle.DOTTED_LITERAL );
yAxisPrimary.getMajorGrid( )
.getLineAttributes( )
.setColor( ColorDefinitionImpl.RED( ) );
yAxisPrimary.getMajorGrid( ).getLineAttributes( ).setVisible( true );
// X-Series
Series seCategory = SeriesImpl.create( );
SeriesDefinition sdX = SeriesDefinitionImpl.create( );
xAxisPrimary.getSeriesDefinitions( ).add( sdX );
sdX.getSeries( ).add( seCategory );
// Y-Series (1)
BarSeries bs1 = (BarSeries) BarSeriesImpl.create( );
bs1.setSeriesIdentifier( "Unit Price" );//$NON-NLS-1$
bs1.setRiserOutline( null );
bs1.setRiser( RiserType.RECTANGLE_LITERAL );
// Y-Series (2)
LineSeries ls1 = (LineSeries) LineSeriesImpl.create( );
ls1.setSeriesIdentifier( "Quantity" );//$NON-NLS-1$
ls1.getLineAttributes( ).setColor( ColorDefinitionImpl.GREEN( ) );
for ( int i = 0; i < ls1.getMarkers( ).size( ); i++ )
{
( (Marker) ls1.getMarkers( ).get( i ) ).setType(
MarkerType.BOX_LITERAL );
}
ls1.setCurve( true );
SeriesDefinition sdY = SeriesDefinitionImpl.create( );
yAxisPrimary.getSeriesDefinitions( ).add( sdY );
sdY.getSeriesPalette( ).shift( -1 );
sdY.getSeries( ).add( bs1 );
sdY.getSeries( ).add( ls1 );
// Update data
updateDataSet( cwaBar );
return cwaBar;
}
static final void updateDataSet( ChartWithAxes cwaBar )
{
// Associate with Data Set
TextDataSet categoryValues = TextDataSetImpl.create( sa );
NumberDataSet seriesOneValues = NumberDataSetImpl.create( da1 );
NumberDataSet seriesTwoValues = NumberDataSetImpl.create( da2 );
// X-Axis
Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];
SeriesDefinition sdX = (SeriesDefinition)
xAxisPrimary.getSeriesDefinitions( )
.get( 0 );
( (Series) sdX.getSeries( ).get( 0 ) ).setDataSet( categoryValues );
// Y-Axis
Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );
SeriesDefinition sdY = (SeriesDefinition)
yAxisPrimary.getSeriesDefinitions( )
.get( 0 );
( (Series) sdY.getSeries( ).get( 0 ) ).setDataSet( seriesOneValues );
( (Series) sdY.getSeries( ).get( 1 ) ).setDataSet( seriesTwoValues );
}
// Live Date Set
private static final String[] sa = {
"One", "Two", "Three", "Four",
"Five" ,//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON- NLS-5$
"Six", "Seven", "Eight", "Nine",
"Ten" };//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON -NLS-5$
private static final double[] da1 = {
56.99,
352.95,
-201.95,
299.95,
-95.95,
25.45,
129.33,
-26.5,
43.5,
122
};
private static final double[] da2 = {
20, 35, 59, 105, 150, -37, -65, -99, -145, -185
};
private Image imgChart;
private GC gcImage;
private Bounds bo;
static final void scrollData( ChartWithAxes cwa )
{
// Scroll the bar (Y) series
double dTemp = da1[0];
for ( int i = 0; i < da1.length - 1; i++ )
{
da1[i] = da1[i + 1];
}
da1[da1.length - 1] = dTemp;
// Scroll the line (Y) series
dTemp = da2[0];
for ( int i = 0; i < da2.length - 1; i++ )
{
da2[i] = da2[i + 1];
}
da2[da2.length - 1] = dTemp;
// Scroll X series
String sTemp = sa[0];
for ( int i = 0; i < sa.length - 1; i++ )
{
sa[i] = sa[i + 1];
}
sa[sa.length - 1] = sTemp;
updateDataSet( cwa );
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.PaintListener#paintControl(org.eclips e.swt.events
* .PaintEvent)
*/
public final void paintControl( PaintEvent e )
{
Rectangle d = this.getClientArea( );
if ( bFirstPaint )
{
imgChart = new Image( this.getDisplay( ), d );
gcImage = new GC( imgChart );
idr.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, gcImage );
bo = BoundsImpl.create( 0, 0, d.width, d.height );
bo.scale( 72d / idr.getDisplayServer( ).getDpiResolution( ) );
}
Generator gr = Generator.instance( );
try
{
gcs = gr.build( idr.getDisplayServer( ), cm, bo, null, null, null );
gr.render( idr, gcs );
GC gc = e.gc;
gc.drawImage( imgChart, d.x, d.y );
}
catch ( ChartException ce )
{
ce.printStackTrace( );
}
bFirstPaint = false;
Display.getDefault( ).timerExec( 500, new Runnable( ) {
public void run( )
{
chartRefresh( );
}
} );
}
/*
* (non-Javadoc)
*
* @see
*
org.eclipse.swt.events.SelectionListener#widgetDefaultSelect ed(org.eclipse
* .swt.events.SelectionEvent)
*/
private void chartRefresh( )
{
if ( !isDisposed( ) )
{
final Generator gr = Generator.instance( );
scrollData( (ChartWithAxes) cm );
// Refresh
try
{
gr.refresh( gcs );
}
catch ( ChartException ex )
{
ex.printStackTrace( );
}
redraw( );
}
}
}
Jason
On 2/23/2011 10:19 AM, kkt8 wrote:
> Hello,
>
> I create a PieChart in a view like this :
>
> public constructorDemaclass(){
> ...
> produceChart();
> }
>
> public Chart produceChart(){
> {
> ...
> objectsCODE[0] = new DataObject("CODE", "startup", 32.);
> objectsCODE[1] = new DataObject("CODE", "thandlers", 408.);
> objectsCODE[2] = new DataObject("CODE", "text", 152560.);
> PieChartCode = new PieChartFactory(objectsCODE, labelField, null);
> chart1 = PieChartCode.producePieChart(null, "CODE");
> ...
> }
> }
>
> public void createPartControl(Composite parent) {
> cParent = parent;
> try {
> paintCanvas = new Canvas( parent, SWT.BORDER |SWT.V_SCROLL );
> paintCanvas.getVerticalBar().setEnabled(false);
> paintCanvas.setLayoutData( new GridData( GridData.FILL_BOTH ) );
> paintCanvas.setBackground( Display.getDefault( ).getSystemColor(
> SWT.COLOR_WHITE ) );
> chartViewer = new ChartViewer( );
> paintCanvas.addPaintListener( chartViewer );
> paintCanvas.addControlListener( chartViewer );
> chartViewer.setViewer( paintCanvas );
> createActions(parent);
> IActionBars actionBars = getViewSite().getActionBars();
> initToolBar(actionBars.getToolBarManager());
> chartViewer.renderModel(chart1);
> saveChartAction.setChart(chart1);
> saveChartAction.setBounds(chartViewer.getBounds());
> saveXMLAction.setChart(chart1);
> if (chart instanceof ChartWithoutAxes){
> valueSeriesDetailsAction = new ValueSeriesDetailsAction(this);
> getViewSite().getActionBars().getToolBarManager().add(valueS eriesDetailsAction);
>
> }
> else {
> coloredByAction = new ColoredByAction(this);
> getViewSite().getActionBars().getToolBarManager().add(colore dByAction);
> }
> getViewSite().getActionBars().getToolBarManager().update(tru e);
>
> } catch (Throwable _)
> {
> Status s = new Status(
> Status.ERROR,
> Activator.PLUGIN_ID,
> Status.ERROR,
> "Error when creating AWT Frame...",
> _);
> Activator.getDefault().getLog().log(s);
> }
> }
>
> public Chart producePieChart(IChartField valField,String title)
> {
> ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
> cwoaPie.setSeriesThickness( 20 );
> cwoaPie.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
> //cwoaPie.getBlock( ).setBounds(BoundsImpl.create(0,0,252,288));
> Bounds bd = cwoaPie.getBlock( ).getBounds();
> cwoaPie.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEP TH_LITERAL);
>
> // Plot
> Plot p = cwoaPie.getPlot( );
> p.getClientArea( ).setBackground( null );
> p.getClientArea( ).getOutline( ).setVisible( false );
>
> // Legend
> Legend lg = cwoaPie.getLegend( );
> lg.getOutline( ).setVisible( false );
> lg.getText( ).getFont( ).setSize( 8 );
> lg.getClientArea().setBackground(ColorDefinitionImpl.create( 255, 255,
> 204));
> ((ColorDefinitionImpl)lg.getClientArea().getBackground()).br ighter();
> lg.setAnchor(Anchor.NORTH_LITERAL);
> lg.setItemType( LegendItemType.CATEGORIES_LITERAL );
>
> // Title
> cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue(title);
> cwoaPie.getTitle( ).getOutline( ).setVisible( false );
>
> //Base Data Set
> List<String> textLabelsCODE = new ArrayList<String>();
> for (DataObject obj : objData) {
> textLabelsCODE.add(obj.sousSection);
> }
> TextDataSet categoryCODEValues = TextDataSetImpl.create(textLabelsCODE );
>
> // Base Series
> Series seCategoryCODE = SeriesImpl.create( );
> seCategoryCODE.setDataSet( categoryCODEValues );
>
> SeriesDefinition sdBase = SeriesDefinitionImpl.create( );
> cwoaPie.getSeriesDefinitions( ).add( sdBase );
>
> sdBase.getSeries( ).add( seCategoryCODE );
>
> // Personnalise les couleurs
> sdBase.getSeriesPalette().getEntries().clear();
> int nbCode = sectSize.GetNbCode();
> for(int i = 0; i<nbCode; i++)
> {
> sdBase.getSeriesPalette().getEntries().add(ColorDefinitionIm pl.create(255,
> (i*(200/nbCode)), 0));
> }
> int nbData = sectSize.GetNbData();
> for(int i = 0; i<nbData; i++)
> {
> sdBase.getSeriesPalette().getEntries().add(ColorDefinitionIm pl.create(0,
> (i*(200/nbData)), 255));
> }
> SeriesDefinition sdValue = SeriesDefinitionImpl.create( );
> sdBase.getSeriesDefinitions( ).add( sdValue );
>
> List<Double> doubleValues = new ArrayList<Double>();
> for (DataObject obj : objData) {
> doubleValues.add(obj.size);
> }
>
> NumberDataSet Values = NumberDataSetImpl.create(doubleValues);
>
> // Pie Series
> PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
>
> sePie.setExplosion(2);
> sePie.setDataSet( Values );
> sePie.getLabel().getCaption().getFont().setSize(8);
> sePie.setLeaderLineStyle(LeaderLineStyle.FIXED_LENGTH_LITERA L);
> sePie.setLeaderLineLength(15);
>
> DataPointComponent dpc = DataPointComponentImpl.create(
> DataPointComponentType.ORTHOGONAL_VALUE_LITERAL,JavaNumberFo rmatSpecifierImpl.create(
> "###.###,00" ) );
> sePie.getDataPoint( ).getComponents( ).clear( );
> sePie.getDataPoint( ).getComponents( ).add( dpc );
>
> //By default the title of the Value Series is not visible
> sePie.getTitle().setVisible(false);
> //Mouse over the Serie to Show Tooltips
> setTriggering(sePie,lg);
> sdValue.getSeries( ).add( sePie);
>
> return cwoaPie;
> }
>
>
>
> It works very well :)
> but I want, in a event, to update the PieChart with new datas.
> I try to modify directly the collections of datas but no :( it dosen't
> work !
>
> Have you an idea ??
> Many thanks !!!
>
> ç
|
|
| |
Re: How to update a PriChart with new datas [message #656842 is a reply to message #656783] |
Mon, 28 February 2011 18:28 |
|
That example has a main that can launch it in a shell, or it can be tied
into a view like:
public void createPartControl(Composite parent) {
c3dViewer = new SwtLiveChartViewer( parent, SWT.NO_BACKGROUND );
c3dViewer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
c3dViewer.addPaintListener( c3dViewer );
Jason
On 2/28/2011 10:25 AM, kkt8 wrote:
> Hello,
>
> I'll try to run your example, and do retro-engeniering to understand.
> How do you launch your SwtLiveChartViewer class, by a RCP appli with a
> view ?
> I always do plugins launch under eclipse and never a standalone appli.
>
> So sorry if my question is stupid :(
> and thank you for your help !
|
|
|
Re: How to update a PriChart with new datas [message #656955 is a reply to message #656842] |
Tue, 01 March 2011 07:50 |
kkt8 Mising name Messages: 27 Registered: November 2010 |
Junior Member |
|
|
Ok, I replace the main by your code.
but I've had an error on :
gcs = gr.build( idr.getDisplayServer( ), cm, bo, null, null, null );
It says me : "The type org.mozilla.javascript.Scriptable cannot be resolved. It is indirectly referenced from required .class files"
so I've replaced by :
gcs = gr.build(idr.getDisplayServer( ), cm, bo, null);
I dont understand why but It's ok.
when I execute I've an exception on :
idr.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, gcImage );
the exception is in the EventTable class on the sendEvent function.
I 've never pass the setProperty method
Do you have an idea ?
|
|
| |
Re: How to update a PriChart with new datas [message #657098 is a reply to message #656955] |
Tue, 01 March 2011 15:29 |
|
What libs from BIRT do you have in your classpath? The js.jar is
available in the birt runtime download. The Scriptable class is in that
jar.
Jason
On 3/1/2011 2:50 AM, kkt8 wrote:
> Ok, I replace the main by your code.
> but I've had an error on :
>
> gcs = gr.build( idr.getDisplayServer( ), cm, bo, null, null, null );
>
> It says me : "The type org.mozilla.javascript.Scriptable cannot be
> resolved. It is indirectly referenced from required .class files"
> so I've replaced by :
>
> gcs = gr.build(idr.getDisplayServer( ), cm, bo, null);
>
> I dont understand why but It's ok.
> when I execute I've an exception on :
>
> idr.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, gcImage );
>
> the exception is in the EventTable class on the sendEvent function.
> I 've never pass the setProperty method :(
>
> Do you have an idea ?
|
|
| | | | | |
Re: How to update a PriChart with new datas [message #657403 is a reply to message #657245] |
Wed, 02 March 2011 16:43 |
|
You either have to use the libs from the BIRT runtime or the libs from
the chart engine download birt-charts-2_5_2\DeploymentRuntime\ChartEngine
Jason
On 3/2/2011 2:01 AM, kkt8 wrote:
> No I'm not.
> I've just for BIRT :
> org.eclipse.birt.chart.device.extension_2.5.2.v20100204.jar
> org.eclipse.birt.chart.device.swt_2.5.2.v20091022.jar
> org.eclipse.birt.chart.engine.extension_2.5.2.v20100121.jar
> org.eclipse.birt.chart.engine_2.5.2.v20100209.jar
> org.eclipse.birt.chart.ui_2.5.2.v20100209.jar
> org.eclipse.birt.core.ui_2.5.2.v20091217.jar
> org.eclipse.birt.core_2.5.2.v20100208.jar
> org.eclipse.birt.data.aggregation_2.5.2.v20100205.jar
> org.eclipse.birt.data_2.5.2.v20100209.jar
|
|
|
Goto Forum:
Current Time: Tue Apr 23 12:25:19 GMT 2024
Powered by FUDForum. Page generated in 1.36642 seconds
|