Issues When Using Null Points and Sphere Points

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
mdemoret
Newbie
Newbie
Posts: 4
Joined: Wed Dec 14, 2011 12:00 am

Issues When Using Null Points and Sphere Points

Post by mdemoret » Thu Feb 23, 2012 7:26 pm

Stemma,

I have encountered a couple more problems when working with Steema's Line Charts. The first problem that I encountered is if a null point's color does not match the color of the series line, some of the points will still be drawn. Using TeeCharts 4.1.2012.1031 with a blank chart with one series, and executing the following code after Initializing the components:

Code: Select all

int? nullInt = null;
line1.Pointer.Brush.Color = Color.Red;
for (int i = 0; i < 25; i++)
{
    if (i > 5 && i < 10)
        tChart1[0].Add(i, nullInt, Color.Transparent);
    else
        tChart1[0].Add(i, i);
}
Results in the following plot being drawn:
HiddenPointsVisible.png
HiddenPointsVisible.png (64.26 KiB) Viewed 4157 times
I would expect that since the points are null and the color is transparent that the points at x = 6, 7, 8 and 9 would not be visible on the chart. However, point 6 is hidden and the others are visible with no lines in between each point. This only occurs if the brush color of the points is specifically set. Ommitting "line1.Pointer.Brush.Color = Color.Red;" in the code sample above will cause points 6, 7, 8, and 9 not to be drawn as expected.

The next issue I am encountering is when using the point type of "Sphere", sometimes the point is not drawn in the legend or is partially clipped in the legend. This seems to only occur when the legend is at the bottom of the plot and the point type is a Sphere. The following picture shows the problem:
ClippedSphereInLegend.png
ClippedSphereInLegend.png (32.41 KiB) Viewed 4155 times
Here only the first line in the legend is drawn correctly. The next line is partially clipped and the remaining lines have no symbol at all. It appears to me that there is a clipping region that is being incorrectly set and is cutting off the bottom of the chart.

I am wondering if there are any viable workarounds for these issues or if they are bugs in TeeChart? Thanks for your help.

Michael Demoret

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Issues When Using Null Points and Sphere Points

Post by Sandra » Tue Feb 28, 2012 9:01 am

Hello Michael,

Sorry for the delay. I have made a simple code where works fine for me and solve the two problems you have with Pointers. To solve the first problem, I have used the GetPointerStyle event, where I have changed the color of pointer to transparent and to solve the second problem, I have only set property of Legend DrawBehind to false. Please see next code and tell us if it works as you expect.

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Line line1; 
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            int? nullInt = null;
            //Series
            line1 = new Line(tChart1.Chart);
            line1.Pointer.Visible = true;
            line1.Pointer.Color = Color.Red;
            line1.Pointer.Pen.Visible = false;
            line1.Pointer.Style = PointerStyles.Rectangle;//PointerStyle.Shpere
         
            
            for (int i = 0; i < 25; i  )
            {
                if (i > 5 && i < 10)
                {
                    tChart1[0].Add(i, nullInt, Color.Transparent);
                       
                }
                else
                {
                    tChart1[0].Add(i, i);
                }
            }
            //Legend
            tChart1.Legend.Alignment = LegendAlignments.Bottom;
            tChart1.Legend.DrawBehind = false;
            //Event GetPointerStyle
            (tChart1[0] as Steema.TeeChart.Styles.Line).GetPointerStyle  = new CustomPoint.GetPointerStyleEventHandler(Form1_GetPointerStyle);
          
        }

        void Form1_GetPointerStyle(CustomPoint series, GetPointerStyleEventArgs e)
        {
            if (e.ValueIndex > 5 && e.ValueIndex < 10)
            {
                e.Color = Color.Transparent;
            }
        }
I hope will help.

Thanks,
Best Regards,
Sandra Pazos / 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

mdemoret
Newbie
Newbie
Posts: 4
Joined: Wed Dec 14, 2011 12:00 am

Re: Issues When Using Null Points and Sphere Points

Post by mdemoret » Mon Mar 05, 2012 9:39 pm

Sandra,

Thank you for your help. The two workarounds you described do help me out with the problems I was encountering. However, I do feel that the first issue is a bug because the null points should all be treated consistently (Either all drawn at y=0 or hidden similar to the point at x=6) and not have both null points that are hidden and drawn in the same series.

After implementing these workarounds I did run into another issue. If a series contains only null data points, the automatic scaling for the axes will not function as expected. I would expect that if a series only contained null points, it would not alter the automatic scaling. It seems that if a series has only null points, the y-axis will always show 0, even if y=0 is outside the range of the data. It appears that this only applies to the y-axis. The x-axis functions as I would expect. In the picture below I have created two series with identical data (y = (x - 1)^2 + 5), and setting the second line data to Color.Transparent at each step. The code used to generate the data is:

Code: Select all

for (int i = 0; i < 100; i++)
{
   line1.Add(i / 25D + , Math.Pow((i / 25D), 2) + 5);
   line2.Add(i / 25D, Math.Pow((i / 25D), 2) + 5, Color.Transparent);
}
Which results in the following figure:
AutoScaling.png
AutoScaling.png (19.11 KiB) Viewed 4125 times
I have tried changing the TreatNulls property and the line's Visible property to false, but these do not give me the desired result because I would like the line to stay in the legend (In my real world scenario, not in the simplified example I have shown above). Is there a workaround for this issue I am having? Thanks again.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Issues When Using Null Points and Sphere Points

Post by Sandra » Tue Mar 06, 2012 4:23 pm

Hello mdemoret,
Thank you for your help. The two workarounds you described do help me out with the problems I was encountering. However, I do feel that the first issue is a bug because the null points should all be treated consistently (Either all drawn at y=0 or hidden similar to the point at x=6) and not have both null points that are hidden and drawn in the same series.
Ok. I am agree with you. I have added your request in bug list report with number [TF02016070]. We will try to fix it for next maintenance releases.
After implementing these workarounds I did run into another issue. If a series contains only null data points, the automatic scaling for the axes will not function as expected. I would expect that if a series only contained null points, it would not alter the automatic scaling. It seems that if a series has only null points, the y-axis will always show 0, even if y=0 is outside the range of the data. It appears that this only applies to the y-axis. The x-axis functions as I would expect. In the picture below I have created two series with identical data (y = (x - 1)^2 + 5), and setting the second line data to Color.Transparent at each step. The code used to generate the data is:I have tried changing the TreatNulls property and the line's Visible property to false, but these do not give me the desired result because I would like the line to stay in the legend (In my real world scenario, not in the simplified example I have shown above). Is there a workaround for this issue I am having? Thanks again.
I suggest use SetMinMax() property to achieve as you want as do in next lines of code:

Code: Select all

 for (int i = 0; i < 100; i++)
            {
                line1.Add(i / 25D, Math.Pow((i / 25D), 2) + 5);
                line2.Add(i / 25D, Math.Pow((i / 25D), 2) + 5, Color.Transparent);
            }
            tChart1.Axes.Left.SetMinMax(line1.YValues.Minimum, line1.YValues.Maximum);
Can you tell us if previous code works as you expect?

Thanks,
Best Regards,
Sandra Pazos / 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

Post Reply