This project is read-only.
1
Vote

Axis Label customization

description

Hello,

How can i do to customize axis label? i tried this:
                                <sparrow:SparrowChart.XAxis>
                                   <sparrow:CategoryXAxis Interval="1">
                                        <sparrow:CategoryXAxis.LabelTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="V" FontSize="12"/>
                                            </DataTemplate>
                                        </sparrow:CategoryXAxis.LabelTemplate>
                                    </sparrow:CategoryXAxis>
                                </sparrow:SparrowChart.XAxis>
Work fine in static context but i need dinamically change value "V" of TextBox. thank you in advance

comments

Foske76 wrote Mar 17, 2014 at 1:45 PM

Replace V with a binding to a property in your code behind.

melixor wrote Mar 17, 2014 at 2:20 PM

I tried it, but i don't know where set DataContext.

melixor wrote Mar 18, 2014 at 1:11 PM

Do you have any suggestion?

melixor wrote Mar 19, 2014 at 5:11 PM

Nobody can help me?

melixor wrote Mar 19, 2014 at 5:21 PM

i modified the code in this way:

<sparrow:SparrowChart Name="chartTransazioni" Height="220" Margin="10" Theme="Custom">
                                <sparrow:SparrowChart.DataContext>
                                    <local:ContoDettagliViewModel/>
                                </sparrow:SparrowChart.DataContext>
                                <sparrow:SparrowChart.Legend>
                                    <sparrow:Legend LegendPosition="Outside" Dock="Top"/>
                                </sparrow:SparrowChart.Legend>
                                <sparrow:SparrowChart.XAxis>
                                    <sparrow:CategoryXAxis Interval="1" LabelAngle="0" 
                                                            CrossLineStyle="{StaticResource crossLineStyle}"
                                                            MinorLineStyle="{StaticResource minorcrossLineStyle}" 
                                                            MajorLineStyle="{StaticResource crossLineStyle}" 
                                                            AxisLineStyle="{StaticResource axisLineStyle}"
                                                            ShowCrossLines="True">
                                        <sparrow:CategoryXAxis.LabelTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding PropertyA}" FontSize="12" Style="{StaticResource TextBlockStyleItemSubTitle}"/>
                                            </DataTemplate>
                                        </sparrow:CategoryXAxis.LabelTemplate>
                                    </sparrow:CategoryXAxis>
                                </sparrow:SparrowChart.XAxis>
                                <sparrow:SparrowChart.YAxis>
                                    <sparrow:LinearYAxis CrossLineStyle="{StaticResource crossLineStyle}"
                                                            MinorLineStyle="{StaticResource minorcrossLineStyle}" 
                                                            MajorLineStyle="{StaticResource crossLineStyle}" 
                                                            AxisLineStyle="{StaticResource axisLineStyle}"
                                                            ShowCrossLines="True">
                                        <sparrow:LinearYAxis.LabelTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding PropertyB}" FontSize="12" Style="{StaticResource TextBlockStyleItemSubTitle}"/>
                                            </DataTemplate>
                                        </sparrow:LinearYAxis.LabelTemplate>
                                    </sparrow:LinearYAxis>
                                </sparrow:SparrowChart.YAxis>                                    
                                <sparrow:ColumnSeries Stroke="Green" Fill="Green" Label="Entrate" Name="SerieEntrate" PointsSource="{Binding SerieEntrate}" XPath="X" YPath="Y"/>
                                <sparrow:ColumnSeries Stroke="Red" Fill="Red" Label="Uscite" Name="SerieUscite"  PointsSource="{Binding SerieUscite}" XPath="X" YPath="Y"/>                                                                            
                            </sparrow:SparrowChart>
the Data Context is ContoDettagliViewModel class. Data Context have PropertyA and PropertyB in binding with xaml.

The problem is that PropertyA and propertyB is not invoked. I made a mistake?

MaFu wrote Mar 19, 2014 at 6:21 PM

You have to implement a property changed notification if you haven't done already, see http://msdn.microsoft.com/de-de/library/ms743695(v=vs.110).aspx

melixor wrote Mar 19, 2014 at 7:30 PM

Yes, My data source Class implement INotifyPropertyChanged and property lunches the relative event.

melixor wrote Mar 20, 2014 at 11:00 AM

I don't understand how to set DataSource to bind with CategoryXAxis.LabelTemplate, so as to have the labels with dataSource value.
I need a list of item and each item is the label value?

thanks in advance.

MasuqaT wrote Aug 11, 2014 at 7:22 PM

        <sparrow:SparrowChart.XAxis>
            <sparrow:LinearXAxis Interval="3.1416"  MaxValue="6.2832" MinValue="-6.2832" >
                <sparrow:LinearXAxis.LabelTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Converter={StaticResource ResourceKey=PiConverter}}" />
                    </DataTemplate>
                </sparrow:LinearXAxis.LabelTemplate>
            </sparrow:LinearXAxis>
        </sparrow:SparrowChart.XAxis>
"PiConverter" will get axis value (ex. 0, 1, 3.14) in Convert method.
So you can use custom axis unit (ex. pi, e).
If it's different, I'm sorry.