Date label (horizontal axis) in Financial Series [Solved]

Apr 14, 2013 at 10:26 PM
Hi, could you kindly share an example where understand how set a date label in the horizontal axis when using financial series?
Thanks in advance.
Best Regards
MaxAmbrogi
Apr 28, 2013 at 12:02 AM
        PlotModel model = new PlotModel("HighLowSeries") { LegendSymbolLength = 24 };

        DateTimeAxis dateAxis = new DateTimeAxis(AxisPosition.Bottom, "Date", "MM/dd") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
        model.Axes.Add(dateAxis);
        LinearAxis valueAxis = new LinearAxis(AxisPosition.Left, 0) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Price" };
        model.Axes.Add(valueAxis);

        DateTime dt = DateTime.Now;

        var s1 = new HighLowSeries("random values")
        {
            Color = OxyColors.Black,
        };
        var r = new Random();
        var price = 100.0;
        for (int x = 0; x < 24; x++)
        {
            price = price + r.NextDouble() + 0.1;
            var high = price + 10 + r.NextDouble() * 10;
            var low = price - (10 + r.NextDouble() * 10);
            var open = low + r.NextDouble() * (high - low);
            var close = low + r.NextDouble() * (high - low);
            s1.Items.Add(new HighLowItem(DateTimeAxis.ToDouble(dt.AddDays(x)), high, low, open, close));
        }
        model.Series.Add(s1);