mschart remove default elements

wildfire1982

Well-known member
Joined
Oct 23, 2003
Messages
50
Location
Southampton
Hello,

I have an mschart control on one of my forms and when its loaded it always starts with a default set of values in it. Can someone please tell me how to get rid of this in code. I have tried everything but have no idea where the data is or why i cant get rid of it.

Thanks for your time (vb.net)

Chris
 
Are you saying that you plot your own data and you see your data as well as the default data?

Heres a quick chart example that loads off a grid of 4 labels and 8 textboxes - you should be able to recreate this form pretty easily - I call LoadChart from a button_click event:
Private Sub LoadChart()
Dim Sales(,) As Object = New Object(,) _
{{"Company", "Company A", "Company B"}, _
{Label1.Text, TextBox1.Text, TextBox2.Text}, _
{Label2.Text, TextBox3.Text, TextBox4.Text}, _
{Label3.Text, TextBox5.Text, TextBox6.Text}, _
{Label4.Text, TextBox7.Text, TextBox8.Text}}

chtSales.ChartData = Sales

Add a title
With Me.chtSales
.Title.Text = "Sales"
End With

Add titles to the axes.
With Me.chtSales.Plot
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX).AxisTitle.Text = "Month"
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = "Millions of $"
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX).AxisTitle.Visible = True
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Visible = True
End With


Set custom colors for the bars.
With Me.chtSales.Plot
Yellow for Company A
-1 selects all the datapoints.
.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set(250, 250, 0)

Purple for Company B
.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set(200, 50, 200)
End With

chtSales.AllowSelections = True
chtSales.AllowSeriesSelection = True
End Sub
 
Thanks for that, i have been looking for something like that. Well i would like the graph to be emptied on form load so that the actual points can be plotted later. Any ideas?
 
Hmm, havent tried that one yet.

Are you doing something like my example or using databinding to plot your points? Either way, you could just initialize your chart with some arbitrary values.
 
I havent actually got that far yet, still working with the data but... From the moment i put the control on the form, it had values and was displaying them. Its these that are starting to get annoying. Im still thinking about the best way to store the information for the graph because it will have an unknown number of rows and columns.
 
it makes up about 3 quarters of the page so it might look a little silly, i will work it out but thanks again for the code earlier in the thread!
 
Back
Top