找回密码
 立即注册

QQ登录

只需一步,快速开始

lufq

论坛元老

13

主题

34

帖子

9683

积分

论坛元老

积分
9683

活字格认证

lufq
论坛元老   /  发表于:2013-11-1 09:00  /   查看:5567  /  回复:4
<Window.Resources>
        <DataTemplate x:Key="chartLabel">
            <TextBlock Text="{Binding Name}" FontSize="14"/>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <c1:C1Chart HorizontalAlignment="Stretch" Name="c1Chart1" Background="Transparent"
                    ChartType="Bar" VerticalAlignment="Stretch">
            <c1:C1Chart.Data>
                <c1:ChartData ItemsSource="{Binding CityBenths}" Name="c1"
                              ItemNameBinding="{Binding Name}">
                    <c1ataSeries Label="Series 1" RenderMode="Default"
                                   ValueBinding="{Binding Value}" PointLabelTemplate="{StaticResource chartLabel}"
                                   SymbolFill="Orange" />
                </c1:ChartData>
            </c1:C1Chart.Data>
            <!--<c1:C1ChartLegend DockPanel.Dock="Right" />-->
            <TextBlock DockPanel.Dock="Top" Name="title" HorizontalAlignment="Center" FontSize="18"/>
        </c1:C1Chart>
    </Grid>
附件中bar的标注显示在中间,如何让它显示在柱的顶部?如果有一个DataSeries的话,如何设置每个柱的颜色?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

4 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-11-1 10:06:00
沙发
回复 1楼lufq的帖子

lufq 你好,
1.标注显示:

  1. <c1chart:XYDataSeries.PointLabelTemplate>

  2.                             <DataTemplate>

  3.                                 <TextBlock c1chart:PlotElement.LabelAlignment="TopRight"

  4.                        Text="{Binding PointIndex}" />

  5.                             </DataTemplate>

  6.                         </c1chart:XYDataSeries.PointLabelTemplate>
复制代码


2.柱体颜色:

  1. private void XYDataSeries_PlotElementLoaded(object sender, EventArgs e)
  2.         {
  3.             PlotElement pe = (PlotElement)sender;
  4.             if (pe==null)
  5.             {
  6.                 return;
  7.             }

  8.             if (pe.DataPoint.Value>2)
  9.             {
  10.                 SolidColorBrush brush = new SolidColorBrush(Colors.Red);
  11.                 pe.Fill = brush;
  12.             }
  13.             else
  14.             {
  15.                 SolidColorBrush brush = new SolidColorBrush(Colors.Blue);
  16.                 pe.Fill = brush;
  17.             }
  18.         }
复制代码


详细请参考 Demo:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
lufq
论坛元老   /  发表于:2013-11-1 12:27:00
板凳

标注想放到这个顶部中间的位置,怎么弄?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
lufq
论坛元老   /  发表于:2013-11-1 12:32:00
地板
不用回复了,谢谢 设置MiddleRight就可以了
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-11-1 13:31:00
5#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部