C# Silverlight CategoryAxis X Widt使用scrollView水平拉伸

C# Silverlight CategoryAxis X Widt使用scrollView水平拉伸,c#,wpf,silverlight,charts,windows-phone,C#,Wpf,Silverlight,Charts,Windows Phone,我有工作专栏系列 我有大约50+个多列系列要显示,当有更多的条时,它会缩小条宽度并调整到图表宽度 因此,我想添加一个滚动只类别轴X和水平滚动与固定宽度的酒吧,如果它的更多系列的X轴应该水平拉伸 以下是屏幕截图: 在屏幕截图中,您可以看到第三个系列正在剪切,而不是滚动 这就是我尝试过的: <charting:Chart Name="barChart" Style="{StaticResource PhoneChartStyle

我有工作专栏系列

我有大约50+个多列系列要显示,当有更多的条时,它会缩小条宽度并调整到图表宽度

因此,我想添加一个滚动只类别轴X和水平滚动与固定宽度的酒吧,如果它的更多系列的X轴应该水平拉伸

以下是屏幕截图:

在屏幕截图中,您可以看到第三个系列正在剪切,而不是滚动

这就是我尝试过的:

<charting:Chart Name="barChart"
                                Style="{StaticResource PhoneChartStyle}"
                                Template="{StaticResource BarChartTemplate}">
                    <charting:Chart.Axes>
                        <charting:LinearAxis ShowGridLines="True" Title="Scores" Orientation="Y" Minimum="0" Maximum="50" Interval="10"/>
                        <charting:CategoryAxis HorizontalContentAlignment="Stretch"
                                               HorizontalAlignment="Stretch"
                                               Title="Fruits" 
                                               Width="1000"
                                               Orientation="X" 
                                               ScrollViewer.HorizontalScrollBarVisibility="Visible">
                        </charting:CategoryAxis>
                    </charting:Chart.Axes>
                    <charting:Chart.Series>
                        <charting:ColumnSeries 
                                    Title="Apple"
                                    IndependentValueBinding="{Binding Key}"
                                    DependentValueBinding="{Binding Value}"
                                    AnimationSequence="Simultaneous">
                            </charting:ColumnSeries>
                            <charting:ColumnSeries                 
                                    Title="Oranges"
                                    IndependentValueBinding="{Binding Key}"
                                    DependentValueBinding="{Binding Value}"
                                    AnimationSequence="Simultaneous">
                            </charting:ColumnSeries>
                            <charting:ColumnSeries                 
                                    Title="Guava"
                                    IndependentValueBinding="{Binding Key}"
                                    DependentValueBinding="{Binding Value}"
                                    AnimationSequence="Simultaneous">
                            </charting:ColumnSeries>
                    </charting:Chart.Series>
                </charting:Chart>*

*

我也有同样的问题,这个技巧解决了这个问题。希望这对你也有帮助

<ScrollViewer Width="480" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" Margin="0,10">
<charting:Chart Name="barChart"
                                Style="{StaticResource PhoneChartStyle}"
                                Template="{StaticResource BarChartTemplate}" Width="460">
                    <charting:Chart.Axes>
                        <charting:LinearAxis ShowGridLines="True" Title="Scores" Orientation="Y" Minimum="0" Maximum="50" Interval="10"/>
                        <charting:CategoryAxis HorizontalContentAlignment="Stretch"
                                               HorizontalAlignment="Stretch"
                                               Title="Fruits" 
                                               Width="1000"
                                               Orientation="X" 
                                               ScrollViewer.HorizontalScrollBarVisibility="Visible">
                        </charting:CategoryAxis>
                    </charting:Chart.Axes>
                    <charting:Chart.Series>
                        <charting:ColumnSeries 
                                    Title="Apple"
                                    IndependentValueBinding="{Binding Key}"
                                    DependentValueBinding="{Binding Value}"
                                    AnimationSequence="Simultaneous">
                            </charting:ColumnSeries>
                            <charting:ColumnSeries                 
                                    Title="Oranges"
                                    IndependentValueBinding="{Binding Key}"
                                    DependentValueBinding="{Binding Value}"
                                    AnimationSequence="Simultaneous">
                            </charting:ColumnSeries>
                            <charting:ColumnSeries                 
                                    Title="Guava"
                                    IndependentValueBinding="{Binding Key}"
                                    DependentValueBinding="{Binding Value}"
                                    AnimationSequence="Simultaneous">
                            </charting:ColumnSeries>
                    </charting:Chart.Series>
                </charting:Chart>
</ScrollViewer>

您是在图表中动态设置条形图ItemSource还是50常量系列???@Jaihind动态设置时,它可能包含50或100或某些值这将向右滚动整个图表?但我只想滚动Xseries@Goofy是的,我同意你的看法。我也有同样的问题,最后我采用了这个解决方案。我以前试过这个,不管怎样,它能做什么?barChart.Width=barChart.Width+(collection.Count()*80);我们是否需要设置条形图宽度的静态值=“460”?是的,只有将条形图的宽度保持为460(适合屏幕)才能使滚动正常工作。和barChart.Width+(collection.Count()*80);满足条件时,将集合中的每个项目的宽度增加80像素。请记住设置scrollviewer的宽度
if (collection .Count() > 2)
{
   barChart.Width = barChart.Width + (collection .Count() * 80);
}