Page 1 of 1

How to draw a shape on the chart

Posted: Fri Feb 22, 2013 4:11 pm
by 16964919
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 2286 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

Re: How to draw a shape on the chart

Posted: Fri Feb 22, 2013 4:17 pm
by 16964919
to be more precise : the previous code is

Code: Select all


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

Re: How to draw a shape on the chart

Posted: Tue Feb 26, 2013 10:49 am
by yeray
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);