How do I modify a color in a stacked bar graph

  • Thread starter Thread starter Helpmesoso
  • Start date Start date
H

Helpmesoso

Guest
I am pulling data from a mainframe into a data table the has Unit Name, Available and Inuse as the 3 items in the table.

Dim tblPackInfo As New DataTable

tblPackInfo.Columns.Add("PackName", GetType(String))
tblPackInfo.Columns.Add("Available", GetType(Integer))
tblPackInfo.Columns.Add("InUse", GetType(Integer))

I can create the graph using the code below

With chrtPackInfo
.Visible = True
.DataSource = tblPackInfo
.Legends.Clear()
.ChartAreas.Clear()
.Legends.Add("InUse")
.Legends.Add("Available")
.Titles.Add("CPMCP2 Space Usage")
.BackColor = Drawing.Color.Azure
.ChartAreas.Add(New ChartArea("Packs"))

With .ChartAreas("Packs")
.AxisY.Maximum = 100
.AxisY.Interval = 10
.AxisY.Minimum = 0
.AxisX.Title = "Pack Units"
.AxisY.Title = "Usage"
.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep90
.AxisX.Interval = 1
.AxisX.TitleFont = New Drawing.Font("arial", 10)
.AxisY.TitleFont = New Drawing.Font("arial", 10)
End With
.Series.Clear()
.Series.Add("InUse")
.Series.Add("Available")

With .Series("InUse")
.LegendText = "In Use Space"
.ChartArea = "Packs"
.ChartType = SeriesChartType.StackedColumn
.XValueType = ChartValueType.String
.XValueMember = "PackName"
.YValueType = ChartValueType.Int32
.YValueMembers = "InUse"
.SmartLabelStyle.Enabled = False
.LabelAngle = -90
.Color = Drawing.Color.Blue
End With
With .Series("Available")
.ChartArea = "Packs"
.LegendText = "Available Space"
.ChartType = SeriesChartType.StackedColumn
.XValueType = ChartValueType.String
.XValueMember = "PackName"
.YValueType = ChartValueType.Int32
.YValueMembers = "Available"
.SmartLabelStyle.Enabled = False
.LabelAngle = -90
.Color = Drawing.Color.Magenta
End With
End With

But now I want to change the color of items that are over 70% inuse to RED. I tried Datapoint and points, but I get no value since I believe the table is bound as a XValuemember and a YValumember. I could get a count looking at the series X or Y value menbers, but I can find no way to change the color if the items that are over the criteria. What is the best way to do this? Should I not bind the datatable and create points instead. I have spent many hours trying to figure this out with no success.

Continue reading...
 
Back
Top