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线数量每次增加一根,从左向右排列。

posted on 2013-08-08 17:22  dancetime  阅读(521)  评论(0编辑  收藏  举报

导航