需要您的建议!
我使用 TickCreationFunc 和 LabelTransformFunc 在 XAxis 上显示时间轴
像这样:
var plotCube = new ILPlotCube(tag, true);
List<Tuple<double, string>> ticks = null;
plotCube.Axes.XAxis.Ticks.TickCreationFunc = (min, max, qty) =>
{
ticks = AxisHelper.CreateUnixDateTicks(min, max, qty).ToList();
return ticks.Select(x => (float)x.Item1).ToList();
};
plotCube.Axes.XAxis.Ticks.LabelTransformFunc = (ind, val) =>
{
if (ticks != null)
return ticks[ind].Item2;
else
return null;
};
plotCube.Axes.XAxis.ScaleLabel.Visible = false; //does not help
结果很好,但是我找不到去除刻度标签的方法
两个问题:
1) VS 显示警告'ILNumerics.Drawing.Plotting.ILTickCollection.TickCreationFunc' is obsolete: '"Use TickCreationFuncEx instead!"。然而 TickCreationFuncEx 从未被调用。
2) 有没有办法告诉 ILNumerics 不要缩写刻度数?
感谢您的帮助!
最佳答案
这个警告很重要。如果您使用新的
TickCreationFuncEx
,刻度标签应该消失.界面非常相似。但是你的函数必须返回IEnumerable<ILTick>
:var plotCube = ilPanel1.Scene.First<ILPlotCube>(); List<Tuple<double, string>> ticks = null; plotCube.Axes.XAxis.Ticks.TickCreationFuncEx = (float min, float max, int qty, ILAxis axis, AxisScale scale) => { ticks = CreateUnixDateTicks(min, max, qty).ToList(); return // return IEnumerable<ILTick> here! }; // you should not need this //plotCube.Axes.XAxis.ScaleLabel.Visible = false;
不能完全禁用缩写。但是您可以指定要显示的位数。直到 4.7(由于错误)你将不得不使用这个:
ilPanel1.SceneSyncRoot.First<ILPlotCube>().Axes.XAxis.Ticks.MaxNumberDigitsShowFull = 10;
从 4.8 版开始,您将不再需要
SceneSyncRoot
可以走得更直:ilPanel1.Scene.First<ILPlotCube>().Axes.XAxis.Ticks.MaxNumberDigitsShowFull = 10; // or in your case just plotcube.Axes.XAxis.Ticks.MaxNumberDigitsShowFull = 10;
注意:在代码中使用了 XAxis 而不是 YAxis acc。以你的例子
关于c# - ILNumerics轴配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29505149/