Visifire图表

1、柱状图

代码:

public void BindChart1()
{
    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 = 0;
    int onNum = 0;
    int totalNum = 0;
    string errMsg = string.Empty;
    bool result = false;

    BackgroundWorker worker = new BackgroundWorker();
    worker.DoWork += (s, e) =>
    {
        result = HI.Get<ICameraService>().GetCameraOnline(out colorList, out fjList, out qyonList, out qyoutList, out outNum, out onNum, out totalNum, out errMsg);
    };
    worker.RunWorkerCompleted += (s, e) =>
    {
        try
        {
            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(0);
            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(0);
            chart.PlotArea = pa;
            #endregion

            //绑定Chart
            chart.Series.Clear();
            chart.Titles.Clear();

            chart.Width = this.chart1Grid.Width - 10;
            chart.Height = this.chart1Grid.Height - 10;

            DataSeries dataSeries = new DataSeries();
            DataPoint datapoint = null;

            #region 颜色
            SolidColorBrush[] brushArr = new SolidColorBrush[8];
            brushArr[0] = new SolidColorBrush(Color.FromRgb(237, 133, 140));
            brushArr[1] = new SolidColorBrush(Color.FromRgb(178, 150, 233));
            brushArr[2] = new SolidColorBrush(Color.FromRgb(16, 227, 230));
            brushArr[3] = new SolidColorBrush(Color.FromRgb(176, 235, 124));
            brushArr[4] = new SolidColorBrush(Color.FromRgb(237, 133, 140));
            brushArr[5] = new SolidColorBrush(Color.FromRgb(178, 150, 233));
            brushArr[6] = new SolidColorBrush(Color.FromRgb(16, 227, 230));
            brushArr[7] = new SolidColorBrush(Color.FromRgb(176, 235, 124));
            #endregion

            #region 数据
            for (int i = 0; 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 = 0;  //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.chart1Grid.Children.Clear();
            this.chart1Grid.Children.Add(chart);
        }
        catch { }
    };
    worker.RunWorkerAsync();

}

效果图:

2、堆积柱状图

代码:

public void PartolTaskChart()
{
    try
    {
        Chart chart = new Chart();

        #region 样式
        //样式
        chart.ThemeEnabled = true;
        chart.Theme = "Theme2";
        chart.Background = new SolidColorBrush(Colors.Transparent);
        chart.BorderThickness = new Thickness(0);
        chart.AnimationEnabled = false;
        chart.View3D = false;

        PlotArea pa = new PlotArea();
        pa.Background = new SolidColorBrush(Colors.Transparent);
        pa.ShadowEnabled = false;
        pa.BorderThickness = new Thickness(0);
        chart.PlotArea = pa;
        #endregion

        #region 颜色
        SolidColorBrush[] brushArr = new SolidColorBrush[8];
        brushArr[0] = new SolidColorBrush(Color.FromRgb(237, 133, 140));
        brushArr[1] = new SolidColorBrush(Color.FromRgb(178, 150, 233));
        brushArr[2] = new SolidColorBrush(Color.FromRgb(16, 227, 230));
        brushArr[3] = new SolidColorBrush(Color.FromRgb(176, 235, 124));
        brushArr[4] = new SolidColorBrush(Color.FromRgb(237, 133, 140));
        brushArr[5] = new SolidColorBrush(Color.FromRgb(178, 150, 233));
        brushArr[6] = new SolidColorBrush(Color.FromRgb(16, 227, 230));
        brushArr[7] = new SolidColorBrush(Color.FromRgb(176, 235, 124));
        #endregion

        #region 数据
        List<Dictionary<string, int>> lsDic = new List<Dictionary<string, int>>();
        BackgroundWorker worker = new BackgroundWorker();
        worker.DoWork += (s, e) =>
        {
            lsDic = HI.Get<SunCreate.CombatPlatform.Contract.IVideoPatrol>().GetTackRecordAnalysis(DateTime.Now.AddYears(-1), DateTime.Now.AddDays(1), "1");
        };
        worker.RunWorkerCompleted += (s, e) =>
        {
            try
            {
                #region 巡查次数
                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.StackedColumn;
                dataSeries.ShowInLegend = false;
                dataSeries.Color = brushArr[0];

                foreach (string key in lsDic[0].Keys)
                {
                    //设置点
                    int val = lsDic[0][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[1];

                foreach (string key in lsDic[1].Keys)
                {
                    //设置点
                    int val = lsDic[1][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[2];

                foreach (string key in lsDic[2].Keys)
                {
                    //设置点
                    int val = lsDic[2][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

            }
            catch { }
        };
        worker.RunWorkerAsync();
        #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 = 0;  //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 { }
}

效果图:

时间: 2024-08-26 19:22:15

Visifire图表的相关文章

visifire 图表双坐标轴 silverlight

public void CreateChart(Grid oGrid, ObservableCollection<ListItem> lBaseOilBar)        {            foreach (ListItem li in lBaseOilBar)            {                //图表大小,框线                Chart chart = new MyCharts();                chart.Width =

WPF Visifire 图表控件

Visifire WPF 图表控件 破解 可能用WPF生成过图表的开发人员都知道,WPF虽然本身的绘图能力强大,但如果每种图表都自己去实现一次的话可能工作量就大了, 尤其是在开发时间比较紧的情况下.这时候有必要借助一种专业的图表工具. Visifire 是专为WPF.SliverLight.WP开发人员制定的一套图表控件,实现了一系列的专业图表(如:柱图.点图.雷达.饼图.K线图.以及其组合图等). 它在4.5版本前都是实验阶段,而且是免费的....所以赢得了大部开发人员的青睐. 然而在2011

asp.net中绘制大数据量的可交互的图表

在一个asp.net项目中要用到能绘制大数据量信息的图表,并且是可交互的(放大.缩小.导出.打印.实时数据),能够绘制多种图形. 为此进行了多方调查预研工作,预研过微软的MsChart图表组件.基于jquery的FlortChart图表.Silverlight的Visifire图表组件.基于js和flash的FusionCharts图表.Ext4.0框架中的图表.纯js的Highstock和纯js的Highcharts. 下面给出各个图表的预研结果,以供参考. MsChart MsChart是一

一个WPF小项目小结

一:缘起 在10月中旬的时候在学校BBS上看到有人有做PC桌面客户端的需求,做的是能耗的计算和评估,要算能耗,就有很多环节,最后对这些环节数据进行一些简单计算.我想要是做的话就用比较熟的wpf,就去聊了下,对方给了1张比较复杂的Excel表格(其实对方的需求并不是很清楚,最后大概10来张EXcel表格),说是要做成软件呈现的形式,也没要求数据库,反正只要有功能,界面他们也没概念,给了个98年的老软件作为参考,最后EXcel表格弄懂结构后不复杂,计算都是加减乘除.我就答应了,这个软件算起来大概花了

使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示

原文:使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示 首先来看一看实现的效果: PS:原始的程序中更新曲线数据时添加了过渡的效果,具体可查看官网的示例: http://www.visifire.com/silverlight_spline_charts_gallery.php 点击其中的一个例子,然后点击Live Updates,就可看到数据更新时的过渡效果.但是蛋疼的博客园,不知道为什么,我插入了我原始的xap文件,过渡效果却没有

Silverlight 图表控件 Visifire 常用属性

首要介绍 Visifire 常用属性的设置,用来生成不合样式的图例 设置Chart的属 //设置title的值 // 创建一个题目标对象 Title title = new Title(); // 设置题目标名称 title.Text = titleText; title.Padding = new Thickness(0, 10, 5, 0); // 向图标添加题目 chart.Titles.Add(title); //是否显示3D结果 chart.View3D = view3D; //图表数

silverlight visifire控件图表制作——silverlight 后台方法页面事件

1.返回事件 (1.返回silverlight页面,2.返回web页面) private void button_ClickBack(object sender, RoutedEventArgs e)        { 1.返回silverlight页面: this.Content = new BeginControlChart(sTNameClick, strReportDate, false);//增加个参数表名 2.返回web页面 HtmlWindow html = HtmlPage.Wi

silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs

一.构造方法ControlChart 1.前台页面控件赋值 //时间下拉框赋值,下拉框赋选定值                for (int ii = DateTime.Today.Year; ii >= 1980; ii--)                {                    string item = string.Format("{0}年", ii.ToString());                    this.dateYear.Items

silverlight visifire控件图表制作——silverlight 静态页面xaml

一.silverlight 静态页面 1. 时间控件:DatePicker ,添加引用: xmlns:sdk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls", 触发事件:SelectedDateChanged: 2.文本:TextBlock : 3.下拉框:ComboBox,触发事件:SelectionChanged : 4.按钮:Button ,触发事件:Click: 5.图表画布:Gr