Page 1 of 1

Clicked-response in histograms

Posted: Mon Mar 03, 2008 3:04 pm
by 7667185
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)
    {
    }
}

Posted: Tue Mar 04, 2008 2:36 pm
by narcis
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.

Posted: Tue Mar 04, 2008 2:47 pm
by 7667185
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

Posted: Tue Mar 04, 2008 3:10 pm
by narcis
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);

Posted: Wed Mar 05, 2008 2:13 pm
by 7667185
Thanks I'll check it out!

Posted: Fri Mar 07, 2008 8:09 am
by 7667185
Just for info, it works fine doing it the way you propsed!

Thanks for good advice and good help, kudos!

M

Posted: Fri Mar 07, 2008 9:19 am
by narcis
Hi Marius,

Thanks for your feedback. I'm glad to hear that help!