Chartfield scaling

Posted by: saidnai on 28 April 2022, 8:32 pm EST

  • Posted 28 April 2022, 8:32 pm EST

    Hello,

    I am using a function to create Chart. It works fine. But i could not set scaling for the AxisY. I need to ovoid the decimal as shown in the attached picture. Is there a possibility to get only full numbers (1,2,3,4,5, e.t.c).

    I use the following function:
    Private Function CreateChart1() As ChartField
    Try
    Dim chart = CreateChartField("Chart1", "TmpStatistikEK1")
    chart.Top = 4100
    chart.Left = 400
    chart.Height = 3500
    chart.Width = 4800
    chart.Border.Style = BorderStyle.FixedSingle 'DashStyle.Solid
    'chart.Header.Text = "Reklamation 1"
    chart.ChartArea2D.Inverted = False
    chart.ChartArea2D.AxisX.OnTop = True
    chart.ChartArea2D.AxisX.AnnoRotation = 50
    chart.ChartArea2D.AxisX.Font.Bold = True
    chart.ChartArea2D.AxisX.Visible = True

    chart.ChartArea2D.AxisY.GridMajor.Visible = True
    chart.ChartArea2D.AxisY.Font.Bold = True
    chart.ChartArea2D.AxisY.AutoMax = False
    chart.ChartArea2D.AxisY.AutoMin = False
    chart.ChartArea2D.AxisY.Min = 1 'Scaling Min
    chart.ChartArea2D.AxisY.Max = 1 'Scaling Max

    'TickMajor / TickMinor
    'chart.ChartArea2D.AxisY.TickMajor = 1
    'chart.ChartArea2D.AxisY.TickMinor = 1
    'AutoMin / AutoMax
    'chart.ChartArea2D.AxisY.AutoMin = 1
    'chart.ChartArea2D.AxisY.AutoMax = 1
    'AutoMajor / AutoMinor
    'chart.ChartArea2D.AxisY.AutoMajor = 1
    'chart.ChartArea2D.AxisY.AutoMinor = 1
    'UnitMajor / UnitMinor
    'chart.ChartArea2D.AxisY.UnitMajor = 5
    'chart.ChartArea2D.AxisY.UnitMinor = 5
    'GridMajor / GridMinor
    'chart.ChartArea2D.AxisY.GridMinor.MiterLimit = 10
    'chart.ChartArea2D.AxisY.GridMajor.MiterLimit = 20
    'chart.ChartArea2D.AxisY.GridMinor.Visible = False
    'AutoOrigin
    'chart.ChartArea2D.AxisY.AutoOrigin = 1
    'Origin
    'chart.ChartArea2D.AxisY.Origin = 1
    'Breite der Strich = TickFactorMajor / TickFactorMinor =
    'chart.ChartArea2D.AxisY.TickFactorMajor = 10
    'chart.ChartArea2D.AxisY.TickFactorMinor = 1
    'TickGauge
    'chart.ChartArea2D.AxisY.TickGauge = 1

    chart.Legend.Visible = False 'Die Legende zeigen oder nicht
    'chart.Legend.Location =

    Dim group = chart.ChartGroups2D.Group0
    group.ChartType = C1.Win.FlexReport.Chart.Chart2DType.Bar 'Chart2DType.Bar
    Dim data = group.ChartData
    data.IsForEachRecord = True ' show value of each record in data source
    data.CategoryGroups.AddNewGroup("=TxTWert") ' group by FullName
    data.ColorMode = ChartColorMode.ColorByCategory 'Für Unterschiedliche Fareben

    Dim seriesTemplate = data.SeriesValues.AddNewSeries()
    seriesTemplate.DataValues.AddNewValue("=AnzLieferungen") ' show count in AxisY
    seriesTemplate.LegendEntry = True
    'Show the values
    seriesTemplate.DataLabel.Visible = True
    seriesTemplate.DataLabel.Text = "{#YVAL}"
    'Values display location and fonts
    seriesTemplate.DataLabel.Compass = ChartLabelCompass.North 'i.e. On top of bar
    seriesTemplate.DataLabel.Style.Font.Bold = True
    Return chart

    Catch ex As Exception
    MsgBox("Error 'CreateChart1' :" & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
    End Try
    End Function

    Best regards
    Said
  • Replied 1 May 2022, 7:40 pm EST

    Hi Said,

    Thanks for the code snippet and snapshot.

    You need to set AxisY.UnitMajor=1 to achieve your requirement as(see code snippet)

    chart.ChartArea2D.AxisY.AutoMajor = False
    chart.ChartArea2D.AxisY.UnitMajor = 1


    Please refer the attached sample for the same: FlexChartScale.zip

    Best Regards,
    Nitin
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels