ColorGrid - Data adding problem

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

ColorGrid - Data adding problem

Post by Marius » Mon Jan 05, 2009 1:06 pm

I am starting a new thread on this as the previous, similar one did not help and was a bit too old to be revived in a sensible way:

I am having difficulties seeing why this code snippet would cause a world of NullPointerExceptions. What in this way of adding data is it that does not work? All is sorted, the grid is regular and the values are all integers in Double format:

Code: Select all

            ArrayList<Double> x = new ArrayList<Double>();
            ArrayList<Double> y = new ArrayList<Double>();
            ArrayList<Double> z = new ArrayList<Double>();
            x.add(0.0);
            x.add(1.0);
            x.add(2.0);
            y.add(0.0);
            y.add(1.0);
            y.add(2.0);
            z.add(0.0);
            z.add(1.0);
            z.add(2.0);
            ColorGrid grid = new ColorGrid(getPlotPanel().getTChart().getChart().chart);
            grid.add(x,y,z);
Could anyone please let me in on how this is done? I also tried adding start,mid and end colors as well as adding the data in many other ways, all of them resulting in a ton of exceptions. And as you may know, an exception generally doesnt weigh much ;)

Below are the two typical outputs:

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at com.steema.teechart.styles.ColorGrid.fillBitmap(ColorGrid.java:297)
	at com.steema.teechart.styles.ColorGrid.draw(ColorGrid.java:252)
	at com.steema.teechart.styles.Series.drawSeries(Series.java:2222)

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at com.steema.teechart.styles.ValueList.calcStats(ValueList.java:307)
	at com.steema.teechart.styles.ValueList.getRange(ValueList.java:340)
	at com.steema.teechart.styles.Custom3DPalette.createDefaultPalette(Custom3DPalette.java:498)
	at com.steema.teechart.styles.Custom3DPalette.checkPaletteEmpty(Custom3DPalette.java:841)
	at com.steema.teechart.styles.Custom3DPalette.doBeforeDrawChart(Custom3DPalette.java:847)
	at com.steema.teechart.styles.Custom3DGrid.doBeforeDrawChart(Custom3DGrid.java:275)

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

Post by Narcís » Mon Jan 05, 2009 2:52 pm

Hi Marius,

That's most likely a series design issue as ColorGrid series need to be populated as described here. Having said that, this code works fine:

Code: Select all

        ColorGrid grid = new ColorGrid(myChart.getChart());
        
        for (int i = 0; i<3; i++)
            for (int j = 0; j<3; j++)
                grid.add(i,j,j);
Anyway, I'll add your request to the defect list to be investigated 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

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

Post by Narcís » Mon Jan 05, 2009 3:26 pm

Hi Marius,

After a little bit more investigation this may be considered a ColorGrid series bug (TJ71013678).
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 » Thu Jan 08, 2009 2:11 pm

Hi, thanks for the reply. As I said, I already looked at the thread you referred to but since the java api is not similar to the one in that thread and not all population methods for Java worked, I needed to ask.

So, I have a follow-up question: I seem to have problems adding data to the plot which is not continuous or equi-spaced.

The data is sorted ascendingly first with respect to X-values, then for all X-values that are similar I have sorted on Z-values. the "#"-value is just what I add as the Y. The adding is like this (I apologize for the long example but it illustrates the problem in a nice way):

Code: Select all

grid.setIrregularGrid(true);
grid.setUsePalette(true);
grid.setPaletteStyle(PaletteStyle.STRONG);
grid.setUseColorRange(false);
loop(in this example 40 times):
  grid.add(X,#,Z);
Example:
0 X:-2.5 Z:-2.5 #:34
1 X:-2.5 Z:-2.142857 #:30
2 X:-2.5 Z:-1.785714 #:17
3 X:-2.5 Z:-1.428571 #:5
4 X:-2.5 Z:-1.428571 #:13
5 X:-2.5 Z:-1.428571 #:18
6 X:-2.5 Z:-1.071429 #:19
7 X:-2.5 Z:-1.071429 #:20
8 X:-2.5 Z:-0.714286 #:23
9 X:-2.5 Z:-0.357143 #:22
10 X:-2.142857 Z:-2.142857 #:26
11 X:-2.142857 Z:-0.714286 #:14
12 X:-2.142857 Z:-0.357143 #:27
13 X:-1.785714 Z:-2.5 #:8
14 X:-1.785714 Z:-2.5 #:9
15 X:-1.785714 Z:-2.5 #:24
16 X:-1.785714 Z:-2.5 #:35
17 X:-1.785714 Z:-2.142857 #:28
18 X:-1.785714 Z:-2.142857 #:32
19 X:-1.785714 Z:-1.071429 #:21
20 X:-1.785714 Z:-0.714286 #:11
21 X:-1.785714 Z:-0.714286 #:33
22 X:-1.785714 Z:0.0 #:25
23 X:-1.428571 Z:-2.5 #:4
24 X:-1.428571 Z:-2.5 #:36
25 X:-1.428571 Z:-2.5 #:40
26 X:-1.428571 Z:-2.142857 #:6
27 X:-1.428571 Z:-2.142857 #:39
28 X:-1.428571 Z:-1.428571 #:29
29 X:-1.428571 Z:-1.428571 #:38
30 X:-1.428571 Z:-0.714286 #:16
31 X:-1.071429 Z:-2.5 #:10
32 X:-1.071429 Z:-2.5 #:31
33 X:-1.071429 Z:-2.142857 #:1
34 X:-1.071429 Z:-2.142857 #:3
35 X:-1.0 Z:-1.0 #:41
36 X:-0.714286 Z:-2.142857 #:7
37 X:-0.714286 Z:-2.142857 #:12
38 X:-0.357143 Z:-2.142857 #:15
39 X:0.0 Z:-2.5 #:37
40 X:0.0 Z:-1.785714 #:2

The Exception I get when plotting is this:

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at com.steema.teechart.styles.ColorGrid.getZStep(ColorGrid.java:186)
	at com.steema.teechart.styles.ColorGrid.draw(ColorGrid.java:241)
	at com.steema.teechart.styles.Series.drawSeries(Series.java:2222)
	at com.steema.teechart.Chart.internalDraw(Chart.java:670)
	at com.steema.teechart.Chart.paint(Chart.java:1807)
Nothing shows up in the grid window, but when I mouseover I get loads of these exceptions:

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
	at com.steema.teechart.styles.ValueList.getValue(ValueList.java:430)
	at com.steema.teechart.styles.ColorGrid.getXStep(ColorGrid.java:216)
	at com.steema.teechart.styles.ColorGrid.maxZValue(ColorGrid.java:464)
	at com.steema.teechart.styles.ColorGrid.getMaxYValue(ColorGrid.java:440)
	at com.steema.teechart.Chart.internalMinMax(Chart.java:1583)
	at com.steema.teechart.axis.Axis.calcMinMax(Axis.java:1122)
	at com.steema.teechart.axis.Axis.adjustMaxMin(Axis.java:355)
	at com.steema.teechart.axis.Axes.adjustMaxMin(Axes.java:235)
So, is this a bug or am I not getting the point? I cannot add data to each point of the grid, but that should hopefully not be necessary?

Thanks in advance
Marius

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

Post by Narcís » Thu Jan 08, 2009 2:48 pm

Hi Marius,

I don't think this should work as there are repeated X-Z values combinations, for example:
3 X:-2.5 Z:-1.428571 #:5
4 X:-2.5 Z:-1.428571 #:13
5 X:-2.5 Z:-1.428571 #:18
6 X:-2.5 Z:-1.071429 #:19
7 X:-2.5 Z:-1.071429 #:20
or:
13 X:-1.785714 Z:-2.5 #:8
14 X:-1.785714 Z:-2.5 #:9
15 X:-1.785714 Z:-2.5 #:24
16 X:-1.785714 Z:-2.5 #:35
17 X:-1.785714 Z:-2.142857 #:28
18 X:-1.785714 Z:-2.142857 #:32
I don't think such data can be plotted in a grid structure.

Code to reproduce the problem:

Code: Select all

        ColorGrid colorGrid1 = new ColorGrid(myChart.getChart());
        
        colorGrid1.setIrregularGrid(true);
        
        colorGrid1.add(-2.5, 34, -2.5);
        colorGrid1.add(-2.5, 30, -2.142857);
        colorGrid1.add(-2.5, 17, -1.785714);
        colorGrid1.add(-2.5, 5, -1.428571);
        colorGrid1.add(-2.5, 13, -1.428571);
        colorGrid1.add(-2.5, 18, -1.428571);
        colorGrid1.add(-2.5, 19, -1.071429);
        colorGrid1.add(-2.5, 20, -1.071429);
        colorGrid1.add(-2.5, 23, -0.714286);
        colorGrid1.add(-2.5, 22, -0.357143);
        colorGrid1.add(-2.142857, 26, -2.142857);
        colorGrid1.add(-2.142857, 14, -0.714286);
        colorGrid1.add(-2.142857, 27, -0.357143);
        colorGrid1.add(-1.785714, 8, -2.5);
        colorGrid1.add(-1.785714, 9, -2.5);
        colorGrid1.add(-1.785714, 24, -2.5);
        colorGrid1.add(-1.785714, 35, -2.5);
        colorGrid1.add(-1.785714, 28, -2.142857);
        colorGrid1.add(-1.785714, 32, -2.142857);
        colorGrid1.add(-1.785714, 21, -1.071429);
        colorGrid1.add(-1.785714, 11, -0.714286);
        colorGrid1.add(-1.785714, 33, -0.714286);
        colorGrid1.add(-1.785714, 25, 0.0);
        colorGrid1.add(-1.428571, 4, -2.5);
        colorGrid1.add(-1.428571, 36, -2.5);
        colorGrid1.add(-1.428571, 40, -2.5);
        colorGrid1.add(-1.428571, 6, -2.142857);
        colorGrid1.add(-1.428571, 39, -2.142857);
        colorGrid1.add(-1.428571, 29, -1.428571);
        colorGrid1.add(-1.428571, 38, -1.428571);
        colorGrid1.add(-1.428571, 16, -0.714286);
        colorGrid1.add(-1.071429, 10, -2.5);
        colorGrid1.add(-1.071429, 31, -2.5);
        colorGrid1.add(-1.071429, 1, -2.142857);
        colorGrid1.add(-1.071429, 3, -2.142857);
        colorGrid1.add(-1.0, 41, -1.0);
        colorGrid1.add(-0.714286, 7, -2.142857);
        colorGrid1.add(-0.714286, 12, -2.142857);
        colorGrid1.add(-0.357143, 15, -2.142857);
        colorGrid1.add(0.0, 37, -2.5);
        colorGrid1.add(0.0, 2, -1.785714);
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 » Thu Jan 08, 2009 9:47 pm

Ok I assumed that doublet values would be overwritten, but that might be the problem. Will create a doublet-remover then, thanks.

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

Post by Marius » Fri Jan 09, 2009 12:05 pm

This array of data is added in the manner previously described, but still I get Exceptions... Now both X and Z are in ascending order, and there are no doublette values. The NullPointerException is gone, but there are still ArrayOutOfBoundsExceptions going on:
  • 0 X:1.0 Z:-2.5 #:5
    1 X:1.0 Z:-2.142857 #:14
    2 X:1.0 Z:-1.785714 #:8
    3 X:1.0 Z:-1.428571 #:4
    4 X:1.0 Z:-1.071429 #:1
    5 X:1.0 Z:-0.714286 #:7
    6 X:1.0 Z:-0.357143 #:15
    7 X:1.0 Z:0.0 #:2
    8 X:2.0 Z:-2.5 #:34
    9 X:2.0 Z:-1.785714 #:32
    10 X:2.0 Z:-1.428571 #:36
    11 X:2.0 Z:-1.071429 #:31
    12 X:2.0 Z:0.0 #:37
    13 X:3.0 Z:-1.0 #:41

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
	at com.steema.teechart.styles.ValueList.getValue(ValueList.java:430)
	at com.steema.teechart.styles.ColorGrid.getXStep(ColorGrid.java:214)
	at com.steema.teechart.styles.ColorGrid.maxZValue(ColorGrid.java:464)
	at com.steema.teechart.styles.ColorGrid.getMaxYValue(ColorGrid.java:440)
	at com.steema.teechart.Chart.internalMinMax(Chart.java:1583)
Any idea on this? I note that there are several similar values in the Z-array, but none with also similar X-value...

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 Jan 09, 2009 2:45 pm

Hi Marius,

I could reproduce the issue here and added it (TJ71013700) to the defect list to be investigated 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 » Mon Jan 12, 2009 9:18 am

OK that's good news at least, but can you propose a work-around or a different approach for me on this?

Unrelated; to get the newest release, we buy the package again right? Looking forward to try the improvements from last time.

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

Post by Narcís » Mon Jan 12, 2009 9:26 am

Hi Marius,
OK that's good news at least, but can you propose a work-around or a different approach for me on this?
I'm sorry but I can't think of a workaround for this. The only idea I can think of would be using multiple ColorGrid series. For example, you could try using one for all X=1.0 values and another one for X=2.0.
Unrelated; to get the newest release, we buy the package again right? Looking forward to try the improvements from last time.
This has been reported as a TeeChart for Java v1 issue. Current version is v2 so I can't promise it will be fixed in v1. If it only was fixed in v2 you should only have to upgrade your v1 license to v2:

http://www.steema.com/ordering/order_tchjava_u.shtml
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 Jan 13, 2009 12:46 pm

:?

Hmm what about using surfaces for this purpose, would that work you think? When I try to split up the series I dont get any exceptions but I also do not get anything up in my grid... Any additional thoughts on this would be greatly appreciated as it is highly important for me to get this view going.

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 Jan 13, 2009 1:17 pm

Hi Marius,

Using a Surface series plots a chart:

Code: Select all

        Surface surface1 = new Surface(myChart.getChart());        
        surface1.setIrregularGrid(true);
        
        surface1.add(1.0, 5, -2.5); 
        surface1.add(1.0, 14, -2.142857);
        surface1.add(1.0, 8, -1.785714);
        surface1.add(1.0, 4, -1.428571);
        surface1.add(1.0, 1, -1.071429);
        surface1.add(1.0, 7, -0.714286);
        surface1.add(1.0, 15, -0.357143);
        surface1.add(1.0, 2, 0.0);
        
        surface1.add(2.0, 34, -2.5);
        surface1.add(2.0, 32, -1.785714);
        surface1.add(2.0, 36, -1.428571);
        surface1.add(2.0, 31, -1.071429);
        surface1.add(2.0, 37, 0.0);
        surface1.add(3.0, 41, -1.0);
        
        myChart.getAspect().setView3D(true);
        myChart.getAspect().setOrthogonal(false);
        myChart.getAspect().setElevation(270);
        myChart.getAspect().setRotation(360);
However this may not be what you expect as for defining a surface series cell you need 4 points.
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 Jan 14, 2009 8:22 am

Hmm thanks, but Surface did not work very well.

I am not sure if I understood you correctly previously: Is this bug also in version 2 of the Java-API? If it is, what do you think will be done about it (wrt when it might be fixed)?

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

Post by Narcís » Wed Jan 14, 2009 9:03 am

Hi Marius,

Yes, the bug is also present in v2. Sorry but I don't know what will be done with this issue at the present moment. An estimate fix date hasn't been set either. I recommend you to be aware at this forum or subscribe to our RSS news feed for new release announcements and what's fixed on them.
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 May 06, 2009 2:57 pm

As the need for it is rising; have you figured out what to do with this problem yet? It is a whole plot type which is not working properly, so it is a bit of a problem to us at least. It would be really nice if I also do not have to do the sorting of the input-arrays myself too, as it is just such a potential for errors ;)

Thanks in advance
Marius

Post Reply