Tooltip on Legend

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
SDG
Newbie
Newbie
Posts: 3
Joined: Fri Nov 15, 2002 12:00 am

Tooltip on Legend

Post by SDG » Fri Apr 09, 2010 6:09 am

Hi,
I am trying to create a graph in which two or more Legend texts can be same as they represent the same type of data but they are being displayed for different parameter values.

For example, there may be two Legends with name: "Frequency" but they represent Frequency of two different People or for the same person over a different time range.
Legend.JPG
Legend.JPG (3.7 KiB) Viewed 4441 times
As in a set of parameters, a user can select any two different combination to draw a series, i intend to display the selected parameter as a tooltip of the respective legends to differentiate.

Let me know if any such feature is already available in TeeChart for Java. In case if you know of any alternative, do let me know.

Thanks and regards.
Mausam

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

Re: Tooltip on Legend

Post by Yeray » Fri Apr 09, 2010 4:15 pm

Hi Mausam,

If I understood well what you want to do, you could use OnMouseMove event to check if the mouse is over the legend (and over what item). Then you could show the text you want. Here it is an example:

Code: Select all

    com.steema.teechart.tools.MarksTip markstip1;

    String text;

    private void initChart() {

        tChart1.getAspect().setView3D(false);

        for (int i=0; i<3; i++)
        {
            new com.steema.teechart.styles.Bar(tChart1.getChart());
            tChart1.getSeries(i).fillSampleValues();
        }

        markstip1 = new com.steema.teechart.tools.MarksTip(tChart1.getChart());

        tChart1.addChartPaintListener(new ChartPaintListener() {

            public void axesPainting(ChartDrawEvent arg0) {}

            public void chartPainted(ChartDrawEvent arg0) {
                markstip1.chart.getToolTip().setText(text);
            }

            public void chartPainting(ChartDrawEvent arg0) {}
            public void seriesPainting(ChartDrawEvent arg0) {}
            public void seriesPainted(ChartDrawEvent arg0) {}
        });

        tChart1.addMouseMotionListener(new MouseMotionListener() {

            public void mouseDragged(MouseEvent e) {}

            public void mouseMoved(MouseEvent e) {
                int clickedIndex = tChart1.getLegend().clicked(e.getX(),e.getY());
                if (clickedIndex > -1)
                {
                    text = tChart1.getSeries(clickedIndex).titleOrName();
                    tChart1.repaint();
                }
            }
        });
    }
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