af36a64c565449b8d2877a304ca79e85f4a82d62
FAQ/CustomizeGuage.md
| ... | ... | @@ -0,0 +1,137 @@ |
| 1 | +#CustomizeGuage |
|
| 2 | + |
|
| 3 | +##About |
|
| 4 | + |
|
| 5 | +This method allows customization of the gauge that is rendered on reports. Since the gauge image returned is static, this override will not work for animated or interactive gauges. |
|
| 6 | + |
|
| 7 | +##C# Example |
|
| 8 | + |
|
| 9 | +```csharp |
|
| 10 | +public override System.Drawing.Image CustomizeGuage(double value, double min, double max, string name, System.Drawing.Image GuageImage) |
|
| 11 | +{ |
|
| 12 | + int dashboardGaugeWidth = AdHocSettings.DashboardGaugeWidth; |
|
| 13 | + Dundas.Gauges.WebControl.GaugeContainer container = new Dundas.Gauges.WebControl.GaugeContainer(); |
|
| 14 | + container.RenderType = Dundas.Gauges.WebControl.RenderType.BinaryStreaming; |
|
| 15 | + container.Width = AdHocSettings.DashboardGaugeWidth; |
|
| 16 | + container.Height = AdHocSettings.DashboardGaugeWidth; |
|
| 17 | + Dundas.Gauges.WebControl.CircularGauge myCircularGauge = container.CircularGauges.Add("MyCircularGauge"); |
|
| 18 | + myCircularGauge.BackFrame.Image = "custom_gauge.png"; //The static image file for the back of the gauge. This needs to exist in the resources |
|
| 19 | + myCircularGauge.Size.Width = dashboardGaugeWidth / 2; |
|
| 20 | + myCircularGauge.Size.Height = dashboardGaugeWidth / 2; |
|
| 21 | + myCircularGauge.Scales["Default"].Maximum = max; |
|
| 22 | + myCircularGauge.Scales["Default"].Minimum = min < 2 ? 0 : min; |
|
| 23 | + myCircularGauge.Scales["Default"].StartAngle = 45; |
|
| 24 | + myCircularGauge.Scales["Default"].SweepAngle = 270; |
|
| 25 | + myCircularGauge.Pointers["Default"].Value = value; |
|
| 26 | + myCircularGauge.PivotPoint.Y = 50; |
|
| 27 | + myCircularGauge.Pointers[0].Type = Dundas.Gauges.WebControl.CircularPointerType.Needle; |
|
| 28 | + myCircularGauge.Pointers[0].Width = 4; |
|
| 29 | + myCircularGauge.Pointers[0].FillColor = System.Drawing.Color.Black; |
|
| 30 | + myCircularGauge.Pointers[0].FillGradientType = Dundas.Gauges.WebControl.GradientType.None; |
|
| 31 | + myCircularGauge.Pointers[0].NeedleStyle = Dundas.Gauges.WebControl.NeedleStyle.NeedleStyle4; |
|
| 32 | + myCircularGauge.Pointers[0].CapVisible = true; |
|
| 33 | + myCircularGauge.Pointers[0].CapOnTop = true; |
|
| 34 | + myCircularGauge.Pointers[0].CapWidth = 15; |
|
| 35 | + myCircularGauge.Pointers[0].CapStyle = Dundas.Gauges.WebControl.CapStyle.CustomCap1; |
|
| 36 | + myCircularGauge.Pointers[0].CapFillColor = System.Drawing.Color.White; |
|
| 37 | + myCircularGauge.Pointers[0].CapFillGradientEndColor = System.Drawing.Color.FromArgb(255, 106, 121, 131); |
|
| 38 | + myCircularGauge.Pointers[0].CapFillGradientType = Dundas.Gauges.WebControl.GradientType.DiagonalRight; |
|
| 39 | + myCircularGauge.Pointers[0].BorderWidth = 0; |
|
| 40 | + myCircularGauge.Pointers[0].BorderStyle = Dundas.Gauges.WebControl.GaugeDashStyle.NotSet; |
|
| 41 | + myCircularGauge.Pointers[0].ShadowOffset = 0; |
|
| 42 | + myCircularGauge.Pointers[0].Visible = true; |
|
| 43 | + myCircularGauge.BackFrame.FrameStyle = Dundas.Gauges.WebControl.BackFrameStyle.Simple; |
|
| 44 | + myCircularGauge.BackFrame.FrameWidth = 10; |
|
| 45 | + myCircularGauge.BackFrame.BackColor = System.Drawing.Color.White; |
|
| 46 | + myCircularGauge.BackFrame.FrameShape = Dundas.Gauges.WebControl.BackFrameShape.AutoShape; |
|
| 47 | + myCircularGauge.Scales["Default"].Width = 0; |
|
| 48 | + myCircularGauge.Scales["Default"].FillColor = System.Drawing.Color.Transparent; |
|
| 49 | + myCircularGauge.Scales["Default"].FillGradientType = Dundas.Gauges.WebControl.GradientType.None; |
|
| 50 | + myCircularGauge.Scales["Default"].BorderColor = System.Drawing.Color.Transparent; |
|
| 51 | + myCircularGauge.Scales["Default"].BorderStyle = Dundas.Gauges.WebControl.GaugeDashStyle.NotSet; |
|
| 52 | + myCircularGauge.Scales["Default"].MinorTickMark.Visible = false; |
|
| 53 | + myCircularGauge.Scales["Default"].MajorTickMark.Width = 1; |
|
| 54 | + myCircularGauge.Scales["Default"].MajorTickMark.Length = 8; |
|
| 55 | + myCircularGauge.Scales["Default"].MajorTickMark.DistanceFromScale = 4; |
|
| 56 | + myCircularGauge.Scales["Default"].MajorTickMark.Placement = Dundas.Gauges.WebControl.Placement.Outside; |
|
| 57 | + myCircularGauge.Scales["Default"].MajorTickMark.Interval = max / 5; |
|
| 58 | + myCircularGauge.Scales["Default"].MaximumPin.Visible = true; |
|
| 59 | + myCircularGauge.Scales["Default"].LabelStyle.AllowUpsideDown = false; |
|
| 60 | + myCircularGauge.Scales["Default"].LabelStyle.RotateLabels = false; |
|
| 61 | + myCircularGauge.Scales["Default"].LabelStyle.Placement = Dundas.Gauges.WebControl.Placement.Cross; |
|
| 62 | + myCircularGauge.Scales["Default"].LabelStyle.DistanceFromScale = 10; |
|
| 63 | + myCircularGauge.Scales["Default"].LabelStyle.ShowEndLabels = true; |
|
| 64 | + foreach (Dundas.Gauges.WebControl.CircularRange range in myCircularGauge.Ranges) |
|
| 65 | + range.Visible = false; |
|
| 66 | + MemoryStream ms = new MemoryStream(); |
|
| 67 | + container.SaveAsImage(ms); |
|
| 68 | + System.Drawing.Image result = new System.Drawing.Bitmap(ms); |
|
| 69 | + return result; |
|
| 70 | +} |
|
| 71 | +``` |
|
| 72 | + |
|
| 73 | +##VB.NET Example |
|
| 74 | + |
|
| 75 | +```visualbasic |
|
| 76 | +Public Overrides Function CustomizeGuage(value As Double, min As Double, max As Double, name As String, guageImage As Drawing.Image) As Drawing.Image |
|
| 77 | + Dim dashboardGaugeWidth As Integer = AdHocSettings.DashboardGaugeWidth |
|
| 78 | + Dim container As New Dundas.Gauges.WebControl.GaugeContainer() |
|
| 79 | + container.RenderType = Dundas.Gauges.WebControl.RenderType.BinaryStreaming |
|
| 80 | + container.Width = AdHocSettings.DashboardGaugeWidth |
|
| 81 | + container.Height = AdHocSettings.DashboardGaugeWidth |
|
| 82 | + Dim myCircularGauge As Dundas.Gauges.WebControl.CircularGauge = container.CircularGauges.Add("MyCircularGauge") |
|
| 83 | + myCircularGauge.BackFrame.Image = "custom_gauge.png" ' The Static image file For the back Of the gauge. This needs To exist In the resources |
|
| 84 | + myCircularGauge.Size.Width = dashboardGaugeWidth / 2 |
|
| 85 | + myCircularGauge.Size.Height = dashboardGaugeWidth / 2 |
|
| 86 | + myCircularGauge.Scales("Default").Maximum = max |
|
| 87 | + myCircularGauge.Scales("Default").Minimum = min < 2 ? 0 : min |
|
| 88 | + myCircularGauge.Scales("Default").StartAngle = 45 |
|
| 89 | + myCircularGauge.Scales("Default").SweepAngle = 270 |
|
| 90 | + myCircularGauge.Pointers("Default").Value = value |
|
| 91 | + myCircularGauge.PivotPoint.Y = 50 |
|
| 92 | + myCircularGauge.Pointers(0).Type = Dundas.Gauges.WebControl.CircularPointerType.Needle |
|
| 93 | + myCircularGauge.Pointers(0).Width = 4 |
|
| 94 | + myCircularGauge.Pointers(0).FillColor = System.Drawing.Color.Black |
|
| 95 | + myCircularGauge.Pointers(0).FillGradientType = Dundas.Gauges.WebControl.GradientType.None |
|
| 96 | + myCircularGauge.Pointers(0).NeedleStyle = Dundas.Gauges.WebControl.NeedleStyle.NeedleStyle4 |
|
| 97 | + myCircularGauge.Pointers(0).CapVisible = True |
|
| 98 | + myCircularGauge.Pointers(0).CapOnTop = True |
|
| 99 | + myCircularGauge.Pointers(0).CapWidth = 15 |
|
| 100 | + myCircularGauge.Pointers(0).CapStyle = Dundas.Gauges.WebControl.CapStyle.CustomCap1 |
|
| 101 | + myCircularGauge.Pointers(0).CapFillColor = System.Drawing.Color.White |
|
| 102 | + myCircularGauge.Pointers(0).CapFillGradientEndColor = System.Drawing.Color.FromArgb(255, 106, 121, 131) |
|
| 103 | + myCircularGauge.Pointers(0).CapFillGradientType = Dundas.Gauges.WebControl.GradientType.DiagonalRight |
|
| 104 | + myCircularGauge.Pointers(0).BorderWidth = 0 |
|
| 105 | + myCircularGauge.Pointers(0).BorderStyle = Dundas.Gauges.WebControl.GaugeDashStyle.NotSet |
|
| 106 | + myCircularGauge.Pointers(0).ShadowOffset = 0 |
|
| 107 | + myCircularGauge.Pointers(0).Visible = True |
|
| 108 | + myCircularGauge.BackFrame.FrameStyle = Dundas.Gauges.WebControl.BackFrameStyle.Simple |
|
| 109 | + myCircularGauge.BackFrame.FrameWidth = 10 |
|
| 110 | + myCircularGauge.BackFrame.BackColor = System.Drawing.Color.White |
|
| 111 | + myCircularGauge.BackFrame.FrameShape = Dundas.Gauges.WebControl.BackFrameShape.AutoShape |
|
| 112 | + myCircularGauge.Scales("Default").Width = 0 |
|
| 113 | + myCircularGauge.Scales("Default").FillColor = System.Drawing.Color.Transparent |
|
| 114 | + myCircularGauge.Scales("Default").FillGradientType = Dundas.Gauges.WebControl.GradientType.None |
|
| 115 | + myCircularGauge.Scales("Default").BorderColor = System.Drawing.Color.Transparent |
|
| 116 | + myCircularGauge.Scales("Default").BorderStyle = Dundas.Gauges.WebControl.GaugeDashStyle.NotSet |
|
| 117 | + myCircularGauge.Scales("Default").MinorTickMark.Visible = False |
|
| 118 | + myCircularGauge.Scales("Default").MajorTickMark.Width = 1 |
|
| 119 | + myCircularGauge.Scales("Default").MajorTickMark.Length = 8 |
|
| 120 | + myCircularGauge.Scales("Default").MajorTickMark.DistanceFromScale = 4 |
|
| 121 | + myCircularGauge.Scales("Default").MajorTickMark.Placement = Dundas.Gauges.WebControl.Placement.Outside |
|
| 122 | + myCircularGauge.Scales("Default").MajorTickMark.Interval = max / 5 |
|
| 123 | + myCircularGauge.Scales("Default").MaximumPin.Visible = True |
|
| 124 | + myCircularGauge.Scales("Default").LabelStyle.AllowUpsideDown = False |
|
| 125 | + myCircularGauge.Scales("Default").LabelStyle.RotateLabels = False |
|
| 126 | + myCircularGauge.Scales("Default").LabelStyle.Placement = Dundas.Gauges.WebControl.Placement.Cross |
|
| 127 | + myCircularGauge.Scales("Default").LabelStyle.DistanceFromScale = 10 |
|
| 128 | + myCircularGauge.Scales("Default").LabelStyle.ShowEndLabels = True |
|
| 129 | + For Each range As Dundas.Gauges.WebControl.CircularRange In myCircularGauge.Ranges |
|
| 130 | + range.Visible = False |
|
| 131 | + Next |
|
| 132 | + Dim ms As New MemoryStream() |
|
| 133 | + container.SaveAsImage(ms) |
|
| 134 | + Dim result As New System.Drawing.Bitmap(ms) |
|
| 135 | + Return result |
|
| 136 | +End Function |
|
| 137 | +``` |