Visifire图表

Visifire图表引用DLL:WPFToolkitWPFVisifire.Charts.dllWPFVisifire.Gauges.dll1、柱状图代码:publicvoidBindChart1(){System.Threading.Tasks.Task.Factory.StartNew(()=>{try…

大家好,又见面了,我是你们的朋友全栈君。

引用DLL:

WPFToolkit

WPFVisifire.Charts.dll

WPFVisifire.Gauges.dll

1、柱状图

代码:

Visifire图表
Visifire图表

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 = 0;
            int onNum = 0;
            int totalNum = 0;
            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(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
        {

        }
    });
}

View Code

效果图:

Visifire图表

2、堆积柱状图

 代码:

Visifire图表
Visifire图表

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(-1), DateTime.Now.AddDays(1), "1");
            #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(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 数据
                #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
                #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
        {

        }
    });
}

View Code

效果图:

Visifire图表

3、雷达图

代码:

Visifire图表
Visifire图表

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

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

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

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

        #region 数据
        //设置类型为雷达图  
        DataSeries dataSeries = new DataSeries();
        dataSeries.RenderAs = RenderAs.Radar;
        dataSeries.ShowInLegend = false;
        dataSeries.Color = brushArr[0];

        //设置点  
        DataPoint point = new DataPoint();
        point.YValue = 20;
        point.AxisXLabel = "高新分局";
        point.Tag = "高新分局";
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 50;
        point.AxisXLabel = "包河分局";
        point.Tag = "包河分局";
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 70;
        point.AxisXLabel = "新站分局";
        point.Tag = "新站分局";
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 10;
        point.AxisXLabel = "经开分局";
        point.Tag = "经开分局";
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 50;
        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[1];

        //设置点  
        point = new DataPoint();
        point.YValue = 33;
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 57;
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 25;
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 98;
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 70;
        dataSeries.DataPoints.Add(point);

        chart.Series.Add(dataSeries);
        #endregion

        #region 数据
        //设置类型为雷达图  
        dataSeries = new DataSeries();
        dataSeries.RenderAs = RenderAs.Radar;
        dataSeries.ShowInLegend = false;
        dataSeries.Color = brushArr[2];

        //设置点  
        point = new DataPoint();
        point.YValue = 95;
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 88;
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 50;
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 60;
        dataSeries.DataPoints.Add(point);

        point = new DataPoint();
        point.YValue = 83;
        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 = 0;  //y轴刻度最小值
        yAxis.AxisMaximum = 100;  //y轴刻度最大值
        //yAxis.Suffix = "%"; //"给刻度添加后缀 如%";
        yAxis.Interval = 25;    //设置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 { }
}

View Code

效果图:

Visifire图表

 

补充:

datapoint.LightingEnabled = false; // 照明功能
datapoint.SnapsToDevicePixels = true; // 像素对齐

 

转载于:https://www.cnblogs.com/s0611163/p/7094729.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/162782.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • vscode好用的插件「建议收藏」

    1.Chinese(Simplified)LanguagePackforVisualStudioCode(汉化vscode必备)2.BracketPairColorizer(给代码中的括号添加亮色便于区分这里截图有报错是特意便于演示写的多组括号)3.AutoCloseTag(自动补全标签必备)4.AutoRenameTag(修改标签名自动同步修改闭合标签的标签名必备)5.ClassautocompleteforHTML(自动补全cl

    2022年4月17日
    233
  • sortedset实现_实现serializable接口

    sortedset实现_实现serializable接口1.SortedSet接口 继承了Set接口,基本类型加String类型放到排序的集合中,可以不用写实现Comparable接口,但是自定义类类型就必须实现这个接口,不然会报类型转换错误(collection接口的remove())  SortedSet接口的子类有TreeSet类 …

    2022年8月30日
    0
  • synchronized偏向锁和轻量级锁_偏向锁/轻量级锁/重量级锁的原理

    synchronized偏向锁和轻量级锁_偏向锁/轻量级锁/重量级锁的原理今天简单了解了一下java轻量级锁和重量级锁以及偏向锁。看了看这篇文章觉得写的不错原文链接java 偏向锁、轻量级锁及重量级锁synchronized原理Java对象头与Monitorjava对象头是实现synchronized的锁对象的基础,synchronized使用的锁对象是存储在Java对象头里的。对象头包含两部分:Mark Word 和 Class Metadata Address其中Mark Word在默认情况下存储着对象的HashCode、分代年龄、锁标记位等以下是32位JVM的

    2022年8月9日
    7
  • mysql报错日志文件在哪_windows硬件报错日志

    mysql报错日志文件在哪_windows硬件报错日志1.cmd打开服务,找到mysql服务,查看属性中my.ini配置文件所在位置:2.打开my.ini配置文件,查看datadir配置:datadir=C:/ProgramData/MySQL/MySQLServer5.7/Data此目录存储了错误日志文件3.查看错误日志文件名SHOWVARIABLESLIKE”%error%”;…

    2022年10月13日
    0
  • 手机修改ntp服务器地址,手机修改ntp服务器ip地址

    手机修改ntp服务器地址,手机修改ntp服务器ip地址手机修改ntp服务器ip地址内容精选换一换本文介绍使用云手机服务时需要了解的基本概念。云手机是一台包含原生安卓操作系统,具有虚拟手机功能的云服务器,简单来说,云手机=云服务器+AndroidOS。您可以远程实时控制云手机,实现安卓APP的云端运行;也可以基于云手机的基础算力,高效搭建应用,如云游戏、移动办公、直播互娱等场景。服务器是用来提供云手机的物理服务器。云手机目前以服务器您可以直接修改虚…

    2022年5月26日
    40
  • 非常好的理解遗传算法的例子有哪些_知觉理解性的例子

    非常好的理解遗传算法的例子有哪些_知觉理解性的例子遗传算法的手工模拟计算示例为更好地理解遗传算法的运算过程,下面用手工计算来简单地模拟遗传算法的各   个主要执行步骤。      例:求下述二元函数的最大值:   (1)个体编码          遗传算法的运算对象是表示个体的符号串,所以必须把变量x1,x2编码为一种      符号串。本题中,用无符号二进制整数来表示。          因x1,x2

    2022年9月13日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号