Page 1 of 1

Null Points

Posted: Wed Sep 23, 2009 12:21 pm
by 13052926
Sorry, I see this has been discussed but I simply cannot get the result I'm expecting.

I have a financial chart. All prices (3400 of them) are in a dataset. If doing a daily interval I simply add every price to my line works perfectly. Now if I change to a weekly interval only prices marked as weekly in the dataset should plot. However I still want 3400 points in my series.

I did this using the old ActiveX control quite simply:
chart.Series(0).AddXY iPoint, dblPrice, "", Colour

This doesn't work using the .NET control (v3). Here is a snippet of my code:
Dim line As New Styles.Line(chart0.Chart)

For iPoint As Integer = 0 To (prices.Tables(0).Rows.Count - 1)
.
.
.
if plottingweekly=true then
line.Add(CType(iPoint, Double), CType(prices.Tables(0).Rows(iPoint).Item("price"), Double))
end if
.
.
.
Next

Help?

Re: Null Points

Posted: Thu Sep 24, 2009 11:56 am
by yeray
Hi rossmc,

We are not sure to understand what are you exactly doing here. Could you please send us a simple example project we can run as-is to reproduce the problem here?

Re: Null Points

Posted: Mon Sep 28, 2009 12:48 pm
by 13052926
Hi Yeray

Thanks for response. I found a solution that works for my needs. If the price should not be plotted on the chart I explicitly call series.Add(), just as written here without any parameters. That seems to correctly(?) add a null point.

If I then set series.TreatNulls = Styles.TreatNullsStyle.Skip I get what I wanted.

There does seem to be some strange behaviour in VB.NET using the TreatNulls property? For example if I do exactly the same as above but set TreatNulls = DoNotPaint, none of the points on my chart get drawn (including those with valid values) except the very first one. As above but selecting TreatNulls = Ignore draws the null points.

Re: Null Points

Posted: Tue Sep 29, 2009 11:05 am
by yeray
Hi rossmc,

I'm still not sure to see how are you entering your data to the chart. Let me recommend you to take a look at the demo at All features\Welcome !\Chart styles\Standard\Line(Strip)\Line/Horizontal line TreatNulls.
If you still have problems with the null points treatment, please, don't hesitate to let us know and please, send us a simple example project we can run as-is to reproduce the issue here.

Re: Null Points

Posted: Tue Oct 06, 2009 9:12 am
by 13052926
Yeray

I thought I had a way to make this work, but the current 'solution' I found is creating too many problems for me. So here is the exact code from my project for loading a line series.

Note first that the table in the prices dataset has 3500 rows in it.

Private Sub plot_Line()

Dim s As New Styles.Line(chart0.Chart)
Dim dbl As Double = 0

With s
.Title = "Company Shortname"

.TreatNulls = Styles.TreatNullsStyle.Skip

.Color = Color.Blue
.LinePen.Width = 1
.HorizAxis = Styles.HorizontalAxis.Both
.Cursor = Cursors.Hand
.VertAxis = Styles.VerticalAxis.Both

For iPoint As Integer = 0 To (prices.Tables(0).Rows.Count - 1)
'Extract what we will be plotting
dbl = CType(prices.Tables(0).Rows(iPoint).Item("priceClose"), Double)

Select Case tdo.PriceInterval
Case tdoPriceInterval.Daily
.Add(CType(iPoint, Double), dbl)

Case tdoPriceInterval.Weekly
'Weekly
If InStr(1, prices.Tables(0).Rows(iPoint).Item("prFlags").ToString, "W") > 0 Or iPoint = 1 Or iPoint = (prices.Tables(0).Rows.Count - 1) Then
.Add(CType(iPoint, Double), dbl)
Else
.Add()
End If

End Select
Next

End With

End Sub

After plotting the line above, I set the axes.bottom min and max to 'zoom in' to the last 'year' worth of data, as such:
chart0.axes.bottom.setminmax(chart0.Series(0).XValues.Count - 260, chart0.Series(0).XValues.Count)

On the daily view this all works fine. If I switch to weekly (meaning I'm 'plotting' nulls whenever the date is not a Friday) with the above code I get a line plotted, but when I zoom in if the first point starting at the left-side of the bottom axis (in other words the point represented by axes.bottom.minimum) is a null point there is no line drawn and I have a blank space, instead of the first weekly point on the visible axes joining to the previous weekly point which is now outside of the viewable area.

It's important to understand here that in my application the bottom axes represents a fixed length of time, lets say four years. If I only want some of the points during that four year period to plot I can't have the total number of points in the chart change.

Lastly the reason I now have a problem with my current solution is with the CursorTool. I add a vertical cursortool which I snap to the price line. Once again this works on a daily chart, but on a weekly chart the nulls are not ignored meaning the vertical cursortool no longer snap to the visible prices.

Help?

Re: Null Points

Posted: Tue Oct 06, 2009 11:00 am
by yeray
Hi rossmc,

Thank you for the code snipped, but we can't run it as there are calls to a datatable where we don't have access.

If I understand well, you are having two problems. The first is related to your null points, that they seem to make your line series not visible when the first point is a null. So I've tried to reproduce it with the following code but I couldn't:

Code: Select all

            MyChart.AddSeries(TeeChart.ESeriesClass.scLine);

            for (int i = 0; i < 10; i++)
            {
                MyChart.Series(0).Add(i, "", (uint)TeeChart.EConstants.clTeeColor);
            }

            MyChart.Series(0).asLine.Pointer.Visible = true;
            MyChart.Series(0).SetNull(0);
        }
So please, try to send us a simple example project we can run as-is to reproduce the problem here.
For our help in this process, here is is a little example of how you could prepare a sample datatable.

And the second problem is that the "snap to points" feature of the cursor tool still considers the null values of your series as snappable points. I could reproduce it and I've added it to the wish list to be enhanced in future releases (TV52014467). Haven't you noticed this issue in the AX version?

Re: Null Points

Posted: Tue Oct 06, 2009 11:13 am
by 13052926
Re: And the second problem is that the "snap to points" feature of the cursor tool still considers the null values of your series as snappable points. I could reproduce it and I've added it to the wish list to be enhanced in future releases (TV52014467). Haven't you noticed this issue in the AX version?

It works fine for me in the AX version.

I'll try make a sample. Where will I send it?

Re: Null Points

Posted: Tue Oct 06, 2009 11:33 am
by yeray
Hi rossmc,

You can attach your files directly here in the forums messages but, if your project is too heavy for that, you can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Re: Null Points

Posted: Thu Oct 08, 2009 12:52 pm
by 13052926
Yeray

If I could buy you a beer (or ten) I would. I was being an idiot and letting my newbie status in VS2005 and with the new control confuse me. Turns out the control was doing exactly the right thing all along, I was looking at the wrong collection!

The issue was, I was using series.xvalues.count property to determine total price points instead of just using my dataset row count. If I have 260 prices in my dataset but am plotting weekly - meaning I only plot 52 of those prices - then the chart is correctly telling me that there are 52 xvalues in the series.

Sorry. No wonder you were confused by my questions above. Short answer: I was being dumb but worked it out. Everything working perfectly again!

Once again if anyone reading this would like more info feel free to contact me.

Re: Null Points

Posted: Thu Oct 08, 2009 1:32 pm
by yeray
Hi rossmc,
rossmc wrote:If I could buy you a beer (or ten) I would
Don't say it too loud... ;)

Back to the issue... I'm glad to see that you found a way to make it run properly!