|
-
Nov 19th, 2001, 06:04 AM
#1
Thread Starter
New Member
MSChart, arrrgh! Any help appreciated.
Hi, I hope you can help please.
I have an MSChart control in my project that I use to display a single series of data. I am using a 2D Bar.
I can successfully change the colour of the ALL bars at run-time but I am unable to change a single bar based on some criteria.
All I need to do is change the colour of each bar based on the value of my data.
I have searched all over for some help but all example code is based on multiple series data.
Can anyone help please or i this impossible?
If it is not possible, does anyone know of another control that would allow this?
Many thanks,
Bob
-
Nov 19th, 2001, 07:25 AM
#2
Another frustrated individual trying to get MSChart to work. You said you searched all over. Did you try MSDN? That is the only place I've ever found anything pertienent information concerning this "sterling" control.
-
Nov 19th, 2001, 09:44 AM
#3
Here is some code to change colors:
Code:
Dim x(2, 1) As Integer
x(0, 0) = 1
x(0, 1) = 2
x(1, 0) = 3
x(1, 1) = 2
MSChart1.ChartData = x
'Change background color
With MSChart1.Plot
' Set the style to solid.
.Wall.Brush.Style = VtBrushStyleSolid
' Set the color to yellow.
.Wall.Brush.FillColor.Set 255, 255, 0
End With
'Change the color of the second series of data
With MSChart1.Plot.SeriesCollection(2)
.DataPoints(-1).Brush.FillColor.Set 0, 0, 255
End With
'Change the color of the first series of data
With MSChart1.Plot.SeriesCollection(1)
.DataPoints(-1).Brush.FillColor.Set 255, 255, 255
End With
Hope this helps
-
Nov 21st, 2001, 06:41 AM
#4
Thread Starter
New Member
Thanks but no cigar :)
Thanks for your code Negative0
Trouble is, as I say above, I only have one series of data. Your example works with two series of data.
I wish to change the colour of each bar of that series at runtime.
For example: A chart showing ping rates of an IP address would return values from say 10 - 1000. I show these values on my 2d bar chart in one series, each bar one after another.
One set of data, blue bars for all values below 100 and red for all bars above 100.
Any ideas?
Thanks
Originally posted by Negative0
Here is some code to change colors:
Code:
Dim x(2, 1) As Integer
x(0, 0) = 1
x(0, 1) = 2
x(1, 0) = 3
x(1, 1) = 2
MSChart1.ChartData = x
'Change background color
With MSChart1.Plot
' Set the style to solid.
.Wall.Brush.Style = VtBrushStyleSolid
' Set the color to yellow.
.Wall.Brush.FillColor.Set 255, 255, 0
End With
'Change the color of the second series of data
With MSChart1.Plot.SeriesCollection(2)
.DataPoints(-1).Brush.FillColor.Set 0, 0, 255
End With
'Change the color of the first series of data
With MSChart1.Plot.SeriesCollection(1)
.DataPoints(-1).Brush.FillColor.Set 255, 255, 255
End With
Hope this helps
-
Nov 21st, 2001, 10:43 AM
#5
This is for one series of data:
If this doesnt work give me a better idea of what you are trying to do or maybe some source code
Code:
Dim x(8, 1) As Integer
x(0, 0) = 1
x(1, 0) = 2
x(2, 0) = 3
x(3, 0) = 2
x(4, 0) = 2
x(5, 0) = 4
x(6, 0) = 5
x(7, 0) = 6
x(8, 0) = 7
MSChart1.ChartData = x
'Change background color
With MSChart1.Plot
' Set the style to solid.
.Wall.Brush.Style = VtBrushStyleSolid
' Set the color to green
.Wall.Brush.FillColor.Set 0, 255, 0
End With
'Change the color of the first series of data
With MSChart1.Plot.SeriesCollection(1)
.DataPoints(-1).Brush.FillColor.Set 255, 255, 255
End With
Hope this helps,
I just read your initial post, why dont you just make all of your pieces of data a different series, then you can control the color.
Last edited by Negative0; Nov 21st, 2001 at 10:46 AM.
-
Nov 22nd, 2001, 04:46 AM
#6
Thread Starter
New Member
Thanks again. I am unable to use different series for each data.
To draw each colour as a different series, each of the series is given a space on the chart even if its not been set, this means the chart ends up with too many spaces where there is no values.
e.g 10 series will show space on the chart for each of the ten series when I only want to draw the "bar" for which has a value.
Perhaps I don't understand how to use series data in a bar chart? Am I able to get contiguous data shown on the chart?
I attach an example chart with the sort of results I would like.
The actual chart will show up to 5,000 bars at a time.
As for the actual requirement, the best way to replicate my data is to randomly generate values between 0 and 500. Then dislplay those values in a bar chart, one after another, using different colours for values 0-50, 51-100, 101-200,201-500.
Thankls again.
-
Nov 23rd, 2001, 02:08 PM
#7
Try This:
Code:
Dim x(0 To 0, 1 To 80) As Integer
Dim j As Integer
For j = 1 To 80
x(0, j) = Rnd(Timer) * 500 + 1
Next
MSChart1.ChartData = x
For j = 1 To 80
If x(0, j) > 300 Then
With MSChart1.Plot.SeriesCollection(j)
.DataPoints(-1).Brush.FillColor.Set 0, 0, 255
End With
Else
With MSChart1.Plot.SeriesCollection(j)
.DataPoints(-1).Brush.FillColor.Set 255, 255, 255
End With
End If
Next
Hope this helps
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|