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.
- a) After I get all the ContourLevels by calling the createAutoLevels() and when I try to modify the individual levels by calling
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);
}