Visifire曾经开源,保持使用开源版本是不会有版权问题滴。
引用的命名控件
using Visifire.Charts;
using Visifire.Commons;
一、应用示例主要代码
//实例化一个图表对象
Chart chart = new Chart();
//设置主题
chart.Theme = "Theme4";
//是否3D显示
chart.View3D = true;
//宽
chart.Width = 1000;
//高
chart.Height = 500;
//设置图形标题
Title title = new Title();
title.Text = "肉类数据";
chart.Titles.Add(title);
//设置坐标轴
Axis axisX = new Axis();
axisX.Title = "X轴/肉类";
AxisLabels xal = new AxisLabels
{
Enabled = true,
Angle = -45
};
axisX.AxisLabels = xal;
chart.AxesX.Add(axisX);
Axis axisY = new Axis();
axisY.Title = "Y轴/价格";
AxisLabels yal = new AxisLabels
{
Enabled = true,
Angle = 45
};
axisY.AxisLabels = yal;
chart.AxesY.Add(axisY);
//图形类型 RenderAs是枚举类型 有很多种图形 如棒图 饼图等等
DataSeries dataSeries = new DataSeries();
dataSeries.RenderAs = RenderAs.Column;
DataPoint dataPoint;
double[] data = {100.9,20.9,300.9,400.9,200.9 };
string[] key = {"猪肉","牛肉","鸡肉","羊肉","鱼肉" };
for (int i = 0; i < 5; i++)
{
dataPoint = new DataPoint();
//Y轴数据
dataPoint.YValue = data[i];
//X轴名称
dataPoint.AxisXLabel = key[i];
//设置提示信息
dataPoint.ToolTipText = key[i];
dataSeries.DataPoints.Add(dataPoint);
}
chart.Series.Add(dataSeries);
mainCV.Children.Add(chart); //mainCV为承载图表的一个控件名称,可以是Grid.