刻度之间的 Oxyplot 距离

Oxyplot distance between ticks

如何减小刻度之间的距离?我想把蜡烛放得更近一些。 而且我在 LinearAxis XAxis 中找不到任何响应距离的 属性。

代码:

namespace WpfApplication20
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
/// 
public partial class MainWindow : Window
{

    public MainWindow()
    {
        InitializeComponent();
        DataContext = new PlotClass();
    }

}
public class PlotClass
{
    public PlotModel PlotModel { get; set; }
    public PlotClass()
    {
        Random rnd = new Random();
        PlotModel = new PlotModel();
        LineSeries LS = new LineSeries();
        LinearAxis XAxis = new LinearAxis
        {
            Position = AxisPosition.Bottom,
            MinorStep=1,
            MajorStep=1

        };
        LinearAxis YAxis = new LinearAxis()
        {
            Position = AxisPosition.Left
        };
        for (int i=0;i<10;i++)
        {
            LS.Points.Add(new DataPoint(i,rnd.Next(1,10)));
        }
        PlotModel.Axes.Add(YAxis);
        PlotModel.Axes.Add(XAxis);
        PlotModel.Series.Add(LS);
        ChangeToCandles();
        WhatTypeOfSeries();
    }
    public void ChangeToCandles()
    {
        Random rnd = new Random();
        PlotModel.Series.Clear();
        CandleStickSeries CSS = new CandleStickSeries();
        for (int i = 0; i < 10;i++ )
        {
            CSS.Items.Add(new HighLowItem { X = i, Close = rnd.NextDouble(), High = rnd.NextDouble(), Low = rnd.NextDouble(), Open = rnd.NextDouble() });
        }
        PlotModel.Series.Add(CSS);
    }
    public void WhatTypeOfSeries()
    {
        var temp = PlotModel.Series[0].GetType();
        Console.WriteLine(temp);
    }
}
}

xaml:

 <Grid>
    <oxy:Plot Model="{Binding PlotModel}"/>
</Grid>

试着玩 CandleStickSeries.CandleWidth 属性:

  1. 如果设置为1,则蜡烛之间不会有space。
  2. 如果设置为值 > 1,则蜡烛将重叠。
  3. 如果设置为值 < 1,则蜡烛之间会有间隙。值越小,差距越大。

尝试缩放:

XAxis.Zoom(-5, 15);

编辑>>>>

你有一个从 0 到 10 的 for 循环,你只需要添加一些调整值。对于更通用的限制:

int lowerIndex = 0;
int upperIndex = 10;
int zoomValue = 5;

for (int i=lowerIndex;i<upperIndex;i++)
{
    LS.Points.Add(new DataPoint(i,rnd.Next(1,10)));
}

XAxis.Zoom(lowerIndex-zoomValue, upperIndex+zoomValue);