滴答之间的Oxyplot距离

时间:2015-11-04 11:38:09

标签: c# wpf oxyplot

如何减少蜱之间的距离?我想更密切地放蜡烛。 我在LinearAxis XAxis中找不到任何响应距离的属性。

enter image description here

代码:

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>

2 个答案:

答案 0 :(得分:2)

尝试缩放:

XAxis.Zoom(-5, 15);

<强>编辑&gt;&GT;&GT;&GT;

你有一个从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);

答案 1 :(得分:0)

尝试使用OFFSET属性:

  1. 如果设置为1,则蜡烛之间将没有空格。
  2. 如果设置为值&gt; 1,然后蜡烛会重叠。
  3. 如果设置为值&lt; 1,然后蜡烛之间会有间隙。价值越小,差距越大。