NCH Posted July 10, 2008 Report Share Posted July 10, 2008 Hi, I've a problem with UserLegendBox in the example in Chart FX ressource Center. (see code below) When I execute the code, each points in my chart have the same color except if I highlight one of them. Normally i must have directly a different color I try this in Access 2003 and VB6. I have always the same work. Sorry for my English :s Could you help me ? Thanks Chris code : Chart1.UserLegendBox = True Dim userLegendBoxItem as Object Set userLegendBoxItem = Chart1.UserLegendBoxObj.Item(0) userLegendBoxItem.Label = "Warning" userLegendBoxItem.Color = RGB(255,0,0) userLegendBoxItem.MarkerShape = MarkerShape_Rect userLegendBoxItem.BorderEffect = BorderEffect_None userLegendBoxItem.BorderColor = RGB(0,0,0) Set userLegendBoxItem = Chart1.UserLegendBoxObj.Item(1) userLegendBoxItem.Label = "Caution" userLegendBoxItem.Color = RGB(255,255,0) userLegendBoxItem.MarkerShape = MarkerShape_Rect userLegendBoxItem.BorderEffect = BorderEffect_None userLegendBoxItem.BorderColor = RGB(0,0,0) Set userLegendBoxItem = Chart1.UserLegendBoxObj.Item(2) userLegendBoxItem.Label = "Normal" userLegendBoxItem.Color = RGB(0,128,0) userLegendBoxItem.MarkerShape = MarkerShape_Rect userLegendBoxItem.BorderEffect = BorderEffect_None userLegendBoxItem.BorderColor = RGB(0,0,0) Dim j as Integer j = 0 Dim redPoint as PointAttributes Set redPoint = New PointAttributes Dim greenPoint as PointAttributes Set greenPoint = New PointAttributes Dim yellowPoint as PointAttributes Set yellowPoint = New PointAttributes redPoint.Color = RGB(255,0,0) greenPoint.Color = RGB(0,128,0) yellowPoint.Color = RGB(255,255,0) Chart1.OpenData COD_Values, 1, 5 For j = 0 To 4 Chart1.Value(0, j) = (Rnd()) * 100 If ((Chart1.Value(0, j)) > 70) Then Chart1.Point(0, j) = redPoint Else If ((Chart1.Value(0, j)) > 40) And ((Chart1.Value(0, j)) < 70) Then Chart1.Point(0, j) = yellowPoint Else Chart1.Point(0, j) = greenPoint End If End If Next Chart1.CloseData COD_Values Chart1.BorderEffect = BorderEffect_None Chart1.BorderColor = RGB(0,0,0) Chart1.SmoothFlags = Chart1.SmoothFlags And SmoothFlags_Text Chart1.AxisY.LabelsFormat.Decimals = 0 Dim constantLine as Object Set constantLine = Chart1.ConstantLines(0) constantLine.Axis = AxisItem_Y constantLine.Value = 40 constantLine.Color = RGB(255,255,0) constantLine.Flags = constantLine.Flags Or ConstantFlag_BackOnly constantLine.Width = 3 Set constantLine = Chart1.ConstantLines(1) constantLine.Axis = AxisItem_Y constantLine.Value = 70 constantLine.Color = RGB(255,0,0) constantLine.Flags = constantLine.Flags Or ConstantFlag_BackOnly constantLine.Width = 3 Chart1.AxisX.Label(0) = "Mon" Chart1.AxisX.Label(1) = "Tue" Chart1.AxisX.Label(2) = "Wed" Chart1.AxisX.Label(3) = "Thu" Chart1.AxisX.Label(4) = "Fri" Quote Link to comment Share on other sites More sharing options...
VekiPeki Posted July 10, 2008 Report Share Posted July 10, 2008 You should not overwrite actual Point object with your own, rather just change their properties, i.e. try to change this: redPoint.Color = RGB(255,0,0)...Chart1.Point(0,j) = redPoint to this: redColor = RGB(255,0,0)...Chart1.Point(0,j).Color = redColor (for all lines where you assign colors) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.