【发布时间】:2011-08-13 22:21:38
【问题描述】:
我正在创建一个 C# Visual Studio 表单应用程序,该应用程序使用 zedgraph 绘制程序收集的数据图表,但在绘制数据时遇到以下问题:
我的 y 轴值通常在 100,000+ 范围内,因此当 zed 图绘制该值时,它会用 0、10、15、20、25 之类的东西标记 y 轴标签,然后在 y 轴上标记它将“(10 ^ 3)”附加到标题并相应地绘制值。我想要做的是让它用 0、10,000、15,000、20,000 等或 0、10k、15k、20k 等值标记 y 轴,而不是让它调整 y 轴标题。
我尝试设置YAxis.Scale.MajorStep = double.Parse("10000");,但唯一的效果是在 y 轴上添加大量刻度线,但没有其他效果。这是我绘制数据的代码:
private void createGraph()
{
GraphPane myPane = zdc_graph.GraphPane;
myPane.CurveList.Clear();
myPane.GraphObjList.Clear();
myPane.Title.Text = this.monitoredHost.hostName + "\nWorkState[" +
this.monitoredHost.currentWorkState + "]";
myPane.XAxis.Title.Text = "";
myPane.YAxis.Title.Text = "OPS Per Second";
myPane.YAxis.Scale.FontSpec.FontColor = Color.Blue;
myPane.YAxis.Title.FontSpec.FontColor = Color.Blue;
myPane.YAxis.Scale.MaxAuto = true;
myPane.Y2Axis.Title.Text = "Reading";
myPane.Y2Axis.IsVisible = true;
myPane.Y2Axis.Scale.FontSpec.FontColor = Color.Red;
myPane.Y2Axis.Title.FontSpec.FontColor = Color.Red;
myPane.XAxis.Type = AxisType.Date;
myPane.XAxis.Scale.Format = "T";
myPane.XAxis.Scale.MajorUnit = DateUnit.Second;
myPane.YAxis.Scale.Min = 0;
myPane.YAxis.Scale.MajorStep = double.Parse("10000");
myPane.Y2Axis.Scale.Min = 0;
LineItem kpiCurve = myPane.AddCurve("OPS Per Second",
this.monitoredHost.graphKpiList,
Color.Blue,SymbolType.Circle);
LineItem pwrCurve = myPane.AddCurve("Reading",
this.monitoredHost.graphPwrList, Color.Red,
SymbolType.Circle);
kpiCurve.Line.Width = 2.0F;
kpiCurve.Symbol.Size = 4.0F;
kpiCurve.Symbol.Fill = new Fill(Color.White);
pwrCurve.Line.Width = 2.0F;
pwrCurve.Symbol.Size = 4.0F;
pwrCurve.Symbol.Fill = new Fill(Color.White);
pwrCurve.IsY2Axis = true;
myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F);
zdc_graph.AxisChange();
zdc_graph.Refresh();
}
我希望这是有道理的。感谢您的帮助。
【问题讨论】:
标签: c# visual-studio zedgraph