Visifire图表
引用DLL:
WPFToolkit
WPFVisifire.Charts.dll
WPFVisifire.Gauges.dll
1、柱状图
代码:
public void BindChart1()
{
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
try
{
List<string> colorList = new List<string>();
List<string> fjList = new List<string>(); ;
List<double> qyonList = new List<double>();
List<double> qyoutList = new List<double>();
int outNum = ;
int onNum = ;
int totalNum = ;
string errMsg = string.Empty;
bool result = false; result = HI.Get<ICameraService>().GetCameraOnline(out colorList, out fjList, out qyonList, out qyoutList, out outNum, out onNum, out totalNum, out errMsg); Dispatcher.Invoke(new Action(() =>
{
txtOnlineCamera.Text = onNum.ToString();
txtOutlineCamera.Text = outNum.ToString();
txtTotalCamera.Text = totalNum.ToString(); Chart chart = new Chart(); #region 样式
//样式
chart.ThemeEnabled = true;
chart.Theme = "Theme2";
chart.BorderThickness = new Thickness();
chart.Background = new SolidColorBrush(Colors.Transparent);
chart.ShadowEnabled = false;
chart.View3D = false;
chart.AnimationEnabled = false; PlotArea pa = new PlotArea();
pa.Background = new SolidColorBrush(Colors.Transparent);
pa.ShadowEnabled = false;
pa.BorderThickness = new Thickness();
chart.PlotArea = pa;
#endregion //绑定Chart
chart.Series.Clear();
chart.Titles.Clear(); chart.Width = this.chart1Grid.Width - ;
chart.Height = this.chart1Grid.Height - ; DataSeries dataSeries = new DataSeries();
DataPoint datapoint = null; #region 颜色
SolidColorBrush[] brushArr = new SolidColorBrush[];
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
#endregion #region 数据
for (int i = ; i < fjList.Count; i++)
{
int colorIndex = i % brushArr.Length;
datapoint = new DataPoint();
datapoint.AxisXLabel = fjList[i];
datapoint.YValue = qyonList[i];
datapoint.Color = brushArr[colorIndex];
datapoint.Tag = fjList[i];
datapoint.LabelEnabled = true;
datapoint.LabelStyle = LabelStyles.Inside;
datapoint.LabelFontColor = new SolidColorBrush(Colors.White);
//datapoint.MouseLeftButtonDown += new MouseButtonEventHandler(datapoint_MouseLeftButtonDown); //DataPoint被点击执行事件
dataSeries.DataPoints.Add(datapoint);
}
#endregion //绑定当鼠标放上去显示的信息
chart.Series.Add(dataSeries); #region 图表标题
//图表标题
Title title = new Title();
title.Text = "摄像头在线率";
title.FontColor = new SolidColorBrush(Colors.White);
chart.Titles.Add(title);
#endregion #region 坐标样式
AxisLabels yLabel = new AxisLabels();
yLabel.FontColor = new SolidColorBrush(Colors.White); //y轴刻度文本信息颜色 ChartGrid yGrid = new ChartGrid();// 设置y轴的横向刻度虚线
yGrid.Enabled = true;
yGrid.LineColor = new SolidColorBrush(Colors.White); Axis yAxis = new Axis();
yAxis.Enabled = true; //是否显示Y轴刻度、文本
yAxis.Grids.Add(yGrid);
yAxis.AxisMinimum = ; //y轴刻度最小值
yAxis.AxisMaximum = ; //y轴刻度最大值
yAxis.Suffix = "%"; //"给刻度添加后缀 如%";
yAxis.Interval = ; //设置y轴刻度的增量 -- 即2个刻度值之间的的间隔
yAxis.IntervalType = IntervalTypes.Number;
yAxis.AxisLabels = yLabel;
chart.AxesY.Add(yAxis); AxisLabels xLabel = new AxisLabels();
xLabel.FontColor = new SolidColorBrush(Colors.White); //x轴刻度文本信息颜色 ChartGrid xGrid = new ChartGrid();//设置x轴的纵向刻度虚线
xGrid.Enabled = false; Axis xAxis = new Axis();
xAxis.Enabled = true; //是否显示X轴刻度、文本
xAxis.AxisLabels = xLabel;
xAxis.Grids.Add(xGrid); chart.AxesX.Add(xAxis);
#endregion this.chart1Grid.Children.Clear();
this.chart1Grid.Children.Add(chart);
}));
}
catch
{ }
});
}
效果图:
2、堆积柱状图
代码:
public void PartolTaskChart()
{
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
try
{
#region 数据
List<Dictionary<string, int>> lsDic = HI.Get<SunCreate.CombatPlatform.Contract.IVideoPatrol>().GetTackRecordAnalysisMainPage(DateTime.Now.AddYears(-), DateTime.Now.AddDays(), "");
#endregion Dispatcher.Invoke(new Action(() =>
{
Chart chart = new Chart(); #region 样式
//样式
chart.ThemeEnabled = true;
chart.Theme = "Theme2";
chart.Background = new SolidColorBrush(Colors.Transparent);
chart.BorderThickness = new Thickness();
chart.AnimationEnabled = false;
chart.View3D = false; PlotArea pa = new PlotArea();
pa.Background = new SolidColorBrush(Colors.Transparent);
pa.ShadowEnabled = false;
pa.BorderThickness = new Thickness();
chart.PlotArea = pa;
#endregion #region 颜色
SolidColorBrush[] brushArr = new SolidColorBrush[];
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
brushArr[] = new SolidColorBrush(Color.FromRgb(, , ));
#endregion #region 数据
#region 巡查次数
DataSeries dataSeries = new DataSeries();
dataSeries.RenderAs = RenderAs.StackedColumn;
dataSeries.ShowInLegend = false;
dataSeries.Color = brushArr[]; foreach (string key in lsDic[].Keys)
{
//设置点
int val = lsDic[][key];
DataPoint point = new DataPoint();
point.ToolTipText = "巡查次数:" + val;
point.YValue = val;
point.AxisXLabel = key.Replace("合肥市公安局", string.Empty);
point.Tag = key.Replace("合肥市公安局", string.Empty);
dataSeries.DataPoints.Add(point);
} chart.Series.Add(dataSeries);
#endregion #region 截图张数
dataSeries = new DataSeries();
dataSeries.RenderAs = RenderAs.StackedColumn;
dataSeries.ShowInLegend = false;
dataSeries.Color = brushArr[]; foreach (string key in lsDic[].Keys)
{
//设置点
int val = lsDic[][key];
DataPoint point = new DataPoint();
point.ToolTipText = "截图张数:" + val;
point.YValue = val;
point.AxisXLabel = key.Replace("合肥市公安局", string.Empty);
point.Tag = key.Replace("合肥市公安局", string.Empty);
dataSeries.DataPoints.Add(point);
} chart.Series.Add(dataSeries);
#endregion #region 价值图片
dataSeries = new DataSeries();
dataSeries.RenderAs = RenderAs.StackedColumn;
dataSeries.ShowInLegend = false;
dataSeries.Color = brushArr[]; foreach (string key in lsDic[].Keys)
{
//设置点
int val = lsDic[][key];
DataPoint point = new DataPoint();
point.ToolTipText = "价值图片:" + val;
point.YValue = val;
point.AxisXLabel = key.Replace("合肥市公安局", string.Empty);
point.Tag = key.Replace("合肥市公安局", string.Empty);
dataSeries.DataPoints.Add(point);
} chart.Series.Add(dataSeries);
#endregion
#endregion #region 图表标题
//图表标题
Title title = new Title();
title.Text = "巡查执行情况";
title.FontColor = new SolidColorBrush(Colors.White);
chart.Titles.Add(title);
#endregion #region 坐标样式
AxisLabels yLabel = new AxisLabels();
yLabel.FontColor = new SolidColorBrush(Colors.White); //y轴刻度文本信息颜色 ChartGrid yGrid = new ChartGrid();// 设置y轴的横向刻度虚线
yGrid.Enabled = true;
yGrid.LineColor = new SolidColorBrush(Colors.White); Axis yAxis = new Axis();
yAxis.Enabled = true; //是否显示Y轴刻度、文本
yAxis.Grids.Add(yGrid);
yAxis.AxisMinimum = ; //y轴刻度最小值
//yAxis.AxisMaximum = 100; //y轴刻度最大值
//yAxis.Suffix = "%"; //"给刻度添加后缀 如%";
//yAxis.Interval = 20; //设置y轴刻度的增量 -- 即2个刻度值之间的的间隔
yAxis.IntervalType = IntervalTypes.Number;
yAxis.AxisLabels = yLabel;
chart.AxesY.Add(yAxis); AxisLabels xLabel = new AxisLabels();
xLabel.FontColor = new SolidColorBrush(Colors.White); //x轴刻度文本信息颜色 ChartGrid xGrid = new ChartGrid();//设置x轴的纵向刻度虚线
xGrid.Enabled = false; Axis xAxis = new Axis();
xAxis.Enabled = true; //是否显示X轴刻度、文本
xAxis.AxisLabels = xLabel;
xAxis.Grids.Add(xGrid); chart.AxesX.Add(xAxis);
#endregion this.gridPartolTaskChart.Children.Clear();
this.gridPartolTaskChart.Children.Add(chart);
}));
}
catch
{ }
});
}
效果图:
3、雷达图
代码:
public void ShowRadar()
{
try
{
Chart chart = new Chart(); //样式
chart.ThemeEnabled = true;
chart.Theme = "Theme2";
chart.Background = new SolidColorBrush(Colors.Transparent);
chart.BorderThickness = new Thickness(); PlotArea pa = new PlotArea();
pa.Background = new SolidColorBrush(Colors.Transparent);
pa.ShadowEnabled = false;
pa.BorderThickness = new Thickness();
chart.PlotArea = pa; #region 颜色
SolidColorBrush[] brushArr = new SolidColorBrush[];
brushArr[] = new SolidColorBrush(Color.FromArgb(, , , ));
brushArr[] = new SolidColorBrush(Color.FromArgb(, , , ));
brushArr[] = new SolidColorBrush(Color.FromArgb(, , , ));
brushArr[] = new SolidColorBrush(Color.FromArgb(, , , ));
brushArr[] = new SolidColorBrush(Color.FromArgb(, , , ));
brushArr[] = new SolidColorBrush(Color.FromArgb(, , , ));
brushArr[] = new SolidColorBrush(Color.FromArgb(, , , ));
brushArr[] = new SolidColorBrush(Color.FromArgb(, , , ));
#endregion #region 数据
//设置类型为雷达图
DataSeries dataSeries = new DataSeries();
dataSeries.RenderAs = RenderAs.Radar;
dataSeries.ShowInLegend = false;
dataSeries.Color = brushArr[]; //设置点
DataPoint point = new DataPoint();
point.YValue = ;
point.AxisXLabel = "高新分局";
point.Tag = "高新分局";
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
point.AxisXLabel = "包河分局";
point.Tag = "包河分局";
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
point.AxisXLabel = "新站分局";
point.Tag = "新站分局";
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
point.AxisXLabel = "经开分局";
point.Tag = "经开分局";
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
point.AxisXLabel = "蜀山分局";
point.Tag = "蜀山分局";
dataSeries.DataPoints.Add(point); chart.Series.Add(dataSeries);
#endregion #region 数据
//设置类型为雷达图
dataSeries = new DataSeries();
dataSeries.RenderAs = RenderAs.Radar;
dataSeries.ShowInLegend = false;
dataSeries.Color = brushArr[]; //设置点
point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); chart.Series.Add(dataSeries);
#endregion #region 数据
//设置类型为雷达图
dataSeries = new DataSeries();
dataSeries.RenderAs = RenderAs.Radar;
dataSeries.ShowInLegend = false;
dataSeries.Color = brushArr[]; //设置点
point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); point = new DataPoint();
point.YValue = ;
dataSeries.DataPoints.Add(point); chart.Series.Add(dataSeries);
#endregion AxisLabels yLabel = new AxisLabels();
yLabel.FontColor = new SolidColorBrush(Colors.Transparent); //y轴刻度文本信息颜色 ChartGrid yGrid = new ChartGrid();// 设置y轴的横向刻度虚线
yGrid.Enabled = true;
yGrid.LineColor = new SolidColorBrush(Colors.White); Axis yAxis = new Axis();
yAxis.Enabled = true; //是否显示Y轴刻度、文本
yAxis.Grids.Add(yGrid);
yAxis.AxisMinimum = ; //y轴刻度最小值
yAxis.AxisMaximum = ; //y轴刻度最大值
//yAxis.Suffix = "%"; //"给刻度添加后缀 如%";
yAxis.Interval = ; //设置y轴刻度的增量 -- 即2个刻度值之间的的间隔
yAxis.IntervalType = IntervalTypes.Number;
yAxis.AxisLabels = yLabel;
chart.AxesY.Add(yAxis); AxisLabels xLabel = new AxisLabels();
xLabel.FontColor = new SolidColorBrush(Colors.White); //x轴刻度文本信息颜色
xLabel.Background = new SolidColorBrush(Colors.Transparent); ChartGrid xGrid = new ChartGrid();//设置x轴的纵向刻度虚线
xGrid.Enabled = false; Axis xAxis = new Axis();
xAxis.Enabled = true; //是否显示X轴刻度、文本
xAxis.AxisLabels = xLabel;
xAxis.Grids.Add(xGrid); chart.AxesX.Add(xAxis); this.radarGrid.Children.Add(chart);
}
catch { }
}
效果图:
补充:
datapoint.LightingEnabled = false; // 照明功能
datapoint.SnapsToDevicePixels = true; // 像素对齐
Visifire图表的更多相关文章
- WPF Visifire 图表控件
Visifire WPF 图表控件 破解 可能用WPF生成过图表的开发人员都知道,WPF虽然本身的绘图能力强大,但如果每种图表都自己去实现一次的话可能工作量就大了, 尤其是在开发时间比较紧的情况下.这 ...
- visifire 图表双坐标轴 silverlight
public void CreateChart(Grid oGrid, ObservableCollection<ListItem> lBaseOilBar) { ...
- visifire 图表属性样式设置说明,字体,阴影设置
- asp.net中绘制大数据量的可交互的图表
在一个asp.net项目中要用到能绘制大数据量信息的图表,并且是可交互的(放大.缩小.导出.打印.实时数据),能够绘制多种图形. 为此进行了多方调查预研工作,预研过微软的MsChart图表组件.基于j ...
- 一个WPF小项目小结
一:缘起 老板有做PC桌面客户端的需求,做的是能耗的计算和评估,要算能耗,就有很多环节,最后对这些环节数据进行一些简单计算.我想要是做的话就用比较熟的wpf,就去聊了下,对方给了1张比较复杂的Exce ...
- silverlight visifire控件图表制作——silverlight 后台方法页面事件
1.返回事件 (1.返回silverlight页面,2.返回web页面) private void button_ClickBack(object sender, RoutedEventArgs e) ...
- silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs
一.构造方法ControlChart 1.前台页面控件赋值 //时间下拉框赋值,下拉框赋选定值 for (int ii = DateTime.Today.Year; ii ...
- 使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示
原文:使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示 首先来看一看实现的效果: PS:原始的程序中更新曲线数据时添加了过渡的效果,具体可 ...
- Silverlight 图表控件 Visifire 常用属性
主要介绍 Visifire 常用属性的设置,用来生成不同样式的图例 设置Chart的属 //设置title的值 // 创建一个标题的对象 Title title = new Title(); // 设 ...
随机推荐
- fiddler工具条、状态栏、请求信息栏各按钮的作用
1.fiddler工具条 2.fiddler状态栏 3.请求信息栏
- IPv4正则表达式匹配
IP地址的长度为32位,分为4段,每段8位.用十进制数字表示,每段数字范围为0~255,段与段之间用英文句点“.”隔开.例如:某台计算机IP地址为111.22.33.4. 分析IP地址的组成特点:25 ...
- java的方法传参,最容易混淆的问题!!!
参数传递 参数传递,可以理解当我们要调用一个方法时,我们会把指定的数值,传递给方法中的参数,这样方法中的参数就拥有了这个指定的值,可以使用该值,在方法中运算了.这种传递方式,我们称为参数传递. 在这里 ...
- css常用属性总结:文本属性中的text-indent
在网页中的文本格式中最重要的效果之一就是段落的首行文本缩进,尤其在新闻类页面,使用text-indent,任何元素都可以让首行以给定的长度缩进, 长度甚至可以是负数,这一属性的最常用方式就是段落的首行 ...
- java web作用域page request session application
转载自:http://blog.csdn.net/wyd458549392147/article/details/6944481 1.page指当前页面.只在一个jsp页面里有效 . 2.reques ...
- qemu模拟器下编译运行基于riscv指令集的Linux操作系统
基本原理: 在物理服务器Ubuntu14.04上安装qemu模拟器,模拟器中运行基于riscv指令集编译的linux镜像文件. 用到的工具包括: riscv-qemu(模拟器,可以模拟运行risc ...
- ASP.NET文件上传大小限制
上传限制 我们以为的文件大小限制 我们大家都知道ASP.NET为我们提供了文件上传服务器控件FileUpload,默认情况下可上传的最大文件为4M,如果要改变可上传文件大小限制,那么我们可以在web. ...
- Windows c++程序的基本结构
Windows c++程序的基本结构 1.一个完整的Windows应用程序通常由五种类型的文件组成 C语言源程序文件 头文件 模块定义文件 资源描述文件 项目文件 2.Windows应用程序构成基本框 ...
- Android内核的编译与测试
1.下载Android内核 source.android.com/source->Downloading and Building Building Kernels 大概要花2个小时,其源码在培 ...
- Oracle学习笔记(七)
九.高级查询(分组,子查询)查询升级版: 需要用到三张表员工表: desc emp EMPNO 员工号 ENAME 员工姓名 JOB 员工职位 MGR 老板员工号 HIREDATE 员工入职日期 SA ...