Skip to main content



      Home
Home » Archived » BIRT » Bar rising high
Bar rising high [message #115116] Wed, 25 January 2006 01:47 Go to next message
Eclipse UserFriend
Originally posted by: amitgolwala.gmail.com

Hi I am using BIRT Chart Engine in an SWT application. I have created
ChatWithAxes and have set the Data for Y - axis. I m using BarSeries for
viewing the data values. However, on runtime I can see all the set values
alongwith the Bars but due to some reasons all the bars rise upto to the
maximum height of the chart irrespective of the data value set for that
bar.
Re: Bar rising high [message #115208 is a reply to message #115116] Wed, 25 January 2006 03:10 Go to previous messageGo to next message
Eclipse UserFriend
Can you send a screenshot and the code you use to create the chart?

Thanks,

David

"Amit" <amitgolwala@gmail.com> wrote in message
news:ec8500a8b6d7d97f08eccf3d424ad391$1@www.eclipse.org...
> Hi I am using BIRT Chart Engine in an SWT application. I have created
> ChatWithAxes and have set the Data for Y - axis. I m using BarSeries for
> viewing the data values. However, on runtime I can see all the set values
> alongwith the Bars but due to some reasons all the bars rise upto to the
> maximum height of the chart irrespective of the data value set for that
> bar.
>
Re: Bar rising high [message #118208 is a reply to message #115208] Thu, 26 January 2006 18:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amitgolwala.gmail.com

Hi,
following is the code written inorder to view the Chart with BarSeries in
SWT.

public class Snippet84 {

private static final class MyPaintListener implements PaintListener {

public void paintControl(PaintEvent e) {
IDeviceRenderer deviceRenderer = null;
try {
System.setProperty("STANDALONE", "true");
deviceRenderer = PluginSettings.instance().getDevice("dv.SWT");
} catch (Exception ex) {
System.err.println("Oops, can't find the device renderer.");
ex.printStackTrace();
System.exit(1);
}
deviceRenderer.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, e.gc);

Rectangle rect = ((Composite) e.widget).getClientArea();
final Bounds bounds = BoundsImpl.create(rect.x + 2, rect.y + 2,
rect.width - 4, rect.height - 4);
bounds.scale(72d /
deviceRenderer.getDisplayServer().getDpiResolution());
Chart chart = createSimpleLineChart();
if (chart == null)
return;
final Generator gr = Generator.instance();
GeneratedChartState state;
try {
state = gr.build(deviceRenderer.getDisplayServer(), chart,
bounds, null, new RunTimeContext (), null);
gr.refresh(state);
gr.render(deviceRenderer, state);
} catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
}
}
}

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("TestLineChart");
Canvas canvas = new Canvas(shell, SWT.NONE);
canvas.addPaintListener(new MyPaintListener());
shell.setSize(400, 400);

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}

/**
* Creates a line chart model as a reference implementation *
*
* @return An instance of the simulated runtime chart model (containing
filled
* datasets)
*/
public static final Chart createSimpleLineChart() {
ChartWithAxes cwaBar = ChartWithAxesImpl.create();
cwaBar.getBlock().setBackground(ColorDefinitionImpl.WHITE()) ;
Plot p = cwaBar.getPlot();
p.getClientArea().setBackground(ColorDefinitionImpl.create(2 55, 255,
225));
p.getOutline().setVisible(false);
cwaBar.getTitle().getLabel().getCaption().setValue("");

Legend lg = cwaBar.getLegend();
LineAttributes lia = lg.getOutline();
lia.setStyle(LineStyle.SOLID_LITERAL);
lg.getText().getFont().setSize(16);
lg.getInsets().set(10, 5, 0, 0);
lg.getOutline().setVisible(false);
lg.setAnchor(Anchor.NORTH_LITERAL);

Axis xAxisPrimary = (Axis) cwaBar.getPrimaryBaseAxes()[0];
xAxisPrimary.setType(AxisType.TEXT_LITERAL);
xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LIT ERAL);
xAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITE RAL);
xAxisPrimary.getTitle().setVisible(false);

Axis yAxisPrimary = (Axis) cwaBar
.getOrthogonalAxes(xAxisPrimary, true)[0];
yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITE RAL);
yAxisPrimary.setType(AxisType.LINEAR_LITERAL);
yAxisPrimary.setPercent(true);

Vector vs = new Vector();
vs.add("one");
vs.add("two");
vs.add("three");

ArrayList vn1 = new ArrayList ();
vn1.add(new Double(10));
vn1.add(new Double(20));
vn1.add(new Double(30));

if (vn1 == null)
return null;

TextDataSet categoryValues = TextDataSetImpl.create(vs);
NumberDataSet orthoValues1 = NumberDataSetImpl.create(vn1);

Series seCategory = SeriesImpl.create();
seCategory.setDataSet(categoryValues);

BarSeries bs = (BarSeries) BarSeriesImpl.create();
bs.setSeriesIdentifier("");
bs.setDataSet(orthoValues1);
bs.getLabel().setVisible(true);

SeriesDefinition sdX = SeriesDefinitionImpl.create();
sdX.getSeriesPalette().update(0);
xAxisPrimary.getSeriesDefinitions().add(sdX);

SeriesDefinition sdY = SeriesDefinitionImpl.create();
sdY.getSeriesPalette().update(1);
yAxisPrimary.getSeriesDefinitions().add(sdY);

sdX.getSeries().add(seCategory);

sdY.getSeries().add(bs);
return cwaBar;
}
}
Re: Bar rising high [message #118217 is a reply to message #118208] Thu, 26 January 2006 18:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amitgolwala.gmail.com

hey,
just want to add another line to the previous posting. The above code is
an answer to the FAQ with question as "Q: How can I use charts in SWT?" on
this URL: "http://www.eclipse.org/birt/wiki/index.php?n=FAQ.Charts".

thnx for reading...
waiting for help ......
cheeeeers !!

Amit
Re: Bar rising high [message #118358 is a reply to message #118217] Fri, 27 January 2006 01:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amitgolwala.gmail.com

Amit Golwala wrote:

> hey,
> just want to add another line to the previous posting. The above code is
> an answer to the FAQ with question as "Q: How can I use charts in SWT?" on
> this URL: "http://www.eclipse.org/birt/wiki/index.php?n=FAQ.Charts".

> thnx for reading...
> waiting for help ......
> cheeeeers !!

> Amit

Sorry to bother any who has read all the previous threads but I m glad to
say that I have overcome the problem n got the solution. For ne one
interseted, I must tell that the source code posted in previous postings,
I missed following line:
" yAxisPrimary.getLabel().getCaption().getFont().setRotation(9 0); "

Cheers !!

Amit
Re: Bar rising high [message #118527 is a reply to message #118358] Fri, 27 January 2006 06:40 Go to previous message
Eclipse UserFriend
I'm glad you found a solution. I am not really understanding how the
rotation of the axis label has anything to do with the bar rising though.
Anyway the most important is that you got it working.

Thanks,

David

"Amit Golwala" <amitgolwala@gmail.com> wrote in message
news:f01d5af9ffc3aece6bc8c1f67c34b19b$1@www.eclipse.org...
> Amit Golwala wrote:
>
>> hey,
>> just want to add another line to the previous posting. The above code is
>> an answer to the FAQ with question as "Q: How can I use charts in SWT?"
>> on this URL: "http://www.eclipse.org/birt/wiki/index.php?n=FAQ.Charts".
>
>> thnx for reading...
>> waiting for help ......
>> cheeeeers !!
>
>> Amit
>
> Sorry to bother any who has read all the previous threads but I m glad to
> say that I have overcome the problem n got the solution. For ne one
> interseted, I must tell that the source code posted in previous postings,
> I missed following line:
> " yAxisPrimary.getLabel().getCaption().getFont().setRotation(9 0); "
>
> Cheers !!
>
> Amit
>
Previous Topic:Standalone Java Program to generate .html for image /charts report
Next Topic:Reg : Upgrading BIRT 1_0_1 to latest version
Goto Forum:
  


Current Time: Fri Jun 06 01:48:07 EDT 2025

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

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

Back to the top