我想制作在更换轴后不会缩放尺寸的矩形。 更改X和Y最小或最大值后,OxyPlot缩放矩形。 我不知道X和Y轴的“新”最小值和最大值。这是简单的方法吗?
File path Existence
C:\Users\Desktop\Excel\Jan15.txt 1
C:\Users\Desktop\Excel\Feb15.txt 1
C:\Users\Desktop\Excel\Mar15.txt 1
C:\Users\Desktop\Excel\Apr15.txt 0
C:\Users\Desktop\Excel\May15.txt 0
Xaml看起来像这样
using GalaSoft.MvvmLight.Command;
using OxyPlot;
using OxyPlot.Annotations;
using OxyPlot.Axes;
using OxyPlot.Series;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication22
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new PlotRectangle();
}
}
public class PlotRectangle
{
public ICommand ComboCommand { get; set; }
public PlotModel PlotModel { get; set; }
public LinearAxis XAxis { get; set; }
public LinearAxis YAxis { get; set; }
public LineSeries LineSeries { get; set; }
public RectangleAnnotation Rect {get;set;}
public List<string> Items { get; set; }
public PlotRectangle()
{
ComboCommand = new RelayCommand(()=>ChangeAxis());
PlotModel = new PlotModel();
Rect = new RectangleAnnotation();
LineSeries = new LineSeries();
Items = new List<string>();
Items.Add("5");
Items.Add("10");
Items.Add("15");
Rect.MinimumX = 10;
Rect.MaximumX = 20;
Rect.MinimumY = 1;
Rect.MaximumY = 10;
XAxis = new LinearAxis
{
Position=AxisPosition.Bottom,
};
YAxis = new LinearAxis
{
Position = AxisPosition.Left
};
PlotModel.Axes.Add(XAxis);
PlotModel.Axes.Add(YAxis);
PlotModel.Series.Add(LineSeries);
PlotModel.Annotations.Add(Rect);
}
public void ChangeAxis()
{
Random rnd1 = new Random();
Random rnd2 = new Random();
Random rnd3 = new Random();
Random rnd4 = new Random();
PlotModel.Axes[1] = new LinearAxis
{
Minimum=rnd1.Next(1,10),
Maximum=rnd2.Next(15,50)
};
PlotModel.Axes[0] = new LinearAxis
{
Minimum = rnd3.Next(1, 10),
Maximum = rnd4.Next(15, 50)
};
PlotModel.InvalidatePlot(true);
}
}
}
我需要在屏幕上绘图,但是如何?