Skip to main content



      Home
Home » Archived » BIRT » Error using a script on a bar chart
Error using a script on a bar chart [message #94518] Sat, 26 November 2005 11:32 Go to next message
Eclipse UserFriend
Originally posted by: prooteus_NOSPAM.gmx.net

Hi,

I wanted to try the following script on a chart:

Chart c = ChartWithAxesImpl.create();
c.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LIT ERAL);

String script = "function beforeDrawDataPoint(dataPointHints, fill)
{" +
"val = dataPointHints.getOrthogonalValue();" +
"if(val < 0) {" +
"fill.set(255, 0, 0);}" +
"else {" +
"fill.set(0, 0, 255);}" +
"}";

c.setScript(script);

[...]

public final void paintControl(PaintEvent pe) {

try {
idr = ps.getDevice("dv.SWT");
} catch (ChartException ex) {
ex.printStackTrace();
}

idr.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc);

Composite co = (Composite) pe.getSource();
Rectangle re = co.getClientArea();
Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height);
bo.scale(72d / idr.getDisplayServer().getDpiResolution());

Generator generator = Generator.instance();
try {
IDisplayServer server = idr.getDisplayServer();
GeneratedChartState state = generator.build(server, c, new
ScriptHandler(), bo, null);
generator.render(idr, state);
} catch (Exception e) {
e.printStackTrace();
}
}
};

But when I execute this, I get the following stack trace:

org.mozilla.javascript.EvaluatorException: Constructor for "Object" not
found.
at
org.mozilla.javascript.DefaultErrorReporter.runtimeError(Def aultErrorReporter.java:95)
at
org.mozilla.javascript.Context.reportRuntimeError(Context.ja va:1054)
at
org.mozilla.javascript.Context.reportRuntimeError(Context.ja va:1110)
at
org.mozilla.javascript.Context.reportRuntimeError1(Context.j ava:1073)
at
org.mozilla.javascript.ScriptRuntime.getExistingCtor(ScriptR untime.java:1119)
at org.mozilla.javascript.Context.newObject(Context.java:1548)
at org.mozilla.javascript.Context.newObject(Context.java:1507)
at
org.eclipse.birt.chart.model.ScriptHandler.init(ScriptHandle r.java:281)
at org.eclipse.birt.chart.factory.Generator.build(Generator.jav a:174)
at de.xxx.paintControl(BarChart.java:214)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:83)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:11 53)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3090 )
at org.eclipse.swt.widgets.Display.windowProc(Display.java:3706 )
at org.eclipse.swt.internal.win32.OS.UpdateWindow(Native Method)
at
org.eclipse.swt.widgets.Decorations.setVisible(Decorations.j ava:1391)
at org.eclipse.swt.widgets.Shell.setVisible(Shell.java:1300)
at org.eclipse.swt.widgets.Shell.open(Shell.java:827)
at de.xxx
at de.xxx
at de.xxx
at de.xxx
at
org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:346)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:291)
at
org.eclipse.jface.dialogs.ProgressMonitorDialog.run(Progress MonitorDialog.java:447)
at de.xxx
at
org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDi alog.java:676)
at
org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDi alog.java:349)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.jav a:556)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at
org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:809 )
at org.eclipse.jface.window.Window.open(Window.java:787)
at de.xxx
at
org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:246)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:538)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:488)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at
org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at
org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at
org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:103)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)

Any hints are welcome.

Regards,
Stefan
Re: Error using a script on a bar chart [message #95395 is a reply to message #94518] Tue, 29 November 2005 14:46 Go to previous message
Eclipse UserFriend
Originally posted by: none.none.com

Stefan,

It should be beforeDrawElement. beforeDrawDataPoint has a Label as
parameter, not a Fill object.

Thanks,

David

"Stefan Knieling" <prooteus_NOSPAM@gmx.net> wrote in message
news:dma2mb$pp1$1@news.eclipse.org...
> Hi,
>
> I wanted to try the following script on a chart:
>
> Chart c = ChartWithAxesImpl.create();
> c.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LIT ERAL);
>
> String script = "function beforeDrawDataPoint(dataPointHints, fill) {" +
> "val = dataPointHints.getOrthogonalValue();" +
> "if(val < 0) {" +
> "fill.set(255, 0, 0);}" +
> "else {" +
> "fill.set(0, 0, 255);}" +
> "}";
>
> c.setScript(script);
>
> [...]
>
> public final void paintControl(PaintEvent pe) {
>
> try {
> idr = ps.getDevice("dv.SWT");
> } catch (ChartException ex) {
> ex.printStackTrace();
> }
>
> idr.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc);
>
> Composite co = (Composite) pe.getSource();
> Rectangle re = co.getClientArea();
> Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height);
> bo.scale(72d / idr.getDisplayServer().getDpiResolution());
>
> Generator generator = Generator.instance();
> try {
> IDisplayServer server = idr.getDisplayServer();
> GeneratedChartState state = generator.build(server, c, new
> ScriptHandler(), bo, null);
> generator.render(idr, state);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> };
>
> But when I execute this, I get the following stack trace:
>
> org.mozilla.javascript.EvaluatorException: Constructor for "Object" not
> found.
> at
> org.mozilla.javascript.DefaultErrorReporter.runtimeError(Def aultErrorReporter.java:95)
> at org.mozilla.javascript.Context.reportRuntimeError(Context.ja va:1054)
> at org.mozilla.javascript.Context.reportRuntimeError(Context.ja va:1110)
> at org.mozilla.javascript.Context.reportRuntimeError1(Context.j ava:1073)
> at
> org.mozilla.javascript.ScriptRuntime.getExistingCtor(ScriptR untime.java:1119)
> at org.mozilla.javascript.Context.newObject(Context.java:1548)
> at org.mozilla.javascript.Context.newObject(Context.java:1507)
> at org.eclipse.birt.chart.model.ScriptHandler.init(ScriptHandle r.java:281)
> at org.eclipse.birt.chart.factory.Generator.build(Generator.jav a:174)
> at de.xxx.paintControl(BarChart.java:214)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:83)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
> at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:11 53)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3090 )
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:3706 )
> at org.eclipse.swt.internal.win32.OS.UpdateWindow(Native Method)
> at org.eclipse.swt.widgets.Decorations.setVisible(Decorations.j ava:1391)
> at org.eclipse.swt.widgets.Shell.setVisible(Shell.java:1300)
> at org.eclipse.swt.widgets.Shell.open(Shell.java:827)
> at de.xxx
> at de.xxx
> at de.xxx
> at de.xxx
> at
> org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:346)
> at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:291)
> at
> org.eclipse.jface.dialogs.ProgressMonitorDialog.run(Progress MonitorDialog.java:447)
> at de.xxx
> at
> org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDi alog.java:676)
> at
> org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDi alog.java:349)
> at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.jav a:556)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
> at org.eclipse.jface.window.Window.runEventLoop(Window.java:809 )
> at org.eclipse.jface.window.Window.open(Window.java:787)
> at de.xxx
> at
> org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:246)
> at
> org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:538)
> at
> org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:488)
> at
> org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:400)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
> at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:103)
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
> at org.eclipse.core.launcher.Main.run(Main.java:973)
> at org.eclipse.core.launcher.Main.main(Main.java:948)
>
> Any hints are welcome.
>
> Regards,
> Stefan
Previous Topic:Dynamic markers in chart, based on parameter
Next Topic:Creating images from charts
Goto Forum:
  


Current Time: Sun May 11 16:39:43 EDT 2025

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

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

Back to the top