• Silverlight调用Visfire开源图表组件的源代码


    Silverlight调用Visfire开源图表组件的源代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Visifire.Charts;
    
    namespace SL
    {
        public partial class VisifireTest : UserControl
        {
            public VisifireTest()
            {
                InitializeComponent();
                List<DateTime> updateTime = new List<DateTime>() 
                { 
                    new DateTime(2010,2,01,7,11,03),
                    new DateTime(2010,3,01,7,12,03),
                    new DateTime(2010,4,01,7,13,03),
                    new DateTime(2010,5,01,7,14,03),
                    new DateTime(2010,6,01,7,15,03), 
                    new DateTime(2010,7,01,7,16,03), 
                    new DateTime(2010,8,01,7,17,03),
                    new DateTime(2010,9,01,7,18,03)
                };
    
                List<string> value = new List<string>() { "20","25","40","55","67","74","88","94" };
                List<string> value1 = new List<string>() { "33", "44", "48", "15", "70", "56", "77", "5" };
                List<string> value2 = new List<string>() { "10", "81", "66", "60", "67", "12", "12", "100" };
                List<object> valueList = new List<object> { value, value1, value2 };
                CreateChart("内存使用率", updateTime, valueList, "%", 1, IntervalTypes.Minutes);
            }
    
    
    
            public void CreateChart(string tableName, List<DateTime> updateTime, List<object> valueList, string rihgtStr, int chartInterval, IntervalTypes intervaltype)
            {
                Chart chart = new Chart();       //创建一个图表
    
                /*  设置图表属性   */
                chart.Width = 500;
                chart.Height = 400;
                chart.ToolBarEnabled = true;
                chart.ScrollingEnabled = false;
                chart.View3D = true;
    
                Title title = new Title() { Text = tableName, Padding = new Thickness(0, 10, 5, 0) };  //图表标题
                chart.Titles.Add(title);         //添加标题
    
                Axis xAxis = new Axis();         //创建X轴
                xAxis.IntervalType = intervaltype;    //X轴分类类型, 小时*分*秒
                xAxis.Interval = chartInterval;       //X轴坐标间隔距离
                xAxis.ValueFormatString = "hh:mm:ss";      //X轴时间显示格式
                chart.AxesX.Add(xAxis);            //为图表添加X轴
    
    
                Axis yAxis = new Axis();        //创建Y轴
                yAxis.Suffix = rihgtStr;         //Y轴后缀%
                yAxis.AxisMinimum = 0;          //Y轴最小值为0      
                chart.AxesY.Add(yAxis);           //为图表添加Y轴
    
    
                for (int i = 0; i < valueList.Count; i++)
                {
                    DataSeries dataSeries = new DataSeries();   //创建数据线
                    dataSeries.RenderAs = RenderAs.Line;        //  数据线显示类型为线型
                    dataSeries.XValueType = ChartValueTypes.DateTime;   //设置X轴的类型为日期类型  
                    List<string> value = (List<string>)valueList[i];
                    for (int j = 0; j < updateTime.Count; j++)
                    {
                        DataPoint dataPoint = new DataPoint();   //创建数据点
                        dataPoint.XValue = updateTime[j];         //设置数据点X轴的值;
                        dataPoint.YValue = double.Parse(value[j]);  //设置Y轴值
                        dataPoint.MarkerSize = 8;              //设置数据点的大小
                        dataPoint.MouseLeftButtonDown += new MouseButtonEventHandler(dataPoint_MouseLeftButtonDown);  //数据点的鼠标单击事件                   
                        dataSeries.DataPoints.Add(dataPoint);       //为数据线添加数据点
                    }
                    chart.Series.Add(dataSeries);           //为图表添加数据线
                }
    
                LayoutRoot.Children.Add(chart);
            }
    
            void dataPoint_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
    
            }
    
        }
    }

    希望对大家有用~

  • 相关阅读:
    《Linux命令行与shell脚本编程大全 第3版》Linux命令行---37
    《Linux命令行与shell脚本编程大全 第3版》Linux命令行---36
    《Linux命令行与shell脚本编程大全 第3版》Linux命令行---35
    《Linux命令行与shell脚本编程大全 第3版》Linux命令行---34
    《Linux命令行与shell脚本编程大全 第3版》Linux命令行---33
    scrollBarStyle- listview滑动条调整
    mk-编译信息的意义
    values-dimen 不同分辨率资源实现引用
    ubuntu-虚拟机分辨率设定
    vmware-虚拟机播放器的下载、安装
  • 原文地址:https://www.cnblogs.com/slteam/p/2216693.html
Copyright © 2020-2023  润新知