在“设计”图表时,我遇到了一些我还没有解决的问题。现在的图表:http: //imgbin.org/index.php ?page=image&id=10595
1)我希望“AreaSeries”的线条与“LineSeries”具有相同的样式。正如您在图像中看到的,它根本没有样式:|。很可能与以下内容有关:
<ControlTemplate TargetType="toolkit:AreaDataPoint">
不正确,虽然我找不到正确的方法......是否有可能给“AreaSerie”的线和数据点另一个布局,或者是通过创建另一个具有相同布局的线系列来做到这一点的唯一方法数据点作为 AreaSeries?
2)当我通过脚本为 Y 轴设置最小值时:
(this.chart1.Axes[0] as LinearAxis).Minimum = UsersMin;
(this.chart1.Axes[1] as LinearAxis).Minimum = CumulativeMin;
这将导致线条根本不显示:| (即使我将其设置为“1”,并且行在 1 以上)。如何设置最小值并保留我的图形?
3) 是否可以将文本放在 ContentControl 中的动态值前面?
<ContentControl Content="Users: {TemplateBinding DependentValue}" />
上面的代码不起作用,因为它认为 {TemplateBinding DependentValue} 只是一个文本,而不是要替换为数据的代码……是否可以在数据绑定前面放置一个文本?如果是这样,怎么办?
XAML 代码附在下面。
谢谢!
JB
<toolkit:Chart.LegendStyle>
<Style TargetType="FrameworkElement">
<Setter Property="Width" Value="0" />
</Style>
</toolkit:Chart.LegendStyle>
<toolkit:Chart.TitleStyle>
<Style TargetType="ContentControl">
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Padding" Value="0,0,0,0"/>
</Style>
</toolkit:Chart.TitleStyle>
<toolkit:Chart.PlotAreaStyle>
<Style TargetType="Grid">
<Setter Property="Background" Value="#AAFFFFFF" />
<Setter Property="Margin" Value="0,0,0,0"/>
</Style>
</toolkit:Chart.PlotAreaStyle>
<toolkit:Chart.Axes>
<!-- Y-Axis custom range -->
<toolkit:LinearAxis x:Name="Yusers"
Orientation="Y"
Title="Users"
ShowGridLines="True"
Foreground="#FF000088"
FontSize="15" />
<toolkit:LinearAxis x:Name="YCumulative"
Orientation="Y"
Title="Cumulative"
Foreground="white"
FontSize="15" />
</toolkit:Chart.Axes>
<!-- Daily data -->
<toolkit:AreaSeries
x:Name="Daily"
ItemsSource="{Binding}"
IndependentValueBinding="{Binding Date}"
DependentValueBinding="{Binding Daily_User}"
DependentRangeAxis="{Binding ElementName=Yusers}">
<toolkit:AreaSeries.DataPointStyle>
<Style TargetType="toolkit:AreaDataPoint">
<Setter Property="Background" Value="#FF001188" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkit:AreaDataPoint">
<ToolTipService.ToolTip>
<StackPanel Margin="2,2,2,2">
<ContentControl Content="Users:" />
<ContentControl Content="{TemplateBinding DependentValue}" />
<ContentControl Content="{TemplateBinding IndependentValue}" />
</StackPanel>
</ToolTipService.ToolTip>
<Ellipse StrokeThickness="2" Height="20" Width="20" Stroke="#7F0011BF" Fill="Azure"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</toolkit:AreaSeries.DataPointStyle>
</toolkit:AreaSeries>
<!-- Cumulative data -->
<toolkit:LineSeries
x:Name="Cumulative"
ItemsSource="{Binding}"
IndependentValueBinding="{Binding Date}"
DependentValueBinding="{Binding Cumulative_User}"
DependentRangeAxis="{Binding ElementName=YCumulative}">
<toolkit:LineSeries.DataPointStyle>
<Style TargetType="toolkit:LineDataPoint">
<Setter Property="Background" Value="Black" />
<Setter Property="BorderBrush" Value="black" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkit:LineDataPoint">
<Grid x:Name="Root" Opacity="1">
<ToolTipService.ToolTip>
<StackPanel Margin="2,2,2,2">
<ContentControl Content="Cumulative Users:" />
<ContentControl Content="{TemplateBinding DependentValue}" />
<ContentControl Content="{TemplateBinding IndependentValue}" />
</StackPanel>
</ToolTipService.ToolTip>
<Ellipse StrokeThickness="2" Stroke="Black" Fill="Azure"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</toolkit:LineSeries.DataPointStyle>
</toolkit:LineSeries>
</toolkit:Chart>