ZedGraph的应用问题

麦田追风 2009-02-13 08:50:03
小弟刚学ZedGraph画图表(折线图)
横坐标是时间,纵坐标是随机数值,已经将折线图画出来了。
现在问题是:
横坐标显示的时间格式是 00:00到59:59(分:秒)
我如何设定横坐标是从00:00:00到23:59:59(时:分:秒),不让它自动变化,只显示当前天的折线图,到第二天刷新图表?
请高人指点,谢谢
...全文
158 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangping_li 2009-02-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 oyds1211 的回复:]
我刚学的时候就看了这网站
他那点是一个一个加进去的
我是想先把直角坐标系画全,然后根据动态横、纵坐标在坐标系上画线
还有横坐标只显示分和秒,怎么不显示小时~~~?[/Quote]
可以自己设定的
参考如下:

private void Form4_Load(object sender, EventArgs e)
{
CreateChart(zedGraphControl1);
}

public void CreateChart(ZedGraphControl zgc)
{
GraphPane myPane = zgc.GraphPane;

// Set the titles and axis labels
myPane.Title.Text = "生产线产量分析图";
//myPane.XAxis.Title.Text = "时间段";
//myPane.YAxis.Title.Text = "Pressure, Psia";
myPane.XAxis.Title.IsVisible = false;
myPane.YAxis.Title.IsVisible = false;
myPane.XAxis.MajorGrid.IsVisible = true; //珊格子
myPane.YAxis.MajorGrid.IsVisible = true;
string[] labels = { "7~8点", "8~9点", "9~10点", "10~11点", "11~12点", "12~13点", "13~14点","14~15点" ,"15~16点","16~17点","17~18点"};
double[] y = { 2000, 1000, 5000, 2500, 3500, 7500,4000,5200};
double[] x = { 4000, 3000, 2500, 3500, 1500, 5500, 2000};
// Hide the legend
myPane.Legend.IsVisible = true;

// Add a curve
LineItem curve = myPane.AddCurve("总产量", null,y, Color.Red, SymbolType.Diamond);
curve.Line.Width = 2.0F;
curve.Line.IsAntiAlias = true;
curve.Symbol.Fill = new Fill(Color.White);
curve.Symbol.Size = 7;
LineItem curve1 = myPane.AddCurve("C线产量", null, x, Color.Blue, SymbolType.Circle);
curve1.Line.Width = 2.0F;
curve1.Line.IsAntiAlias = true;
curve1.Symbol.Fill = new Fill(Color.White);
curve1.Symbol.Size = 7;
// Fill the axis background with a gradient
myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, Color.ForestGreen), 45.0F);

// Offset Y space between point and label
// NOTE: This offset is in Y scale units, so it depends on your actual data
const double offset = 1.0;

// Loop to add text labels to the points
for (int i = 0; i < y.Length; i++)
{
// Get the pointpair
PointPair pt = curve.Points[i];

// Create a text label from the Y data value
TextObj text = new TextObj(pt.Y.ToString("f2"), pt.X, pt.Y + offset,
CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
text.ZOrder = ZOrder.A_InFront;
// Hide the border and the fill
text.FontSpec.Border.IsVisible = false;
text.FontSpec.Fill.IsVisible = false;
//text.FontSpec.Fill = new Fill( Color.FromArgb( 100, Color.White ) );
// Rotate the text to 90 degrees
text.FontSpec.Angle = 50; //字体倾斜度
myPane.GraphObjList.Add(text);
}
for (int i = 0; i < x.Length; i++)
{
// Get the pointpair
PointPair pt = curve1.Points[i];

// Create a text label from the Y data value
TextObj text = new TextObj(pt.Y.ToString("f2"), pt.X, pt.Y + offset,
CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
text.ZOrder = ZOrder.A_InFront;
// Hide the border and the fill
text.FontSpec.Border.IsVisible = false;
text.FontSpec.Fill.IsVisible = false;
//text.FontSpec.Fill = new Fill( Color.FromArgb( 100, Color.White ) );
// Rotate the text to 90 degrees
text.FontSpec.Angle = 50; //数值字体倾斜度
myPane.GraphObjList.Add(text);
}
// Leave some extra space on top for the labels to fit within the chart rect
//myPane.YAxis.Scale.MaxGrace = 0.2;

myPane.XAxis.Type = AxisType.Text;
myPane.XAxis.Scale.TextLabels = labels;
myPane.XAxis.Scale.FontSpec.Size = 8; //x线字体
myPane.XAxis.Scale.FontSpec.Angle = 60;//x线字体倾斜度
// Calculate the Axis Scale Ranges
zgc.AxisChange();
}


yagebu1983 2009-02-14
  • 打赏
  • 举报
回复
没弄过。。。
你可以搜搜。。
麦田追风 2009-02-13
  • 打赏
  • 举报
回复
我刚学的时候就看了这网站
他那点是一个一个加进去的
我是想先把直角坐标系画全,然后根据动态横、纵坐标在坐标系上画线
还有横坐标只显示分和秒,怎么不显示小时~~~?

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧