zoukankan      html  css  js  c++  java
  • SilverLigth的Chart不要图例(Legend)的方法

    XMAL方式:

     1         <chartingToolkit:Chart x:Name="SamplePercentageChart"  Grid.Row="0"
    2 DataContext="{Binding ElementName=PieSampleUserControl}" >
    3
    4 <chartingToolkit:PieSeries DependentValueBinding="{Binding Percentage}"
    5 ItemsSource="{Binding PieSlices}"
    6 IndependentValueBinding="{Binding }"
    7 >
    8
    9 </chartingToolkit:PieSeries>
    10
    11 <chartingToolkit:Chart.LegendStyle>
    12 <Style TargetType="datavis:Legend">
    13 <Setter Property="Width" Value="0"/>
    14 <Setter Property="Height" Value="0"/>
    15 </Style>
    16 </chartingToolkit:Chart.LegendStyle>
    17
    18 </chartingToolkit:Chart>

    C#代码:

    1                 Chart chart = new Chart { Title = new TextBlock() { Text = di.Key, TextWrapping = TextWrapping.Wrap }, Width = 350, Height = 300, Margin = new Thickness(20, 20, 0, 0) };
    2 Style style = new Style(typeof(Legend));
    3 style.Setters.Add(new Setter(Legend.WidthProperty, 0));
    4 style.Setters.Add(new Setter(Legend.HeightProperty, 0));
    5 chart.LegendStyle = style;


    定制X轴和Y轴量程和标题等方法

    XAML方式:

                   <DVC:ScatterSeries  Title=""         
    IndependentValueBinding
    ="{Binding Path=Key}"
    DependentValueBinding
    ="{Binding Path=Value}"
    >
    <DVC:ScatterSeries.IndependentAxis >
    <DVC:LinearAxis
    Title="Prices"
    Orientation
    ="X" Maximum="6.5" Minimum="2">

    </DVC:LinearAxis>
    </DVC:ScatterSeries.IndependentAxis>

    C#代码:

                    CategoryAxis xAxis = new CategoryAxis { Orientation = AxisOrientation.X, Title = "(年)" };
    chart.Axes.Add(xAxis);

    LinearAxis yAxis = new LinearAxis { Orientation = AxisOrientation.Y, Location = AxisLocation.Left, Title = "(%)", ShowGridLines = true, Minimum = 0, Maximum = 100 };
    chart.Axes.Add(yAxis);

    LineSeries ls = new LineSeries();
    ls.Title = string.Empty;
    ls.IndependentValueBinding = new Binding("Name");
    ls.DependentValueBinding = new Binding("Value");
    ls.ItemsSource = di.Items;

    ls.IndependentAxis = xAxis;
    ls.DependentRangeAxis = yAxis;




  • 相关阅读:
    日常学习随笔-数组、单链表、双链表三种形式实现队列结构的基本操作(源码注释)
    代码重构之单元测试
    C# yield return 用法与解析
    MVC学习手册之数据注解与验证
    C#数字图像处理算法学习笔记(三)--图像几何变换
    关于变量名与类名同名问题
    C# 计时器
    C#入门--索引器
    C#入门--字段与属性
    var与dynamic
  • 原文地址:https://www.cnblogs.com/chriskwok/p/2195624.html
Copyright © 2011-2022 走看看