첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="800"
    Height="600"
    Title="그리드 컬럼에서 스파크 라인 보여주기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
        <dxg:GridControl x:Name="gridControl"
            ItemsSource="{Binding SaleDataRowList}">
            <dxg:GridControl.Columns>
                <dxg:GridColumn
                    FieldName="Title"
                    Header="Order"
                    ReadOnly="True"
                    Width="200" />
                <dxg:GridColumn
                    FieldName="SparklineData"
                    Header="Sales"
                    Width="200">
                    <dxg:GridColumn.EditSettings>
                        <dxe:SparklineEditSettings
                            PointArgumentMember="ArgumentColumn"
                            PointValueMember="ValueColumn">
                            <dxe:SparklineEditSettings.PointArgumentRange>
                                <dxe:Range
                                    Auto="False"
                                    Limit1="07/17/2013"
                                    Limit2="08/15/2013" />
                            </dxe:SparklineEditSettings.PointArgumentRange>
                            <dxe:SparklineEditSettings.StyleSettings>
                                <dxe:AreaSparklineStyleSettings
                                    Brush="BlueViolet"
                                    HighlightMaxPoint="True"
                                    HighlightMinPoint="True"
                                    MaxPointBrush="Red"
                                    MinPointBrush="Blue" />
                            </dxe:SparklineEditSettings.StyleSettings>
                        </dxe:SparklineEditSettings>
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
            </dxg:GridControl.Columns>
        </dxg:GridControl>
    </Grid>
</Window>

 

728x90

 

▶ MainWindow.xaml.cs

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region Field

        /// <summary>
        /// 난수 발생기
        /// </summary>
        private Random random = new Random();

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 판매 데이터 행 리스트 - SaleDataRowList

        /// <summary>
        /// 판매 데이터 행 리스트
        /// </summary>
        public List<SaleDataRow> SaleDataRowList { get; set; }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            this.gridControl.DataContext = this;

            SaleDataRowList = new List<SaleDataRow>();

            int rowCount = 20;

            for(int i = 0; i < rowCount; i++)
            {
                SaleDataRowList.Add
                (
                    new SaleDataRow()
                    {
                        Title         = string.Format("Index : {0}", i + 1), 
                        SparklineData = CreateSparklineData()
                    }
                );
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 스파크 라인 데이터 생성하기 - CreateSparklineData()

        /// <summary>
        /// 스파크 라인 데이터 생성하기
        /// </summary>
        /// <returns>스파크 라인 데이터</returns>
        private IList CreateSparklineData()
        {
            ObservableCollection<SaleItem> saleItemCollection = new ObservableCollection<SaleItem>();
            
            DateTime dateTime = new DateTime(2013, 07, 17);

            for(int i = 0; i < 30; i++)
            {
                saleItemCollection.Add
                (
                    new SaleItem()
                    {
                        ValueColumn    = random.Next(-20, 20),
                        ArgumentColumn = dateTime.AddDays(i)
                    }
                );
            }

            return saleItemCollection;
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요