Clicked-response in histograms

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Marius
Newbie
Newbie
Posts: 44
Joined: Thu Jan 31, 2008 12:00 am

Clicked-response in histograms

Post by Marius » Mon Mar 03, 2008 3:04 pm

When I try to select a series in a chart of Histograms, I do not get any response on the Clicked-method. Is this a known issue, or is there a reason why Histograms are "un-clickable"?

Including a small dummy-program to illustrate, just as text. You'll notice how -1 is always returned when clicking, both in- and outside the series.

If you would rather want a jar I can make it next time, but now you also see the src :)

Thanks in advance!

Marius

Code: Select all

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import com.steema.teechart.TChart;
import com.steema.teechart.styles.Histogram;

public class ClickTest extends JFrame implements ActionListener, MouseListener
{
    JPanel dmb = new JPanel();
    TChart myChart = new TChart();
    JButton newSerButton = new JButton("Press for histogram");

    int indicator = 0;
    double[] testData = new double[100];
    double[] testX = new double[100];
    double[] testData1 = new double[50];
    double[] testX1 = new double[50];
    double[] testData2 = new double[50];
    double[] testX2 = new double[50];

    public static void main(String[] args)
    {
        new ClickTest().setVisible(true);
    }
    public ClickTest()
    {
        initialize();
    }
    public void initialize()
    {
/******************/
        for(int i=0;i<100;i++)
        {
            testData[i] = (i+50)*Math.pow(Math.random(),Math.random());
            testX[i] = i;
        }
/******************/
        myChart.getChart().getAspect().setView3D(false);
        newSerButton.addActionListener(this);
        dmb.add(myChart);
        dmb.add(newSerButton);
        super.add(dmb);
        super.setSize(600,400);
    }
    public void addSeries()
    {
        Histogram p = new Histogram(myChart.getChart().chart);
        p.add(testData);
        myChart.getChart().addSeries(p);
        myChart.addMouseListener(this);
        myChart.repaint();
    }

    public void actionPerformed(ActionEvent e)
    {
        addSeries();
    }

    public void mouseClicked(MouseEvent e)
    {
        for(int j = 0; j < myChart.getSeriesCount(); j++)
        {
            System.out.println("clicked: "+myChart.getSeries().getSeries(j).clicked(e.getPoint()));
        }
    }
    public void mousePressed(MouseEvent e)
    {
    }
    public void mouseReleased(MouseEvent e)
    {
    }
    public void mouseExited(MouseEvent e)
    {
    }
    public void mouseEntered(MouseEvent e)
    {
    }
}

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 04, 2008 2:36 pm

Hi Marius,

Thanks for reporting. I've been able to reproduce the issue here and added it (TJ71012870) to our defect list to be fixed for next releases.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Marius
Newbie
Newbie
Posts: 44
Joined: Thu Jan 31, 2008 12:00 am

Post by Marius » Tue Mar 04, 2008 2:47 pm

Ok good, thanks for looking into it.

As we are speaking of the histograms, is there a way of turning off the negative values of a histogram? I.e. making the bottom value of the histogram 0, without setting the charts min value to 0?

M

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 04, 2008 3:10 pm

Hi Marius,

I'm afraid this is not possible using Histogram series but you can obtain that using Bar series, setting BarWidthPercent to 100 and UseOrigin property:

Code: Select all

        Bar bar1 = new Bar(tChart.getChart());
        bar1.fillSampleValues(50);
        bar1.getMarks().setVisible(false);
        bar1.setBarWidthPercent(100);
        bar1.getPen().setVisible(false);
        bar1.setUseOrigin(true);
        bar1.setOrigin(0);
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Marius
Newbie
Newbie
Posts: 44
Joined: Thu Jan 31, 2008 12:00 am

Post by Marius » Wed Mar 05, 2008 2:13 pm

Thanks I'll check it out!

Marius
Newbie
Newbie
Posts: 44
Joined: Thu Jan 31, 2008 12:00 am

Post by Marius » Fri Mar 07, 2008 8:09 am

Just for info, it works fine doing it the way you propsed!

Thanks for good advice and good help, kudos!

M

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Mar 07, 2008 9:19 am

Hi Marius,

Thanks for your feedback. I'm glad to hear that help!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply