sain Posted February 24, 2009 Report Share Posted February 24, 2009 Hi All, For the following code, when I apply axisY.ScaleUnit=100 then I 'm loosing all my axisY labels and gridlines. Any idea? Chrt.AxisY.LabelsFormat.CustomFormat = "00.0%" Chrt.AxisY.DataFormat.Decimals = 1 Chrt.AxisY.DataFormat.Format = ChartFX.WebForms.AxisFormat.Percentage Quote Link to comment Share on other sites More sharing options...
rogelioB Posted February 27, 2009 Report Share Posted February 27, 2009 Hi, It seems you trying to do a percentage Y-Axis, so please use the following lines of code in order to accomplish this behavior: chart1.AxisY.ScaleUnit = 100; chart1.AxisY.LabelsFormat.Decimals = 1; chart1.AxisY.Step = 10; chart1.AxisY.LabelsFormat.CustomFormat = "00.0%"; Regards RB Quote Link to comment Share on other sites More sharing options...
sain Posted March 4, 2009 Author Report Share Posted March 4, 2009 Thanks for your reply. If I assign the Step=10 then it works fine for me. But, in my application I'm setting AxisY min and max values programatically. Some times the AxisY min value is 0 and Max value 1, in this case I don't see Labels on axisY except Zero. My question is can we able to get % and one decimal on AxisY labels without setting Step value? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
rogelioB Posted March 5, 2009 Report Share Posted March 5, 2009 If you do not set the step, Chart FX will calculate it according to your data; if you want to have a specific steps and labels like %, I recommend you to set a step. WPFchartTest1.zip Quote Link to comment Share on other sites More sharing options...
sain Posted March 5, 2009 Author Report Share Posted March 5, 2009 If I assign the step value some times the graphs are looks crazy. In my app there are 100 graphs and data is coming from different sources. I'm calculating Step value as shown below, my users are not satisfied the way graph looks. Public Shared Sub Chart_CommonProperties(ByRef Chrt As ChartFX.WebForms.Chart, ByVal maxValue As Double, ByVal minValue As Double)Chrt.AxisY.LabelsFormat.Decimals = 1 Chrt.AxisY.LabelsFormat.CustomFormat = "#0.0%"Chrt.AxisY.DataFormat.Decimals = 1 Chrt.AxisY.DataFormat.Format = ChartFX.WebForms.AxisFormat.Percentage If (maxValue > 0) ThenChrt.AxisY.Max = maxValue * 1.5 ElseChrt.AxisY.Max = maxValue * 1.25 End If If (minValue > 0) ThenChrt.AxisY.Min = minValue * 0.75 ElseChrt.AxisY.Min = minValue * 1.25 End IfChrt.PlotAreaColor = Drawing.Color.FromArgb(255, 255, 255) Chrt.AxisY.Grids.Major.Visible = TrueChrt.AxisX.Grids.Major.TickMark = ChartFX.WebForms.TickMark.Outside Chrt.AxisX.Grids.Major.Style = Drawing2D.DashStyle.Solid Chrt.AxisX.Grids.Major.Width = 1 Chrt.AxisX.Grids.Major.Color = Drawing.SystemColors.ControlDark Chrt.AxisX.Grids.Major.Visible = FalseChrt.AxisY.Grids.Major.Style = Drawing2D.DashStyle.Solid Chrt.AxisY.LabelValue = 1 Chrt.AxisY.ScaleUnit = 100 Chrt.AxisY.Grids.Major.Color = Drawing.SystemColors.ControlDark 'Chrt.AxisY.Step = 10 If Chrt.AxisY.Max - Chrt.AxisY.Min > 0 ThenDim stepvalue As Integer = Math.Round((Chrt.AxisY.Max - Chrt.AxisY.Min)) Select Case stepvalueCase 0 Chrt.AxisY.Step = 0.1 Case 1 Chrt.AxisY.Step = 0.1 Case 2 Chrt.AxisY.Step = 0.2 Case 3 Chrt.AxisY.Step = 0.3 Case 4 Chrt.AxisY.Step = 0.4 Case 5 Chrt.AxisY.Step = 0.5 Case 6 Chrt.AxisY.Step = 0.6 Case 7 Chrt.AxisY.Step = 0.7 Case 8 Chrt.AxisY.Step = 0.8 Case 9 Chrt.AxisY.Step = 1 Case 10 Chrt.AxisY.Step = 1.5 Case ElseChrt.AxisY.Step = DetermineNextWholeTen((Chrt.AxisY.Max - Chrt.AxisY.Min) / 10) End Select End If ''setting the charts varios properties like border, point label formats and graph colorChrt.PageColor = Color.White Chrt.AllSeries.Border.Color = Drawing.Color.Black Chrt.AllSeries.Border.Effect = ChartFX.WebForms.BorderEffect.Dark Chrt.AllSeries.PointLabels.Visible = TrueChrt.AllSeries.PointLabels.Angle = ERTSCONSTANTS.CHART_VALUES.POINT_LABEL_ANGLE_360 Chrt.AllSeries.Color = Drawing.Color.Black Chrt.AllSeries.MarkerSize = 3 Chrt.AllSeries.MarkerShape = ChartFX.WebForms.MarkerShape.Rect Chrt.AllSeries.Line.Width = 1 End Sub Private Shared Function DetermineNextWholeTen(ByVal value As Decimal) As DoubleDim x As Decimal = value / 10 Dim y As Integer If x > 0 Theny = Math.Ceiling(x) Elsey = Math.Floor(x) y = y - 1 End IfReturn y * 10 End FunctionThanks in advance. 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.