setIgnoreNulls

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Chen
Newbie
Newbie
Posts: 43
Joined: Tue Mar 11, 2008 12:00 am
Contact:

setIgnoreNulls

Post by Chen » Wed Aug 20, 2008 8:00 pm

Hi,

I see that setIgnoreNulls() is not available for Line but it is available for FastLine. Is there any work around for this ?

I can display a a point on the Line using a rectangular shape but this is not available in FastLine. Is there any work around for this ?

If someone wants both these features to be included in a line chart then it is not possible now. Correct me if I am wrong.

Thanks,
Varun

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Aug 21, 2008 11:25 am

Hi Varun,
I see that setIgnoreNulls() is not available for Line but it is available for FastLine. Is there any work around for this ?
For Line Series this property is not necesary. As in the Help says :
For speed reasons, FastLine series supports null (empty) values only when IgnoreNulls property is false.

By default all points are displayed (IgnoreNulls is true by default).

To enable FastLine series to hide null points, set IgnoreNulls to false.
I can display a a point on the Line using a rectangular shape but this is not available in FastLine. Is there any work around for this ?
The way around would be to use Line Series instead. FastLine series has been designed to save time drawing points so some of the Line features has been disabled for this Series type. In your case you have two options, use the Line Series or use the FastLine Series in conjunction with a Point Series.
If someone wants both these features to be included in a line chart then it is not possible now. Correct me if I am wrong.
Yes, both features can be used with the Line Series.

Chen
Newbie
Newbie
Posts: 43
Joined: Tue Mar 11, 2008 12:00 am
Contact:

Post by Chen » Thu Aug 21, 2008 2:22 pm

Quote:

For speed reasons, FastLine series supports null (empty) values only when IgnoreNulls property is false.

By default all points are displayed (IgnoreNulls is true by default).

To enable FastLine series to hide null points, set IgnoreNulls to false.

>>>> What if I want to say setIgnoreNulls(false) for a Line series.


import javax.swing.JFrame;
import javax.swing.JPanel;

import com.steema.teechart.TChart;
import com.steema.teechart.styles.Line;
import com.steema.teechart.styles.MarksStyle;

public class Test {

public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.setSize(800, 800);
TChart chart = new TChart();

panel.add(chart);
chart.setSize(800, 800);
Line line = new Line(chart.getChart());
line.getMarks().setStyle(MarksStyle.LABEL);
chart.getAxes().getBottom().getLabels().setStyle(
com.steema.teechart.axis.AxisLabelStyle.AUTO);

for (int i = 0; i < 10; i++) {
if ((i != 3) && (i != 7))
line.add(i, i, " " + i);
else
line.setNull(line.add(0.0, " "));
}
line.getPointer().setVisible(true);
frame.add(panel);
frame.setSize(800, 800);
frame.setVisible(true);
}
}

If I run this program, then I will see a break between the lines. Is there any way I can join those two points ??
So if I see the example for fastline, then I can see that when I say setIgnoreNulls(true), then there are no breaks in between the lines. I want something like that.

Thanks,
Varun

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Aug 22, 2008 8:39 am

Hi Varun,

ok, using the Line Series a way would be to use Add method instead of SetNull :

Code: Select all

 Line line = new Line(tChart2.getChart());
 line.getMarks().setStyle(MarksStyle.LABEL);
 tChart2.getAxes().getBottom().getLabels().setStyle(
 com.steema.teechart.axis.AxisLabelStyle.AUTO);
 for (int i = 0; i < 10; i++) {
 if ((i != 3) && (i != 7))
     line.add(i, i, " " + i);
 else
     line.add(0.0," ");
    // line.setNull(line.add(0.0, " "));
 }
line.getPointer().setVisible(true); 
This will leave the line between points, although it will pass through the 0 Value, as IgnoreNulls of FastLine Series does. To hide pointers of 0 data points you will have to use the OnGetPointerStyle event (setting the 0 values to none pointer style).

In case you want to join the lines deleting the 0 points then the following code could be used :

Code: Select all

 Line line = new Line(tChart2.getChart());
 line.getMarks().setStyle(MarksStyle.LABEL);
 tChart2.getAxes().getBottom().getLabels().setStyle(
 com.steema.teechart.axis.AxisLabelStyle.AUTO);
 for (int i = 0; i < 10; i++) {
 if ((i != 3) && (i != 7))
     line.add(i, i, " " + i);
 else
    line.setNull(line.add(0.0, " "));
 }
 
 line.getPointer().setVisible(true); 

 for (int ii = 0; ii < tChart2.getSeries(0).getCount()-1; ii++) {
     if (tChart2.getSeries(0).isNull(ii)) {
         tChart2.getSeries(0).delete(ii);
     }   
 }
For the next TeeChart for Java release a new feature related with Nulls has been introduce, it's the TreatNulls feature which allows to specify how the nulls points have to be treated (Dont paint, ignore or skip them). Then the following code should be used :

Code: Select all


  Line line = new Line(tChart2.getChart());
  line.getMarks().setStyle(MarksStyle.LABEL);
  tChart2.getAxes().getBottom().getLabels().setStyle(
  com.steema.teechart.axis.AxisLabelStyle.AUTO);
  for (int i = 0; i < 10; i++) {
  if ((i != 3) && (i != 7))
      line.add(i, i, " " + i);
  else
     line.setNull(line.add(0.0, " "));
  }
 
  line.getPointer().setVisible(true); 
 line.setTreatNulls(TreatNullsStyle.IGNORE);

Post Reply