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

Oystein Bjorke 10 ár síðan 0
This discussion was imported from CodePlex

maxambrogi wrote at 2013-04-14 23:26:

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

maxambrogi wrote at 2013-04-28 01:02:

        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);