簡體   English   中英

工具箱圖表旋轉標簽X軸

[英]Toolkit chart rotate labels X-axis

首先,感謝您閱讀本文。

我有以下問題:
我希望將X軸的標簽旋轉90度。 這樣文本將面對垂直而不是水平。 我的X軸是自動生成的,但不是必須如此。 這樣標簽的內容是垂直的而不是水平的。 我已經嘗試了多種選擇來實現這一目標,但是沒有一個對我有用。 因此,我真的希望任何人都對如何使它正常工作有所了解。 通過我嘗試的選項,只有另一個軸只顯示數字。 我想要的是旋轉標簽,使所有文本都適合軸,而不會彼此重疊。

下圖是現在的樣子: 現在怎么樣。

這是我想要的示例(這是在excel中制作的): 我想要的方式。

我到處查看了更多站點,但找不到適合我的站點。
無論是xaml還是后面的代碼對我來說都很好。
這是我現在使用的代碼:

<toolkit:Chart Margin="8,72,0,8" Title="Aantal meldingen per afdeling" x:Name="chartMeldingenPerAfdeling">
        <toolkit:Chart.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="White" Offset="0"/>
                <GradientStop Color="#FF476D88" Offset="1"/>
            </LinearGradientBrush>
        </toolkit:Chart.Background>
        <toolkit:ColumnSeries ItemsSource="{Binding}" DependentValuePath="AantalMeldingen"
                               IndependentValuePath="Afdeling" Margin="0,0,0,1" 
                           Title="Aantal meldingen" Padding="0" VerticalContentAlignment="Center" 
                           HorizontalContentAlignment="Center" FontSize="8"/>
        <toolkit:LineSeries ItemsSource="{Binding}" DependentValueBinding="{Binding Percentage}" DependentRangeAxis="{Binding ElementName=PercentageAxis}"
                            IndependentValueBinding="{Binding Afdeling}" IndependentAxis="{Binding ElementName=lin}" Title="Pareto"/>
        <toolkit:Chart.Axes>
            <toolkit:LinearAxis Orientation="Y" Location="Left" Title="Aantal" x:Name="AantalAxis"/>
            <toolkit:LinearAxis Orientation="Y" Location="Right" Title="Percentage" x:Name="PercentageAxis" Minimum="0" Maximum="100"/>
        </toolkit:Chart.Axes>
    </toolkit:Chart>

先感謝您。

請檢查以下代碼:

<toolkit:Chart Title="{Binding ChartTitle}" x:Name="myChart" Style="{StaticResource myChartStyle}" BorderBrush="{x:Null}"  Background="Black" Foreground="White">
            <toolkit:ColumnSeries ItemsSource="{Binding LegendList}"
                DependentValueBinding="{Binding FeatureQuantity}" 
                IndependentValueBinding="{Binding LegendName}" DataPointStyle="{Binding Source={StaticResource ColorByGradeColumn}}" >

            </toolkit:ColumnSeries>

            <toolkit:Chart.Axes>
                <toolkit:CategoryAxis Orientation="X" 
                                      Location="Bottom" 
                                      Foreground="White">
                    <toolkit:CategoryAxis.AxisLabelStyle>
                        <Style TargetType="toolkit:AxisLabel">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate 
                                          TargetType="toolkit:AxisLabel">
                                        <TextBlock 
                                 Text="{TemplateBinding FormattedContent}" 
                                                   TextAlignment="Right" 
                                                   TextWrapping="Wrap" 
                                                   Width="60" 
                                                   Margin="-20,15,0,0" 
                                                   RenderTransformOrigin="0.5,0.5">
                                            <TextBlock.RenderTransform>
                                                <RotateTransform Angle="90" />
                                            </TextBlock.RenderTransform>
                                        </TextBlock>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </toolkit:CategoryAxis.AxisLabelStyle>
                </toolkit:CategoryAxis>
            </toolkit:Chart.Axes>

        </toolkit:Chart>

結果是: http : //upload7.ir/imgs/2014-10/42094080161295718077.png

您可以為您的toolkit:ColumnSeries嘗試以下操作toolkit:ColumnSeries XAML元素:

        <chartingToolkit:ColumnSeries ItemsSource="{Binding}" DependentValuePath="AantalMeldingen" IndependentValuePath="Afdeling" Margin="0,0,0,1"  Title="Aantal meldingen" Padding="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="8">
            <chartingToolkit:ColumnSeries.IndependentAxis>
                <chartingToolkit:CategoryAxis Orientation="X">
                    <chartingToolkit:CategoryAxis.AxisLabelStyle>
                        <Style TargetType="chartingToolkit:AxisLabel">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="chartingToolkit:AxisLabel">
                                        <TextBlock Text="{TemplateBinding FormattedContent}">
                                                <TextBlock.LayoutTransform>
                                                    <RotateTransform Angle="-90"/>
                                                </TextBlock.LayoutTransform>
                                        </TextBlock>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </chartingToolkit:CategoryAxis.AxisLabelStyle>
                </chartingToolkit:CategoryAxis>
            </chartingToolkit:ColumnSeries.IndependentAxis>
        </chartingToolkit:ColumnSeries>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM