在一张图上绘制两条线系列
我正在尝试在图表上绘制两条线系列。每条线的数据点都有不同的时间。不幸的是,下面的代码产生了一个奇怪的结果(可能是因为当前级别线没有时间戳)。是否有另一种图表类型或方法可以解决当前水平下降到每个目标水平为零的问题?
这是我的 xaml:
<chartingToolkit:Chart Title="Glucose and Target Levels" x:Name="LevelsChart">
<chartingToolkit:StackedLineSeries>
<chartingToolkit:SeriesDefinition Title="Actual"
ItemsSource="{Binding ElementName=PatientWindow, Path=GlucoseLevels}"
IndependentValuePath="Timestamp"
DependentValuePath="Level" />
<chartingToolkit:SeriesDefinition Title="Target"
ItemsSource="{Binding ElementName=PatientWindow, Path=TargetLevels}"
IndependentValuePath="Timestamp"
DependentValuePath="Level" />
</chartingToolkit:StackedLineSeries>
<chartingToolkit:Chart.Axes>
<chartingToolkit:DateTimeAxis x:Name="LevelsDateTimeAxis" Orientation="X" Minimum="{Binding ElementName=PatientWindow, Path=Minimum}" Maximum="{Binding ElementName=PatientWindow, Path=Maximum}" />
<chartingToolkit:LinearAxis Orientation="Y" Minimum="0" Maximum="200" Interval="20" />
</chartingToolkit:Chart.Axes>
</chartingToolkit:Chart>
这是结果:
I am trying to plot two lines series on a chart. Each line with have different times for their data points. Unfortunately, the code below produces a weird result (probably because the there is not a timestamp for the current level line). Is there another chart type or way that I can fix this issue of the current level going down to zero each target level?
Here is my xaml:
<chartingToolkit:Chart Title="Glucose and Target Levels" x:Name="LevelsChart">
<chartingToolkit:StackedLineSeries>
<chartingToolkit:SeriesDefinition Title="Actual"
ItemsSource="{Binding ElementName=PatientWindow, Path=GlucoseLevels}"
IndependentValuePath="Timestamp"
DependentValuePath="Level" />
<chartingToolkit:SeriesDefinition Title="Target"
ItemsSource="{Binding ElementName=PatientWindow, Path=TargetLevels}"
IndependentValuePath="Timestamp"
DependentValuePath="Level" />
</chartingToolkit:StackedLineSeries>
<chartingToolkit:Chart.Axes>
<chartingToolkit:DateTimeAxis x:Name="LevelsDateTimeAxis" Orientation="X" Minimum="{Binding ElementName=PatientWindow, Path=Minimum}" Maximum="{Binding ElementName=PatientWindow, Path=Maximum}" />
<chartingToolkit:LinearAxis Orientation="Y" Minimum="0" Maximum="200" Interval="20" />
</chartingToolkit:Chart.Axes>
</chartingToolkit:Chart>
Here is the result:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
StackedLineSeries
不是您想要的,实际上却是导致您出现问题的原因。此类图表将系列垂直相加,为每个独立轴值创建总计。只需将每个LineSeries
直接添加到Chart
中即可。A
StackedLineSeries
is not what want and is in fact what is causing you problems. That kind of chart adds the series together vertically to create a total for each independent axis value. Instead just add eachLineSeries
directly to theChart
.