Home > Net >  Customise the x-axis ticks and labels for time series data in LINQPad charts
Customise the x-axis ticks and labels for time series data in LINQPad charts

Time:10-04

I've got a simple CSV log file, reading it into a list and charting it is really easy in LINQPad, but I'd like to update the format and the ticks on the x-axis.

Here's my code:

File.ReadAllLines(@"\\...\ModelTimes.csv")
    .Skip(1)
    .Select(line => line.Split(','))
    .Select(data => new
        {
            CurrentTime = DateTime.Parse(data[0]),
            ModelTime = DateTime.Parse(data[1]),
            ModelAgeHours = Decimal.Parse(data[2]),
            CutOff = 2
        })
    .Where(data => data.CurrentTime.Date == new DateTime(2021, 9, 24))
    .Chart(data => data.CurrentTime)
    .AddYSeries(data => data.ModelAgeHours, LINQPad.Util.SeriesType.Line, "Model Age")
    .AddYSeries(data => data.CutOff, LINQPad.Util.SeriesType.Line, "2 Hours")

With the output: sample output for a single day As you can see all I get is the date and not the time on the x-axis. Is there some way I can configure the labels and the frequency of the ticks, to something like: 2021-09-24 10:00 and 1 tick every 2 hours.

CodePudding user response:

Thanks to Chart with customized x-axis format and tooltip

  • Related