Profile Picture

X-Axis Date Formatting Question

Posted By Steve Marshall 9 Years Ago
Author
Message
Steve Marshall
Posted 9 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 32, Visits: 50
Excellent - the Custom labels solution was just the ticket!

Thanks,
Steve



Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Yesterday @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Steve,

The problem is that you haven't enabled the X values for the line series:
line.UseXValues = True
and the chart assigns automatic values which start from zero (0, 1, 2 etc.) which explains why you get year 1899 on the labels (this is were OA date zero is).

If you still wish to have categorical labels for the line (in order to have the date displayed for each data point) you can simply add custom labels to the X scale:

  Dim XAxisScale As NOrdinalScaleConfigurator = New NOrdinalScaleConfigurator()
  NChartControl1.Axis(StandardAxis.PrimaryX).ScaleConfigurator = XAxisScale

  XAxisScale.Labels.Add("Label 1")
  XAxisScale.Labels.Add("Label 2")
'etc.

  XAxisScale.AutoLabels = False
  XAxisScale.MajorTickMode = MajorTickMode.CustomStep
  XAxisScale.CustomStep = 1

Hope this helps - let us know if you have any questions or meet any problems.




Best Regards,
Nevron Support Team



Steve Marshall
Question Posted 9 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 32, Visits: 50
Hi,
I have a question regarding the formatting of Date Values on the Primary X Axis of a line chart. The

My X and Y Axes has been configured as per examples (X = Date, Y = Currency) and the code snippet is:

' Configure the X Axis as a Date Scale
Dim XAxisScale As NDateTimeScaleConfigurator = New NDateTimeScaleConfigurator()
LineChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = XAxisScale
With XAxisScale
      .LabelStyle.Angle = New NScaleLabelAngle(ScaleLabelAngleMode.Scale, 270)
      .LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft
      .LabelGenerationMode = LabelGenerationMode.SingleLevel 
     .EnableUnitSensitiveFormatting = False
      .InflateContentRange = False
End With   

 ' Configure the Y Axis as a Numeric Scale    
Dim YAxisScale As NLinearScaleConfigurator = CType(LineChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator, NLinearScaleConfigurator)    
With YAxisScale
      .LabelValueFormatter = New NNumericValueFormatter("£0")
      .MajorGridStyle.LineStyle.Pattern = LinePattern.Dot 
     .MajorGridStyle.SetShowAtWall(ChartWallType.Back, True)
      .InflateContentRange = False    
End With

I then go fetch my data from my database and process the Date/Currency pairs into the chart:

For Each drTwelveWeek As dstQNIData.dtaTwelveWeekRow In dtTwelveWeek.Rows
        With drTwelveWeek
                BudgetData.Values.Add(.BUDGET)
                BudgetData.XValues.Add(.START)
                ActualData.Values.Add(.ACTUAL)
                ActualData.XValues.Add(.START)
        End With      
Next drTwelveWeek

The data all loads fine, and debug shows correct values coming in, but although my dates are in 2015, the values displayed in the labels on the X Axis are from 31/12/1899 onwards.

Also, I have an issue where the X Axis label is only displayed for every 7th "point" on the line whereas I need the date displayed at each tick.

I am sure I am doing something absolutely stupid here, but I have spent so long looking at this now I just am going code-blind. I cannot see what I have missed.

Many thanks,
Steve




Similar Topics


Reading This Topic