Custom levels in Contour Chart don't work!!

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
GFoundries
Newbie
Newbie
Posts: 14
Joined: Wed May 21, 2008 12:00 am

Custom levels in Contour Chart don't work!!

Post by GFoundries » Mon Jun 21, 2010 12:22 am

Hello,

For all the issues mentioned below, I have provided the sample code I used.
  • 1) ContourLevel creation issue:
    When I add data to contour charts using the add(double[] X, double[] Y, double[] Z) method and calling the setAutomaticLevels(true), setNumLevels(7) and createAutoLevels() methods to populate the levels, always considers the Y data to create levels not Z. Any specific reason why it does this way ?

    2) Contour custom level issue:
    • a) After I get all the ContourLevels by calling the createAutoLevels() and when I try to modify the individual levels by calling
      series.getLevels().getLevel(0).setUpToValue(2);
      to create my custom levels, it never reflects in the TeeChart ! Is this a bug or intentional ?
      b) Also I tried creating ContourLevels object and 7 ContourLevel objects for all the 7 levels I needed and added them to the series. It never takes this into account.
      It still creates it own levels in the chart.
      c) I tried using ContourLevelResolver too but it never gets a call back to the getLevel() method where I am setting my custom levels.

I tried doing all this by modifying the LevelsDemo code as per my need. In the ContourDemo class also, when ever I try to add any data using the add(double[], double[], double[]) method, I don't see any output for any data except for the one given in demo.

An early response is highly appreciated.

Thanks,
Gunjan

In ContourDemo, I have overridden the initComponents() method based on my requirement.

Code: Select all

 protected void initComponents() {
        super.initComponents();

        // First we add XYZ points to the Contour series...
        contourSeries = new com.steema.teechart.styles.Contour(chart1.getChart());

double[] X = {-2.54, -2.6232,-2.648,-2.6396,-2.6798, -2.6162, -2.6292, -2.622,-2.6556,-2.626,-2.648,-2.5866,-2.669,2.6088,-2.6788,-2.6266,-2.6486,-2.5492,-2.623};
double[] Y = {104.82,105.44,106.18,105.44,105.92,104.82,104.78,105.48,105.48,105.12,105.4,104.92,105.58,105.02,104.76, 105.24,105.62,105.36,105.1};
double[] Z = {3.563115488,2.873769024,2.784243509,2.560429722,2.452999105,3.464637422,2.882721576,3.22291, 3.124440466,3.321396598,3.491495076,3.965980304,3.314867763,3.18084346,3.368477484,3.082558971,3.368477484,3.600786276,3.63652609};

      contourSeries.add(X,Z,Y); // Had to give Z first so that it calculates level  based on Z not Y !!

      createCustomLevels(contourSeries);

      //setCustomLevels(); Tried this one too but doesn't work

     // We specify the Y levels position to the "middle"
        contourSeries.setYPosition((contourSeries.getYValues().getMaximum()+ contourSeries.getYValues().getMinimum() )/2.0);

       view2DButton = new JCheckBox("2D");
        showWallsButton = new JCheckBox("Show Walls");
        showWallsButton.setSelected(true);
        colorEachButton = new JCheckBox("Color Each Level");
        colorEachButton.setSelected(true);
        posLevelButton = new JCheckBox("Levels at Y");
        surfaceButton = new JCheckBox("Surface");

        levelSlider = new JSlider(JSlider.VERTICAL, 0, 1000, 50);
        levelSlider.setValue((int)(1000-Math.round(contourSeries.getYPosition())));

}

private void createCustomLevels(Contour contourSeries)
{
   ContourLevels levels = new ContourLevels();
        ContourLevel level1 = new ContourLevel(contourSeries);
        level1.setColor(Color.red);
        level1.setUpToValue(2.0);
        levels.add(level1);
        
        ContourLevel level2 = new ContourLevel(contourSeries);
        level2.setColor(Color.YELLOW);
        level2.setUpToValue(2.667);
        levels.add(level2);
        
        ContourLevel level3 = new ContourLevel(contourSeries);
        level3.setColor(Color.GREEN);
        level3.setUpToValue(3.333);
        levels.add(level3);
        
        ContourLevel level4 = new ContourLevel(contourSeries);
        level4.setColor(Color.BLUE);
        level4.setUpToValue(4.0);
        levels.add(level4);
        
        ContourLevel level5 = new ContourLevel(contourSeries);
        level5.setColor(Color.CYAN);
        level5.setUpToValue(4.667);
        levels.add(level5);
        
        ContourLevel level6 = new ContourLevel(contourSeries);
        level6.setColor(Color.PINK);
        level6.setUpToValue(5.333);
        levels.add(level6);
        
        ContourLevel level7 = new ContourLevel(contourSeries);
        level7.setColor(Color.BLACK);
        level7.setUpToValue(6.0);
        levels.add(level7);
        
        contourSeries.setNumLevels(7);
        contourSeries.setLevels(levels);

}


 private void setCustomLevels() {
        contourSeries.setNumLevels(7);
        contourSeries.createAutoLevels();
        contourSeries.getLevels().getLevel(0).setUpToValue(2.0);
        contourSeries.getLevels().getLevel(1).setUpToValue(2.667);
        contourSeries.getLevels().getLevel(2).setUpToValue(3.0);
        contourSeries.getLevels().getLevel(3).setUpToValue(3.333);
        contourSeries.getLevels().getLevel(4).setUpToValue(4.0);
        contourSeries.getLevels().getLevel(5).setUpToValue(4.667);
        contourSeries.getLevels().getLevel(6).setUpToValue(6.0);

    }

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

Re: Custom levels in Contour Chart don't work!!

Post by Yeray » Fri Jun 25, 2010 8:17 am

Hi Gunjan,
GFoundries wrote: 1) ContourLevel creation issue:
When I add data to contour charts using the add(double[] X, double[] Y, double[] Z) method and calling the setAutomaticLevels(true), setNumLevels(7) and createAutoLevels() methods to populate the levels, always considers the Y data to create levels not Z. Any specific reason why it does this way ?
I think here is happening the same as discussed here, isn't it?
GFoundries wrote:2) Contour custom level issue:

a) After I get all the ContourLevels by calling the createAutoLevels() and when I try to modify the individual levels by calling
series.getLevels().getLevel(0).setUpToValue(2);
to create my custom levels, it never reflects in the TeeChart ! Is this a bug or intentional ?
b) Also I tried creating ContourLevels object and 7 ContourLevel objects for all the 7 levels I needed and added them to the series. It never takes this into account.
It still creates it own levels in the chart.
c) I tried using ContourLevelResolver too but it never gets a call back to the getLevel() method where I am setting my custom levels.
The following seems to work as expected, can't you see different levels than the default?

Code: Select all

        tChart1.getAspect().setView3D(false);

        tChart1.getSeries().clear();
        com.steema.teechart.styles.Contour contour = new com.steema.teechart.styles.Contour(tChart1.getChart());
        contour.fillSampleValues();

        com.steema.teechart.styles.ContourLevels levels = new com.steema.teechart.styles.ContourLevels();
        com.steema.teechart.styles.ContourLevel level1 = new com.steema.teechart.styles.ContourLevel(contour);
        level1.setColor(Color.RED);
        level1.setUpToValue(0.1);
        levels.add(level1);
        
        com.steema.teechart.styles.ContourLevel level2 = new com.steema.teechart.styles.ContourLevel(contour);
        level2.setColor(Color.YELLOW);
        level2.setUpToValue(0.2);
        levels.add(level2);

        com.steema.teechart.styles.ContourLevel level3 = new com.steema.teechart.styles.ContourLevel(contour);
        level3.setColor(Color.GREEN);
        level3.setUpToValue(0.3);
        levels.add(level3);

        com.steema.teechart.styles.ContourLevel level4 = new com.steema.teechart.styles.ContourLevel(contour);
        level4.setColor(Color.BLUE);
        level4.setUpToValue(0.4);
        levels.add(level4);

        com.steema.teechart.styles.ContourLevel level5 = new com.steema.teechart.styles.ContourLevel(contour);
        level5.setColor(Color.CYAN);
        level5.setUpToValue(0.5);
        levels.add(level5);

        com.steema.teechart.styles.ContourLevel level6 = new com.steema.teechart.styles.ContourLevel(contour);
        level6.setColor(Color.PINK);
        level6.setUpToValue(0.6);
        levels.add(level6);

        com.steema.teechart.styles.ContourLevel level7 = new com.steema.teechart.styles.ContourLevel(contour);
        level7.setColor(Color.BLACK);
        level7.setUpToValue(0.7);
        levels.add(level7);

        contour.setNumLevels(7);
        contour.setLevels(levels);
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

GFoundries
Newbie
Newbie
Posts: 14
Joined: Wed May 21, 2008 12:00 am

Re: Custom levels in Contour Chart don't work!!

Post by GFoundries » Fri Jun 25, 2010 12:15 pm

Hi Yeray,

For the point 2:
Yeray wrote:The following seems to work as expected, can't you see different levels than the default?
What I meant was if you try to modify the setUpToValue() to some other value, it doesn't reflect in the legend. The levels still show the same set of values always.
I had tried the LevelsDemo.java and changed the setCustomLevels() method with the sample code I provided in this topic. No matter what ever you provide in the method, it always gives you the same values for no of levels = 7 (Please check the image)

Thanks,
Gunjan
Attachments
levels.PNG
Levels being generated now in teechart
levels.PNG (2.93 KiB) Viewed 9190 times

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

Re: Custom levels in Contour Chart don't work!!

Post by Yeray » Mon Jun 28, 2010 11:53 am

Hi Gunjan,

You are right. It seems that the changes made to a level (through the editor or via setUpToValue method) aren't reflected at the legend.
I've added it to the defect list to be fixed in future releases (TJ71015008).
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