Hi Guys,
Does anyone have a clue how to add a few colour ranges to a background of a ultrawebchart, so this colour is applied to a layer below the bars on the chart? i want to add the following to my chart:-
My data ranges from 0 to 100%
Range 1 - (0 to 40%) coloured Red
Range 2 - (40 to 70%) coloured Orange
Range 3 - (70 to 100%) coloured Green.
The closed thing i managed to achieve is to add a box element to the chart but this is draw on a layer above the bar, and altering the colours of the bars depending on there value. Does anyone know if this is even possible?
private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e) { IAdvanceAxis xAxis = e.Grid["X"] as IAdvanceAxis; IAdvanceAxis yAxis = e.Grid["Y"] as IAdvanceAxis; if (xAxis == null || yAxis == null) { return; } int indexOfBorderBox = -1; for (int current = 0; current < e.SceneGraph.Count; current++) { if (e.SceneGraph[current].Path == "Border") { indexOfBorderBox = current; break; } } int yMapRange = (int)Math.Abs(yAxis.MapRange); int redBoxTop = (int)(yAxis.MapMinimum - yMapRange * .4); int orangeBoxTop = (int)(yAxis.MapMinimum - yMapRange * .7); int greenBoxTop = (int)yAxis.MapMaximum; int redBoxHeight = (int)(yAxis.MapMinimum - redBoxTop); int orangeBoxHeight = redBoxTop - orangeBoxTop; int greenBoxHeight = (int)(orangeBoxTop - yAxis.MapMaximum); int xMin = (int)xAxis.MapMinimum; int xMax = (int)xAxis.MapMaximum; int xWidth = xMax - xMin; Box redBox = new Box(new Rectangle(xMin, redBoxTop, xWidth, redBoxHeight)); Box orangeBox = new Box(new Rectangle(xMin, orangeBoxTop, xWidth, orangeBoxHeight)); Box greenBox = new Box(new Rectangle(xMin, greenBoxTop, xWidth, greenBoxHeight)); redBox.PE = new PaintElement(Color.Red); orangeBox.PE = new PaintElement(Color.Orange); greenBox.PE = new PaintElement(Color.Green); e.SceneGraph.Insert(indexOfBorderBox + 1, greenBox); e.SceneGraph.Insert(indexOfBorderBox + 1, orangeBox); e.SceneGraph.Insert(indexOfBorderBox + 1, redBox); }
Thank you very much for your assistance David that worked a treat.
Do you know how i could add these three colours to the legend? so i could add a key for each one:-
Red - High Priority
Orange - Medium Priority
Green - Low Priority
and also include the data source key?