• WPF中使用VisiFire制作chart报表


    工程创建

    1.创建WPF工程

    2.创建一个文件夹lib

    3.将WPFVisifire.Charts.dll添加进lib文件夹

    4.添加引用-》浏览  选择 WPFVisifire.Charts.dll

     使用:

    <Window x:Class="testCharts.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid x:Name="LayoutRoot">
            
        </Grid>
    </Window>
    
     
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Visifire.Charts;
    
    namespace testCharts
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
    
                // Create a new DateTime object
                dt = new List<DateTime>();
    
                // Populate DateTime collection
               dt.Add(DateTime.Parse("2010-02-03 12:02:44"));
                dt.Add(DateTime.Parse("2010-02-03 12:03:44"));
                dt.Add(DateTime.Parse("2010-02-03 12:04:44"));
                dt.Add(DateTime.Parse("2010-02-03 12:05:44"));
                dt.Add(DateTime.Parse("2010-02-03 12:06:44"));
                dt.Add(DateTime.Parse("2010-02-03 12:07:44"));
                dt.Add(DateTime.Parse("2010-02-03 12:08:44"));
    
    
                // Create a new Visifire Chart
                CreateChart();
            }
    
            /// <summary>
            /// Function to create a chart
            /// </summary>
            public void CreateChart()
            {
                // Create a new instance of Chart
                Chart chart = new Chart();
    
                // Set chart properties
                chart.ScrollingEnabled = true;
                chart.View3D = false;
    
                // Create a new instance of Title
                Title title = new Title();
    
                // Set title property
                title.Text = "Visifire DateTime Axis Chart";
    
                // Add title to Titles collection
                chart.Titles.Add(title);
    
                // Create a new Axis
                Axis axis = new Axis();
    
                // Set axis properties
                axis.IntervalType = IntervalTypes.Seconds;
                axis.ValueFormatString = "MMdd hh:mm";
                axis.Interval = 60;
    
                // Add axis to AxesX collection
                chart.AxesX.Add(axis);
    
                for (Int32 j = 0; j < 2; j++)
                {
                    // Create a new instance of DataSeries
                    DataSeries dataSeries = new DataSeries();
    
                    // Set DataSeries properties
                    //dataSeries.RenderAs = RenderAs.Area;
    
                    dataSeries.RenderAs = RenderAs.Column;
                    dataSeries.XValueType = ChartValueTypes.DateTime;
                    dataSeries.XValueFormatString = "yyyyMMdd hh:mm:ss";
    
                    //Create a DataPoint
                    DataPoint dataPoint;
    
                    for (int i = 0; i < 6; i++)
                    {
                        // Create a new instance of DataPoint
                        dataPoint = new DataPoint();
    
                        // Set XValue for a DataPoint
                        dataPoint.XValue = dt[i];
    
                        // Set YValue for a DataPoint-
                        dataPoint.YValue = rand.Next(10, 100);
    
                        // Add dataPoint to DataPoints collection
                        dataSeries.DataPoints.Add(dataPoint);
                        //dataSeries.Name = "11";
                    }
    
                    // Add dataSeries to Series collection.
                    chart.Series.Add(dataSeries);
                }
    
                // Add chart to LayoutRoot
                LayoutRoot.Children.Add(chart);
            }
    
            /// <summary>
            /// Create a random class variable
            /// </summary>
            Random rand = new Random(DateTime.Now.Millisecond);
            List<DateTime> dt;
        }
    }
  • 相关阅读:
    一些网站后台模板源码分析 Particleground.js 验证码
    C# 接口的作用浅谈举例(转)
    C# 批量修改文件名
    12306抢票软件相关接口以及数据格式
    StackExChange.Redis for C# 中文文档
    asp.net core 3+ 修改view后自动重新编译运行
    ASP.NET MVC https全局配置
    c#DateTime与unix时间戳互相转换
    mongodb创建管理员用户
    Office365激活方法(无需密钥)
  • 原文地址:https://www.cnblogs.com/hedan/p/2631212.html
Copyright © 2020-2023  润新知