• Visifire的一些使用心得


    1.如何让图表的Y轴不从0开始显示:有时一系列的数据差别很小,如果从0开始显示,在Y轴上,会一堆数据都堆在某一个区间。例如期货的蜡烛图。将ViewportRangeEnabled设为true即可解决此问题。代码:

                Axis axis = new Axis();
                axis.ViewportRangeEnabled = true;
                chart.AxesY.Add(axis);

    2.设置图表类型:使用RenderAs属性即可。下面的代码设置成蜡烛图:

                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.CandleStick;

                dataSeries.PriceDownColor = new SolidColorBrush(Colors.Green);
                dataSeries.PriceUpColor = new SolidColorBrush(Colors.Red);

                DataPoint dataPoint = new DataPoint();
                dataPoint.YValues = new Double[] { 10, 20, 25, 5 };

                // Add DataPoint to DataSeries
                dataSeries.DataPoints.Add(dataPoint);

                // Add DataSeries to Chart
                chart.Series.Add(dataSeries);
                // Add chart to the LayoutRoot for display
                LayoutRoot.Children.Add(chart);

    3.实时更新:由于数据绑定了,只需要更新数据源即可:

                    WHDay day = new WHDay();
                    DataPoint dataPoint = new DataPoint();
                    day = (WHDay)_kList[_nIndex];
                    dataPoint.YValues = new Double[] { day.Close, day.Open, day.High, day.Low };
                    chart.Series[0].DataPoints.Add(dataPoint);

    目前还有两个问题没解决:

    1.蜡烛图的颜色:虽然设置了PriceDownColor、PriceUpColor的颜色,可上影线和下影线的颜色并未随着改变,非常奇怪,不知道是不是Visifire本身的Bug。

    2.每次数据出来时,都是显示在中央。例如我只显示一根K线,它也显示在中央。我希望的效果是显示在最左边,然后K线数量每次增加一根,从左向右排列。

  • 相关阅读:
    程序员式的幽默(灌水)
    你应该知道的
    WPF控件应用[0]
    WPF控件应用[2]
    C#调用Win32 的API函数User32.dll
    C#获取当前行号
    C#导入excel重写
    [转]wpf相关好资源
    使用C#和Excel进行报表开发-生成统计图Chart
    [转]用 delphi 创建一个服务程序
  • 原文地址:https://www.cnblogs.com/dancetime/p/3246261.html
Copyright © 2020-2023  润新知