Jump to content
Software FX Community

sain

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by sain

  1. 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) Then

    Chrt.AxisY.Max = maxValue * 1.5

    Else

    Chrt.AxisY.Max = maxValue * 1.25

    End If

    If (minValue > 0) Then

    Chrt.AxisY.Min = minValue * 0.75

    Else

    Chrt.AxisY.Min = minValue * 1.25

    End If

    Chrt.PlotAreaColor = Drawing.Color.FromArgb(255, 255, 255)

    Chrt.AxisY.Grids.Major.Visible =

    True

    Chrt.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 Else

    Chrt.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 color

    Chrt.PageColor = Color.White

    Chrt.AllSeries.Border.Color = Drawing.Color.Black

    Chrt.AllSeries.Border.Effect = ChartFX.WebForms.BorderEffect.Dark

    Chrt.AllSeries.PointLabels.Visible =

    True

    Chrt.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 Then

    y = Math.Ceiling(x)

    Else

    y = Math.Floor(x)

    y = y - 1

    End IfReturn y * 10

    End Function

    Thanks in advance.

  2.  I'm here with sending my source again:

    Source Code for the above graphs

    Public

    Class Sales

    Private _PrdouctName As String

    Private _Sales As Integer

    Public Property ProductName() As String

    GetReturn _PrdouctName

    End GetSet(ByVal value As String)

    _PrdouctName = value

    End Set

    End Property

    Public Property Sales() As Integer

    GetReturn _Sales

    End GetSet(ByVal value As Integer)

    _Sales = value

    End Set

    End PropertyPublic Sub New()

    End SubPublic Sub New(ByVal name As String, ByVal sales As Integer)

    Me._PrdouctName = nameMe._Sales = sales

    End Sub

    End

    Class

    WebPage with button click events:

    Partial Public Class _Default

    Inherits System.Web.UI.PageProtected Sub btnSample1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSample1.Click

    Dim prodsaleslist As New List(Of Sales)prodsaleslist.Add(New Sales("Sony", 10))

    prodsaleslist.Add(

    New Sales("Panasonic", 30))prodsaleslist.Add(New Sales("Vizio", 55))

    prodsaleslist.Add(

    New Sales("Toshiba", 70))Me.Chart1.DataSource = prodsaleslist

    SetChartCommonProperties(Chart1)

    Chart1.Titles.Add(CreateTitle("TV Sales in 2008-2009"))

    End SubProtected Sub btnSample2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSample2.Click

    Dim prodsaleslist As New List(Of Sales)prodsaleslist.Add(New Sales("Honda", 120))

    prodsaleslist.Add(

    New Sales("Accord", 335))prodsaleslist.Add(New Sales("BMW", 459))

    prodsaleslist.Add(

    New Sales("Ford", 198))Me.Chart1.DataSource = prodsaleslist

    SetChartCommonProperties(Chart1)

    Chart1.Titles.Add(CreateTitle("Car Sales Sales in 2008-2009"))

    End SubProtected Sub btnSample3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSample3.Click

    Dim prodsaleslist As New List(Of Sales)prodsaleslist.Add(New Sales("Shell", 1234))

    prodsaleslist.Add(

    New Sales("British Petrolium", 3452))prodsaleslist.Add(New Sales("Exxon Mobile", 2352))

    prodsaleslist.Add(

    New Sales("Texaco", 65432))Me.Chart1.DataSource = prodsaleslist

    SetChartCommonProperties(Chart1)

    Chart1.Titles.Add(CreateTitle("Gas Sales in 2008-2009"))

    End SubPrivate Sub SetChartCommonProperties(ByVal chrt As ChartFX.WebForms.Chart)

    Chart1.Height = 500

    chrt.AxisY.LabelsFormat.Decimals = 1

    chrt.AxisY.DataFormat.Decimals = 1

    chrt.AxisY.LabelsFormat.Format = ChartFX.WebForms.AxisFormat.Percentage

    chrt.AxisY.DataFormat.Format = ChartFX.WebForms.AxisFormat.Percentage

    chrt.AxisY.ScaleUnit = 100

    chrt.AxisY.Step = 10

    chrt.AxisX.Grids.Major.Visible =

    False

    End SubPrivate Function CreateTitle(ByVal title As String) As ChartFX.WebForms.TitleDockableDim newTitle As New ChartFX.WebForms.TitleDockable

    newTitle.Text = title

    newTitle.Font =

    New System.Drawing.Font(newTitle.Font, Drawing.FontStyle.Bold)Return newTitle

    End Function

    End

    Class

     

  3. 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. 

     

     

     

  4. 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

     

     

×
×
  • Create New...