[RESOLVED] Is there an override/workaround for this?
The ms chart control is quite fussy. If I use this code in a loop where the data is created :
Code:
Form1.Chart1.Series(count).Points.AddXY(x, y)
*
It returns this, which is great.
However, I need the data to be in a datatable, and the chart to be created from the data in the table. Rather than using databind, because it gives terrible values for the axes, I tried this:
Code:
For Each row As DataRow In ARpassover_table.Rows
Chart1.Series(count).Points.AddXY(row.Item(0), row.Item(1))
Next row
The aim was to create the same chart as above. Unfortunately the result was this :
Whhhhhhhhyyyyyyyy! (The same data was used)
Any ideas on how to get it looking like the first example, using data from a datatable?
No luck, for some reason, the X- axis becomes impervious to all simple editing using your examples resulted in this:
I believe that the X axis is showing the first 30 values of the datatable. I know that it works as expected with Y axis, but with the x axis it decides doing unhelpful stuff would be better
I set the format and scale on the x axis regularly with out issue.... I would put a break point of the chart.DataBind line and double check your variables before it runs just to make sure.
Unfortunately there is not a whole lot out there about ms chart. I had to learn most of what I know about it by trial and error.
GL
kevin
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers.
A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________
Last edited by kebo : Now. Reason: superfluous typo's
o....
you should look into binding the table to the chart. It make life a bit easier and may be the root of your problem
To bind it set the Series.DataSource.XValueMember and YValueMember properties to the column names of datatable and call the chart.DataBind method...
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers.
A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________
Last edited by kebo : Now. Reason: superfluous typo's
Using databind warps the shape of the graph, because more of the data is in the 2nd half of the data. Look at the first post, i'm trying to recreate the first image, but using data that is already in a table
... are exactly the same command. So, despite your protestations, all things clearly are not equal. When you say the data series are identical, is that actually true? Are they the exact same type, do they have the same precision, do both have the same starting point? If the data points are literally identical then there must be something in the set-up of the chart itself that is not identical in both cases. It simply cannot be the case that using values from a datatable is in itself the cause of the difference.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Yes, they are both identical. When I loop through the table trying to add them to the chart, the chart acts as if it is databound to the table. I don't really know why, but data binding causes all sorts of problems so I'm trying to avoid it. Without being databound, the graph looks like picture #1. When it's looped through the table to add, it behaves as if it is databound, and ruins the axes and the shape of the graph.
I still don't do Data, so I can't explain why the effect you are seeing happens, buuuut.....
When using your DataTable, try casting your data to the appropriate Type:
Code:
For Each row As DataRow In ARpassover_table.Rows
Dim x As Double = CDbl(row.Item(0))
Dim y As Double = CDbl(row.Item(1))
Chart1.Series(0).Points.AddXY(x, y)
Next row
Or maybe create a strongly Typed DataTable:
Code:
ARpassover_table = New DataTable
ARpassover_table.Columns.Add("X", GetType(Double))
ARpassover_table.Columns.Add("Y", GetType(Double))
'
' Fill table with data
'
and:
Code:
For Each row As DataRow In ARpassover_table.Rows
Chart1.Series(0).Points.AddXY(row.Item("X"), row.Item("Y"))
Next row
Maybe databinding to the Chart will work with a strongly Typed DataTable? I don't know; I don't do Data!