none
WPF Tookit Chart画柱子形图的问题 RRS feed

  • 问题

  • WPF Tookit chart 画柱形图,如何设置这个ColumnSeries这个高宽和Chart一样,或去掉chart ,

    如何控制Y轴显示的数值个数?求教!!!

    下面附上代码:

    XAML

    <Window
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:dc ="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"     
           xmlns:dt="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
            xmlns:tk="clr-namespace:System.Windows;assembly=WPFToolkit"
            xmlns:control="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WPFChart.MainWindow"
            Title="MainWindow"
            Loaded="Window_Loaded">
        <Grid>
            <Grid.Resources>
                <Style TargetType="{x:Type dt:Legend}" x:Key="legendStyle">
                    <Setter Property="Width" Value="0"/>
                    <Setter Property="Height" Value="0"/>

                    <Setter Property="Background" Value="{x:Null}"/>
                </Style>
            </Grid.Resources>
            <StackPanel>
                <dc:Chart Background="SkyBlue"  LegendStyle="{StaticResource legendStyle}" x:Name="mcChart"  Width="600" Height="500"    BorderThickness="0" >
                
                    <dc:ColumnSeries x:Name="columSer" BorderBrush="{x:Null}" FontSize="10" BorderThickness="0" IndependentValueBinding="{Binding X}"  DependentValueBinding="{Binding Y}" VerticalAlignment="Top" VerticalContentAlignment="Top"   Width="{Binding Path=Width,ElementName=mcChart}" Height="{Binding Path=Height,ElementName=mcChart}"  >
                       </dc:ColumnSeries>

                </dc:Chart>
               </StackPanel>
        </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 System.Windows.Controls.DataVisualization.Charting;
    using System.Windows.Controls.DataVisualization;

    namespace WPFChart
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }

            private void Window_Loaded(object sender, RoutedEventArgs e)
            {

                columSer.ItemsSource = new List<Point>
                {
                    new Point(1, 100),
                    new Point(2, 130),
                    new Point(3, 150),
                    new Point(4, 125),
                    new Point(5, 200) ,
                    new Point(6, 500)
                };

            }

       
        }
    }

    怎么改进代码,求教                                                                     

     

    • 已移动 ThankfulHeart 2012年6月18日 2:22 WPf问题 (发件人:Visual C#)
    2012年6月17日 14:59