How to draw a shape on the chart

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
guillaume
Newbie
Newbie
Posts: 2
Joined: Mon Feb 04, 2013 12:00 am

How to draw a shape on the chart

Post by guillaume » Fri Feb 22, 2013 4:11 pm

Hello


I want to draw shape orto fill rectangle on the chart.
It is used as limits.



like this :
ex.png
ex.png (136.32 KiB) Viewed 1783 times

I am using the android version.


I was able to draw a line :

Code: Select all

 IGraphics3D g = tchart.getGraphics3D();
                    if (serie!= null)
                    {
                        Point pfrom = new Point(serie.calcXPos(0), serie.calcYPosValue(seuilValue));
                        Point pto = new Point(serie.calcXPos(serie.getCount() - 1), serie.calcYPosValue(seuilValue));
                        g.getPen().setDashCap(DashCap.SQUARE);
                        g.getPen().setEndCap(LineCap.MITER);
                        g.getPen().setStyle(DashStyle.DASH);
                        g.getPen().setTransparency(70);
                        g.getPen().setWidth(3);
                        g.getPen().setColor(Color.red);
                        g.moveTo(pfrom);
                        g.lineTo(pto);
I was able to draw a rectangle (only the border, I a not able to fill it with a color)

Code: Select all

  
Point pfrom = new Point(serie2.calcXPos(0), serie2.calcYPosValue(0));
                        Point pto = new Point(serie2.calcXPos(serie2.getCount() - 1), serie2.calcYPosValue(serie2.get(values).min));
                        Dimension d = new Dimension(serie2.calcXPos(serie2.getCount() - 1) - serie2.calcXPos(0), serie2.calcYPosValue(values.get(serie2).min) - serie2.calcYPosValue(0));
                        com.steema.teechart.Rectangle r = new com.steema.teechart.Rectangle(pfrom, d);
                        g.getPen().setColor(Color.YELLOW);
                        g.getPen().setTransparency(70);
                        g.getBrush().setColor(Color.blue);
                        g.rectangle(r);
How I can draw a Shape ?

Thank you

guillaume
Newbie
Newbie
Posts: 2
Joined: Mon Feb 04, 2013 12:00 am

Re: How to draw a shape on the chart

Post by guillaume » Fri Feb 22, 2013 4:17 pm

to be more precise : the previous code is

Code: Select all


 new ChartPaintAdapter()
            {
                public void chartPainted(ChartDrawEvent e)
                {
                    IGraphics3D g = tchart.getGraphics3D();
...
}
}
}

Yeray
Site Admin
Site Admin
Posts: 8726
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: How to draw a shape on the chart

Post by Yeray » Tue Feb 26, 2013 10:49 am

Hi,

Make sure the Brush is visible, its gradient invisible, etc:

Code: Select all

                g.getBrush().setVisible(true);
                g.getBrush().getGradient().setVisible(false);
                g.getBrush().setColor(Color.blue);
                g.getBrush().setTransparency(70);
                g.rectangle(r);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply