Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Zoom capability(Zoom capability)
Zoom capability [message #630642] Mon, 04 October 2010 13:25 Go to next message
No real name is currently offline No real name
Messages: 23
Registered: August 2010
Junior Member
Hello,
I am evaluating BIRT charts for our application, specifically zoom functionality.
1. I wanted to know if zoom in , zoom out is possible without explicitly changing the dataset . Does BIRT handle the dataset refresh if I just change the scale or do I need to update the dataset and pass it to the chart each time I rescale?

2.And how about the dataset refresh for Drill down functionality?

3. Does the chart API have support to
a.export the chart object to PDF
b.Print the chart object
If not what options would I have for Export/Print.

Thanks in advance
Re: Zoom capability [message #630712 is a reply to message #630642] Mon, 04 October 2010 16:30 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Are you using charts as part of a BIRT report or by just the Chart
Engine API. If you are using the api you should be able to rescale and
then re-run the chart. You can also do this in a report that contains a
chart using report parameters (if you need an example let me know). The
chart engine supports rendering to PDF as well. If you use the Birt
Viewer you can export the chart to pdf out of the box.

Jason

On 10/4/2010 9:25 AM, asadanandan@axiomainc.com wrote:
> Hello,
> I am evaluating BIRT charts for our application, specifically zoom
> functionality. 1. I wanted to know if zoom in , zoom out is possible
> without explicitly changing the dataset . Does BIRT handle the dataset
> refresh if I just change the scale or do I need to update the dataset
> and pass it to the chart each time I rescale?
> 2.And how about the dataset refresh for Drill down functionality?
>
> 3. Does the chart API have support to a.export the chart object to PDF
> b.Print the chart object
> If not what options would I have for Export/Print.
>
> Thanks in advance
Re: Zoom capability [message #631261 is a reply to message #630712] Wed, 06 October 2010 17:54 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 23
Registered: August 2010
Junior Member
I am using just the Chart Engine API. Yes would you be able to give me an example? I am using it in SWT.
Would you also have an example to export the chart to PDF using the API?

Thanks
Re: Zoom capability [message #631263 is a reply to message #630712] Wed, 06 October 2010 18:01 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 23
Registered: August 2010
Junior Member
No Message Body
Re: Zoom capability [message #631291 is a reply to message #631261] Wed, 06 October 2010 19:55 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Here is a snippet to use the pdf output for the chart engine api.

Make sure you have this
org.eclipse.birt.chart.device.pdf_2.5.1.v20090625 plugin in your plugins

Jason



import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import org.eclipse.birt.chart.api.ChartEngine;
import org.eclipse.birt.chart.device.EmptyUpdateNotifier;
import org.eclipse.birt.chart.device.IDeviceRenderer;
import org.eclipse.birt.chart.device.IDisplayServer;
import org.eclipse.birt.chart.factory.GeneratedChartState;
import org.eclipse.birt.chart.factory.IGenerator;
import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.ChartWithAxes;
import org.eclipse.birt.chart.model.attribute.ActionType;
import org.eclipse.birt.chart.model.attribute.AxisType;
import org.eclipse.birt.chart.model.attribute.Bounds;
import org.eclipse.birt.chart.model.attribute.IntersectionType;
import org.eclipse.birt.chart.model.attribute.LegendItemType;
import org.eclipse.birt.chart.model.attribute.Position;
import org.eclipse.birt.chart.model.attribute.TickStyle;
import org.eclipse.birt.chart.model.attribute.TriggerCondition;
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.attribute.impl.TooltipValueImpl ;
import org.eclipse.birt.chart.model.attribute.impl.URLValueImpl;
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.Trigger;
import org.eclipse.birt.chart.model.data.impl.ActionImpl;
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.data.impl.TriggerImpl;
import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl;
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.impl.BarSeriesImpl;
import org.eclipse.birt.core.framework.PlatformConfig;
//import org.eclipse.swt.dnd.Clipboard;
//import org.eclipse.swt.widgets.Display;





/**
* Test decription:
* </p>
* Chart script: BeforeDrawLegendItem()
* </p>
*/

public class StandaloneChartPDF {

private static String OUTPUT = "output/Standalone.pdf"; //$NON-NLS-1$

/**
* Comment for <code>serialVersionUID</code>
*/
private static final long serialVersionUID = 1L;

/**
* A chart model instance
*/
private Chart cm = null;

/**
* The swing rendering device
*/
private IDeviceRenderer dRenderer = null;
private IDisplayServer dServer = null;

private GeneratedChartState gcs = null;

/**
* execute application
*
* @param args
*/
public static void main(String[] args) {
new StandaloneChartPDF();
System.out.println("Finished");
}

/**
* Constructor
*/
public StandaloneChartPDF() {
PlatformConfig pf = new PlatformConfig();

pf.setBIRTHome("C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine ");

ChartEngine ce = ChartEngine.instance(pf);
//Returns a singleton instance of the Generator
IGenerator gr = ce.getGenerator();

//make sure to org.eclipse.birt.chart.device.pdf_2.5.1.v20090625 in
your plugins
try {
//device renderers for dv.SWT, dv.PNG, dv.JPG
//dv.PDF, dv.SVG, dv.SWING, dv.PNG24, div.BMP
dRenderer = ce.getRenderer("dv.PDF");
dServer = dRenderer.getDisplayServer();
} catch (Exception ex) {
ex.printStackTrace();
}

cm = StandaloneChart.createStackedBar();


BufferedImage img = new BufferedImage(600, 600,
BufferedImage.TYPE_INT_ARGB);
Graphics g = img.getGraphics();

Graphics2D g2d = (Graphics2D) g;
//Look at IDeviceRenderer.java for all properties
//like DPI_RESOLUTION
//FILE_IDENTIFIER
//FORMAT_IDENTIFIER
//UPDATE_NOTIFIER
dRenderer.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, g2d);
dRenderer.setProperty(IDeviceRenderer.FILE_IDENTIFIER, OUTPUT);
//$NON-NLS-1$

//Set the bounds for the entire chart
Bounds bo = BoundsImpl.create(0, 0, 600, 600);
bo.scale(72d / dRenderer.getDisplayServer().getDpiResolution());

try {

gcs = gr.build(dServer, cm, bo, null, null, null);
//gcs.getRunTimeContext().setActionRenderer( new MyActionRenderer());
dRenderer.setProperty(IDeviceRenderer.UPDATE_NOTIFIER,
new EmptyUpdateNotifier(cm, gcs.getChartModel()));

gr.render(dRenderer, gcs);

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public static final Chart createStackedBar()

{

ChartWithAxes cwaBar = ChartWithAxesImpl.create();

cwaBar.setType("Bar Chart"); //$NON-NLS-1$

cwaBar.setSubType("Stacked"); //$NON-NLS-1$


// Plot

cwaBar.getBlock().setBackground(ColorDefinitionImpl.WHITE()) ;

cwaBar.getBlock().getOutline().setVisible(true);

Plot p = cwaBar.getPlot();

p.getClientArea().setBackground(ColorDefinitionImpl.create(2 55,

255,

225));

// Title

cwaBar.getTitle()

.getLabel()

.getCaption()

.setValue("Stacked Bar Chart"); //$NON-NLS-1$

// Legend

Legend lg = cwaBar.getLegend();

lg.setItemType(LegendItemType.CATEGORIES_LITERAL);

//Add Script

cwaBar
.setScript("function beforeGeneration( cm, icsc )"
+ " {importPackage(Packages.org.eclipse.birt.chart.model.attribu te); "
+ "
importPackage(Packages.org.eclipse.birt.chart.model.attribut e.impl); "
+ " cm.getLegend().getOutline( ).setStyle(
LineStyle.DASH_DOTTED_LITERAL );"
+ " cm.getLegend().getOutline( ).setColor(
ColorDefinitionImpl.GREEN() );"
+ " cm.getLegend().getOutline( ).setVisible( true );} ");

// X-Axis

Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];

xAxisPrimary.setType(AxisType.TEXT_LITERAL);


xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LIT ERAL);

xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERA L);

// Y-Axis

Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(xAxisPrimary);

yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITE RAL);

yAxisPrimary.setType(AxisType.LINEAR_LITERAL);

yAxisPrimary.setLabelPosition(Position.RIGHT_LITERAL);
yAxisPrimary.getLabel().getCaption().getFont().setRotation(4 5);



// Data Set

TextDataSet categoryValues = TextDataSetImpl.create(new String[] {
"Item 1a", "Item 2", "Item 3", "Item 4", "Item 5" }); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$

NumberDataSet orthoValues1 = NumberDataSetImpl.create(new double[] {

25, 35, 15, 5, 20

});

NumberDataSet orthoValues2 = NumberDataSetImpl.create(new double[] {

5, 10, 25, 10, 5

});

SampleData sd = DataFactory.eINSTANCE.createSampleData();

BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData();

sdBase.setDataSetRepresentation("");//$NON-NLS-1$

sd.getBaseSampleData().add(sdBase);

OrthogonalSampleData sdOrthogonal1 = DataFactory.eINSTANCE
.createOrthogonalSampleData();

sdOrthogonal1.setDataSetRepresentation("");//$NON-NLS-1$

sdOrthogonal1.setSeriesDefinitionIndex(0);

sd.getOrthogonalSampleData().add(sdOrthogonal1);

OrthogonalSampleData sdOrthogonal2 = DataFactory.eINSTANCE
.createOrthogonalSampleData();

sdOrthogonal2.setDataSetRepresentation("");//$NON-NLS-1$

sdOrthogonal2.setSeriesDefinitionIndex(1);

sd.getOrthogonalSampleData().add(sdOrthogonal2);

cwaBar.setSampleData(sd);

// X-Series

Series seCategory = SeriesImpl.create();

seCategory.setDataSet(categoryValues);

SeriesDefinition sdX = SeriesDefinitionImpl.create();

xAxisPrimary.getSeriesDefinitions().add(sdX);

sdX.getSeries().add(seCategory);
sdX.getSeriesPalette().shift(0);

// Y-Series

BarSeries bs1 = (BarSeries) BarSeriesImpl.create();


bs1.setDataSet(orthoValues1);

bs1.setStacked(true);

bs1.getLabel().setVisible(true);

bs1.setLabelPosition(Position.INSIDE_LITERAL);
bs1.setRiserOutline(ColorDefinitionImpl.TRANSPARENT());

BarSeries bs2 = (BarSeries) BarSeriesImpl.create();

bs2.setDataSet(orthoValues2);

bs2.setStacked(true);

bs2.setRiserOutline(ColorDefinitionImpl.TRANSPARENT());
bs2.getLabel().setVisible(true);

bs2.setLabelPosition(Position.INSIDE_LITERAL);

Trigger tr1 = TriggerImpl.create(TriggerCondition.ONMOUSEOVER_LITERAL,
ActionImpl.create(ActionType.SHOW_TOOLTIP_LITERAL,
TooltipValueImpl.create(200, "test + dph.getDisplayValue()")));
Trigger tr2 = TriggerImpl.create(TriggerCondition.ONCLICK_LITERAL,
ActionImpl.create(ActionType.URL_REDIRECT_LITERAL, URLValueImpl
.create("https://www.google.com", null, "component",
"value", "")));
//Trigger tr3 =
TriggerImpl.create(TriggerCondition.ONMOUSEOVER_LITERAL,
ActionImpl.create(ActionType.SHOW_TOOLTIP_LITERAL,
TooltipValueImpl.create(200, null)));
bs1.getTriggers().add(tr1);
bs1.getTriggers().add(tr2);

SeriesDefinition sdY = SeriesDefinitionImpl.create();

sdY.getSeriesPalette().shift(0);

yAxisPrimary.getSeriesDefinitions().add(sdY);

sdY.getSeries().add(bs1);

sdY.getSeries().add(bs2);

return cwaBar;

}


}


On 10/6/2010 1:54 PM, asadanandan@axiomainc.com wrote:
> I am using just the Chart Engine API. Yes would you be able to give me
> an example? I am using it in SWT.
> Would you also have an example to export the chart to PDF using the API?
>
> Thanks
Re: Zoom capability [message #631303 is a reply to message #631291] Wed, 06 October 2010 22:03 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 23
Registered: August 2010
Junior Member
Jason,
I am getting the following exception when I run this. I have org.eclipse.birt.chart.device.extension and
org.eclipse.birt.chart.engine.extension

in my plugins.



Caused by: org.eclipse.core.runtime.CoreException: Plug-in "org.eclipse.birt.chart.device.pdf" was unable to instantiate class "org.eclipse.birt.chart.device.pdf.PDFRendererImpl".
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .throwException(RegistryStrategyOSGI.java:194)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:188)
at org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:904)
at org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 55)
at org.eclipse.birt.core.framework.eclipse.EclipseConfiguration Element.createExecutableExtension(EclipseConfigurationElemen t.java:35)
... 32 more
Caused by: java.lang.NoClassDefFoundError: org/eclipse/birt/chart/device/util/ICharacterEncoderAdapter
at org.eclipse.birt.chart.device.pdf.PDFRendererImpl.init(PDFRe ndererImpl.java:61)
at org.eclipse.birt.chart.device.swing.SwingRendererImpl.<init >(SwingRendererImpl.java:126)


Re: Zoom capability [message #631409 is a reply to message #631303] Thu, 07 October 2010 13:30 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Did you copy org.eclipse.birt.chart.device.pdf_2.5.1.v20090625 from the
chart engine download to your birt runtime
pf.setBIRTHome("C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine ");


Jason

On 10/6/2010 6:03 PM, asadanandan@axiomainc.com wrote:
> Jason,
> I am getting the following exception when I run this. I have
> org.eclipse.birt.chart.device.extension and
> org.eclipse.birt.chart.engine.extension
>
> in my plugins.
>
>
>
> Caused by: org.eclipse.core.runtime.CoreException: Plug-in
> "org.eclipse.birt.chart.device.pdf" was unable to instantiate class
> "org.eclipse.birt.chart.device.pdf.PDFRendererImpl".
> at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI
> .throwException(RegistryStrategyOSGI.java:194)
> at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI
> .createExecutableExtension(RegistryStrategyOSGI.java:188)
> at org.eclipse.core.internal.registry.ExtensionRegistry.createE
> xecutableExtension(ExtensionRegistry.java:904)
> at org.eclipse.core.internal.registry.ConfigurationElement.crea
> teExecutableExtension(ConfigurationElement.java:243)
> at org.eclipse.core.internal.registry.ConfigurationElementHandl
> e.createExecutableExtension(ConfigurationElementHandle.java: 55)
> at org.eclipse.birt.core.framework.eclipse.EclipseConfiguration
> Element.createExecutableExtension(EclipseConfigurationElemen t.java:35)
> ... 32 more
> Caused by: java.lang.NoClassDefFoundError:
> org/eclipse/birt/chart/device/util/ICharacterEncoderAdapter
> at org.eclipse.birt.chart.device.pdf.PDFRendererImpl.init(PDFRe
> ndererImpl.java:61)
> at org.eclipse.birt.chart.device.swing.SwingRendererImpl.<init
> >(SwingRendererImpl.java:126)
>
>
>
Re: Zoom capability [message #631412 is a reply to message #631409] Thu, 07 October 2010 13:39 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 23
Registered: August 2010
Junior Member
Jason,
Yes I did as you mentioned in your previous email.
And set the BIRT home:
pf.setBIRTHome("C:/Program Files/Helios-BIRT/eclipse ");

[Updated on: Thu, 07 October 2010 13:41]

Report message to a moderator

Re: Zoom capability [message #631414 is a reply to message #631412] Thu, 07 October 2010 13:40 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 23
Registered: August 2010
Junior Member
Does it have any other dependencies which I need to add to my plugins folder?
Re: Zoom capability [message #631421 is a reply to message #631414] Thu, 07 October 2010 13:51 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

What are you using as your build path (classpath)?

Jason

On 10/7/2010 9:40 AM, asadanandan@axiomainc.com wrote:
> Does it have any other dependencies which I need to add to my plugins
> folder?
Re: Zoom capability [message #631445 is a reply to message #631414] Thu, 07 October 2010 14:23 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

What I did to get it to work was to copy the plugin
(org.eclipse.birt.chart.device.pdf) from the chart download
(birt-charts-2_5_1\ChartRuntime\eclipse\plugins) to the plugins folder
of my birt runtime and then added one extra lib to my build path.
birt-charts-2_5_1\DeploymentRuntime\ChartEngine\org.apache.x erces_2.9.0.v200909240008.jar

Jason

On 10/7/2010 9:40 AM, asadanandan@axiomainc.com wrote:
> Does it have any other dependencies which I need to add to my plugins
> folder?
Previous Topic:Arabic fonts are not rendered
Next Topic:turning filters on and off
Goto Forum:
  


Current Time: Sat Oct 25 22:21:33 GMT 2014

Powered by FUDForum. Page generated in 0.02455 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software