Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Chris
Posted

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

 

Here's 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

Posted

Hmm, haven't 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.

Posted
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.
Chris
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...