zoukankan      html  css  js  c++  java
  • ZedGraph如何动态的加载曲线

    ZedGraph的在线文档

    http://zedgraph.sourceforge.net/documentation/default.html

     官网的源代码 http://sourceforge.net/projects/zedgraph/?source=directory

     zedgraph的demo在线范例

     http://zedgraph.sourceforge.net/samples.html

    这里介绍了如何实现动态加载数据,并且提供了demo

    http://goorman.free.fr/ZedGraph/zedgraph.org/wiki/index3061.html?title=Display_Dynamic_or_Real-Time_Data

    The ZedGraphControl can display dynamic or static data. For dynamic displays, each time you want to add data to a graph, you will need to do the following:

    ZedGraph可以显示动态或者静态的数据,对于动态展示,每当你想要把数据加载到graph上的时候,你需要按照以下的步骤来做

    1.Find the CurveItem of interest within the GraphPane.CurveList collection

    第一步,先找到GraphPane.CurveList 中的相关曲线
    2.Access the PointPairList (or other IPointListEdit type) for the CurveItem, and add the new data or modify the existing data as required

    第二步,找到曲线中的PointPairList ,然后根据需要加载新数据或者修改已经存在的数据
    3.Call ZedGraphControl.AxisChange() to update the auto-scaled axis ranges

    第三步,调用ZedGraphControl的AxisChange()函数来更新坐标轴范围的比例
    4.Call Form.Invalidate() to update the graph

    第四步,调用Form.Invalidate() 来更新graph------------[貌似我没有找到这个方法,winform支持?]

    The data points are stored with each CurveItem as a reference to an IPointList interface in CurveItem.Points. Note that this point list reference can be any class that implements IPointList. If it also implements IPointListEdit, thenIPointListEdit.Add() and IPointListEdit.RemoveAt() methods will be available.

    The code sample is for a form that implements a ZedGraphControl with a Timer event to show dynamically updated data. You can download the complete project from the links below:

    ZedGraph控件随机生成曲线的颜色,以及X轴坐标文字竖着显示==========mypane.XAxis.Scale.FontSpec.Angle = 270;//X轴的时间垂直显示

    http://blog.csdn.net/happy09li/article/details/7535388

    ZedGraph使用大全http://www.cnblogs.com/peterzb/archive/2009/07/19/1526726.html

    //zedgraph一些属性的介绍

    http://blog.chinaunix.net/uid-20776117-id-1847015.html

    ZedGraph刷新数据的方法

    zedGraphControl1.AxisChange();//此方法   调整坐标轴的范围

    Invalidate()//使控件的特定区域无效并向控件发送绘制消息。

    //调用 Invalidate 方法并不强制同步绘制;若要强制同步绘制,请在调用 Invalidate 方法之后调用 Update 方法。 在不带参数的情况下调用此方法时,会将整个工作区添加到更新区域。

    zedGraphControl1.Invalidate();
    zedGraphControl1.Update();

    或者

    zedGraphControl1.Refresh();//强制控件使其工作区无效并立即重绘自己和任何子控件。

    //让坐标轴不不显示10^x;[这样做会导致比例尺失调]

    zedGraphControl1.GraphPane.XAxis.Type = AxisType.Log;

    zedGraphControl1.GraphPane.XAxis.Scale.IsUseTenPower = false;

    IsUseTenPower ->> 是否为10次幂表示,scale为LogScale时有效。 The powers-of-ten notation is just the text "10" followed by a superscripted value indicating the magnitude. This mode is only valid for log scales. boolean value; true to show the title as a power of ten, false to show a regular numeric value (e.g., "0.01", "10", "1000")

    zedGraphControl1.GraphPane.XAxis.Title.IsOmitMag

    true to show the magnitude value, false to hide it .   //IsOmitMag为true的时候,显示数量级,为false的时候,不显示
    For large scale values, a "magnitude" value (power of 10) is automatically used for scaling the graph. This magnitude value is automatically appended to the end of the Axis Title (e.g., "(10^4)") to indicate that a magnitude is in use. This property controls whether or not the magnitude is included in the title. Note that it only affects the axis title; a magnitude value may still be used even if it is not shown in the title. 
    对于大数量级,10幂,会自动显示;数量级会自动加载坐标的Title后面,无论IsOmitMag是true还是false;它仅仅是影响Title,数量级还是正常的影响坐标系的。
     
     
    以加载100万数据为例子,说明上面几个的属性
    默认状态下的加载界面
     zedGraphControl1.GraphPane.XAxis.Title.IsOmitMag 此属性默认为false,X轴的标题显示10的幂
    将zedGraphControl1.GraphPane.XAxis.Title.IsOmitMag 设置为true的时候,就不显示10的幂了
     
     
     
    zedGraphControl1.GraphPane.XAxis.Type = AxisType.Log;//横轴按照10的幂为步长//默认横轴是按照10的幂来显示的
     

    zedGraphControl1.GraphPane.XAxis.Type = AxisType.Log;
    zedGraphControl1.GraphPane.XAxis.Scale.IsUseTenPower = false;//横轴不显示成10的幂

    给某一个曲线加载100万点,希望横轴显示100000,200000,300000

    直接设定好,坐标轴

    zedGraphControl1.GraphPane.XAxis.Scale.Max = number;//设定X轴的最大值
    zedGraphControl1.GraphPane.XAxis.Scale.MajorStep = number / 10;//设定最大步长
    zedGraphControl1.GraphPane.XAxis.Scale.MinorStep = number / 10 / 5;//设定最小步长
    zedGraphControl1.GraphPane.XAxis.Scale.FontSpec.Angle = 45;//设定X轴的字体的倾斜度

    注意:一定不要调用zedGraphControl1.AxisChange();否则上面的设置就白设置了,相当于重置了

  • 相关阅读:
    flex 圣杯布局
    .net mvc里AutoMapper更为便捷的使用方法
    使用ClaimsIdentity来实现登录授权
    判断js中数据类型 的最短代码
    输入分钟、秒倒计时
    .net 导出Excel插件Npoi的使用
    seajs简单使用
    图片懒加载
    dropload上拉加载更多
    基于移动端的左滑删除
  • 原文地址:https://www.cnblogs.com/chucklu/p/3829103.html
Copyright © 2011-2022 走看看