I'm trying to receive click events when a user clicks on my color grid. I need to know where in the grid the click occurred so that I can display details relating to that cell. I've added a SeriesMouseListener and a ChartMouseListener, neither of which seems fire at any time. What steps do i need to take to receive those click events?
Thank you
ColorGrid SeriesMouseListener
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi McMClark,
Thanks for reporting. I could reproduce the issue here and added it (TJ71013450) to the defect list to be fixed for next releases.
Thanks for reporting. I could reproduce the issue here and added it (TJ71013450) to the 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 |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |
Thank You. Any information on when a fix will go out for this? We're dependent on the colorgrid for an upcoming project and will have to find another solution if a fix isn't made soon.narcis wrote:Hi McMClark,
Thanks for reporting. I could reproduce the issue here and added it (TJ71013450) to the defect list to be fixed for next releases.
Hello,
Re. Maintenance release
We will announce it shortly
To resolve the SeriesClick problem, if you are compiling from TeeChart code you can add the following method to the ColorGrid class (com\steema\teechart\styles\ColorGrid.java):
Regards,
Marc Meumann
Re. Maintenance release
We will announce it shortly
To resolve the SeriesClick problem, if you are compiling from TeeChart code you can add the following method to the ColorGrid class (com\steema\teechart\styles\ColorGrid.java):
Code: Select all
public int clicked(int X, int Y)
{
int i, tmpResult = -1;
double tmpDecAmount;
int Result = -1;
int zIndex = -1;
double XPos = super.getHorizAxis().calcPosPoint(X);
double YPos = super.getVertAxis().calcPosPoint(Y);
if (this.centered)
{
tmpDecAmount = 0.5;
}
else
{
tmpDecAmount = 0.0;
}
if (!this.getIrregularGrid())
{
double YDif = (YPos + tmpDecAmount) - this.getZValues().getMinimum();
if (YDif >= 0f)
{
i = (int)(YDif);
}
else
{
i = -1;
}
if ((i >= 0) && (i < this.getNumZValues()))
{
zIndex = i;
}
if (zIndex != -1)
{
double XDif = (XPos + tmpDecAmount) - this.getXValues().getMinimum();
if (XDif >= 0f)
{
i = (int)(XDif);
}
else
{
i = -1;
}
if ((i >= 0) && (i < this.getNumXValues()))
{
tmpResult = this.getIndex(i + 1, zIndex + 1);
}
}
return tmpResult;
}
if (super.getXValues().getCount() > 0)
{
int num = this.getNumZValues() - 1;
i = 0;
if (num >= i)
{
num++;
do
{
if ((( (this.getZValues().getValue(i) - tmpDecAmount) <= YPos)
&& ((this.getZValues().getValue(i + 1) - tmpDecAmount) > YPos))
|| (((i == (this.getNumZValues() - 1))) && (((this.getZValues().getValue(i) - tmpDecAmount)) >= YPos)))
{
zIndex = i;
break;
}
i++;
}
while (i != num);
}
if (zIndex != -1)
{
int num2 = this.getNumXValues() - 1;
i = 0;
if (num2 < i)
{
return Result;
}
num2++;
do
{
if ((((this.getXValues().getValue(i * this.getNumZValues()) - tmpDecAmount) <= XPos)
&& ((this.getXValues().getValue((i + 1) * this.getNumZValues()) - tmpDecAmount) > XPos)) || (((i == (this.getNumXValues() - 1)))
&& (((this.getXValues().getValue(i * this.getNumZValues()) - tmpDecAmount)) >= XPos)))
{
return (zIndex + (i * this.getNumZValues()));
}
i++;
}
while (i != num2);
}
}
return Result;
}
Marc Meumann
Steema Support
well, I must be doing something wrong, I still get no click events. Here's my code. I did add the click method to the colorgrid class. I know I'm using the right JAR b/c the new method is callable from the code that references it.
ColorGrid cg = new ColorGrid(tChart1.getChart());
cg.addSeriesMouseListener(new ColorGridMouseAdapter());
class ColorGridMouseAdapter extends SeriesMouseAdapter
{
@Override
public void seriesClicked(SeriesMouseEvent arg0) {
System.out.println(arg0.getValueIndex());
}
@Override
public void seriesEntered(SeriesMouseEvent arg0) {
super.seriesEntered(arg0);
}
@Override
public void seriesExited(SeriesMouseEvent arg0) {
super.seriesExited(arg0);
}
}
thanks for your help.
ColorGrid cg = new ColorGrid(tChart1.getChart());
cg.addSeriesMouseListener(new ColorGridMouseAdapter());
class ColorGridMouseAdapter extends SeriesMouseAdapter
{
@Override
public void seriesClicked(SeriesMouseEvent arg0) {
System.out.println(arg0.getValueIndex());
}
@Override
public void seriesEntered(SeriesMouseEvent arg0) {
super.seriesEntered(arg0);
}
@Override
public void seriesExited(SeriesMouseEvent arg0) {
super.seriesExited(arg0);
}
}
thanks for your help.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi McMClark,
It works fine for us here using this code:
And implementing the event like this:
Could you please check if that works for you?
Thanks in advance.
It works fine for us here using this code:
Code: Select all
ColorGrid colorGrid1 = new ColorGrid(myChart.getChart());
colorGrid1.fillSampleValues();
myChart.addMouseListener(new java.awt.event.MouseListener() {
public void mouseClicked(MouseEvent e) {
myChartMouseListened(e);
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
});
Code: Select all
private void myChartMouseListened(java.awt.event.MouseEvent e) {
int index = myChart.getSeries(0).clicked(e.getX(),e.getY());
myChart.getHeader().setText(String.valueOf(index));
}
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |