问题
If my graph shows values of 0-100 on x axis, how can I pan x axis to value of 115 from code behind?
回答1:
Since the Maximum Value (assuming Max is 100, from the description is the OP) of your X Axis is already set (at the point when you want to pan from behind), the first step required would be to change the Maximum of the Axis.
var axis = Model.Axes.First(x => x.Position == OxyPlot.Axes.AxisPosition.Bottom);
axis.Maximum = 120;
Model.InvalidatePlot(false);
axis.Pan(115);
Model.InvalidatePlot(false);
Once the Maximum has been reset, you can use Axis.Pan Method to pan to desired point .
In case, Maximum of your X Axis is already more than the desired value, you can skip the first step.
var axis = Model.Axes.First(x => x.Position == OxyPlot.Axes.AxisPosition.Bottom);
axis.Pan(115);
Model.InvalidatePlot(false);
来源:https://stackoverflow.com/questions/53937019/oxyplot-wpf-how-to-pan-to-value-of-x-axis