This is a migrated thread and some comments may be shown as answers.

[Solved] How set color to the Axis X & Y on Chart:RadCartesianChart

6 Answers 495 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carlos
Top achievements
Rank 1
Carlos asked on 19 Nov 2012, 06:40 PM
Hi...
How set color to the Axis X & Y on Chart:RadCartesianChart for Windows8 metro style VisualStudio.net  C#? Someone could help me with this task, i found some examples on G but it doesn't work or those aren't correct.

This is my code:
--------------------------------------------
<Page
   
    xmlns:Chart="using:Telerik.UI.Xaml.Controls.Chart" 
    x:Class="bluetooth_77.Pt_Chart"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:bluetooth_77"


    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Resources>
        <Style x:Key="LabelStyle" TargetType="TextBlock">
            <Setter
                Property="FontSize"
                Value="20"/>
            <Setter
                Property="Foreground"
                Value="YellowGreen"/>
        </Style>
    </Page.Resources>


    <Grid>
        <Grid x:Name="xStoreRevenue">
            <Grid.RowDefinitions>
                <RowDefinition
            Height="30"/>
                <RowDefinition
            Height="*"/>
            </Grid.RowDefinitions>
            <Chart:RadCartesianChart
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    Grid.Row="1" Margin="10,155,381,48" FontFamily="Segoe UI Light">

 <Chart:RadCartesianChart.Resources>
                    <Style x:Key="CustomAxisLineStyle" TargetType="Line">
                        <Setter Property="Stroke" Value="Black" />
                        <Setter Property="StrokeThickness" Value="5" />
                    </Style>

                </Chart:RadCartesianChart.Resources>

                
                <Chart:RadCartesianChart.Grid>
                    <Chart:CartesianChartGrid MajorLinesVisibility="Y"/>
                </Chart:RadCartesianChart.Grid>
                <Chart:RadCartesianChart.VerticalAxis>
                    <Chart:LinearAxis LabelStyle="{StaticResource LabelStyle}"/>
                </Chart:RadCartesianChart.VerticalAxis>
                <Chart:RadCartesianChart.HorizontalAxis>
                    <Chart:CategoricalAxis LabelStyle="{StaticResource LabelStyle}" LabelFitMode="MultiLine"/>
                </Chart:RadCartesianChart.HorizontalAxis>
                <Chart:BarSeries ItemsSource="{Binding StoreRevenues}">
                    <Chart:BarSeries.ValueBinding>
                        <Chart:PropertyNameDataPointBinding PropertyName="Amount"/>
                        
                    </Chart:BarSeries.ValueBinding>
                    <Chart:BarSeries.PointTemplate>
                        <DataTemplate>
                            <Rectangle Fill="Yellow"/>
                        </DataTemplate>
                    </Chart:BarSeries.PointTemplate>
                    <Chart:BarSeries.CategoryBinding>
                        <Chart:PropertyNameDataPointBinding PropertyName="StoreName"/>
                    </Chart:BarSeries.CategoryBinding>


                </Chart:BarSeries>
            </Chart:RadCartesianChart>
            <ComboBox x:Name="cbn_fecha" BorderBrush="#CCE6DCDC" FontFamily="Segoe UI Light"  HorizontalAlignment="Left" Margin="79,43,0,0" Grid.Row="1" VerticalAlignment="Top" Width="120" SelectionChanged="cbn_fecha_SelectionChanged" Foreground="Black"/>
            <Button Content="..." HorizontalAlignment="Left" Margin="1311,10,0,0" Grid.Row="1" VerticalAlignment="Top" Click="Button_Click_2"/>
            <TextBlock HorizontalAlignment="Left" Margin="35,43,0,0" Grid.Row="1" TextWrapping="Wrap" Text="Tipo:" VerticalAlignment="Top" FontSize="18" FontFamily="Segoe UI Light" Foreground="Black"/>
            <TextBox Visibility="Collapsed" x:Name="txtci" HorizontalAlignment="Left" Margin="35,110,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="80"/>
            <TextBlock HorizontalAlignment="Left" Grid.Row="1" TextWrapping="Wrap" Text="Grafico Estadistico Temperatura Corporal" VerticalAlignment="Top" FontSize="20" FontFamily="Segoe UI Light" Foreground="Black"/>
        </Grid>
        <TextBox HorizontalAlignment="Left" Margin="37,118,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="15" Height="9" Background="Yellow" BorderBrush="Yellow"/>
        <TextBlock  HorizontalAlignment="Left" Margin="106,126,0,0" TextWrapping="Wrap" Text="°C---°F" VerticalAlignment="Top" FontSize="20" FontFamily="Segoe UI Light" Foreground="Black"/>
    </Grid>
</Page>

----------------------------------------------------------

Regarts :)

6 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 20 Nov 2012, 04:21 PM
Hi, Carlos

Thank you for using our RadControls for Windows 8!

I checked your code and the current approach seems to be ok. Now you can use the LineStyle property of the Axis and set the resources you created:
LineStyle="{StaticResource CustomAxisLineStyle}"

More information is available in our online documentation - http://www.telerik.com/help/windows-8-xaml/radchart-axes-axis.html.

I hope this helps. Let me know if I can assist you any further.

Regards,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Carlos
Top achievements
Rank 1
answered on 21 Nov 2012, 06:08 PM
Thanks Ivaylo Gergov...

where that fragmnet of code would fits? I'm confused

Forgive me if I did not understand you.

Thanks again and regarts.

<Chart:RadCartesianChart.Resources>
                   <Style x:Key="CustomAxisLineStyle" TargetType="Line">
                       <Setter Property="Stroke" Value="Black" />
                       <Setter Property="StrokeThickness" Value="5" />
                   </Style>
</Chart:RadCartesianChart.Resources>

0
Carlos
Top achievements
Rank 1
answered on 21 Nov 2012, 06:10 PM
Thanks Ivaylo Gergov...

where that fragmnet of code would fits? I'm confused

LineStyle="{StaticResource CustomAxisLineStyle}"


Forgive me if I did not understand you.

Thanks again and regarts.

<Chart:RadCartesianChart.Resources>
                <Style x:Key="CustomAxisLineStyle" TargetType="Line">
                    <Setter Property="Stroke" Value="Black" />
                    <Setter Property="StrokeThickness" Value="5" />
                </Style>
</Chart:RadCartesianChart.Resources>

0
Carlos
Top achievements
Rank 1
answered on 21 Nov 2012, 07:14 PM
Ivaylo Gergov...
Sorry for the double post,i got connection problems.  I found out the way to apply the code, at last I could do it!  Thanks!
But i have other doubt, How I could coloring the value lines, I mean "the little vertical lines what under the numbers, the little sticks what poiting the numbers", they still white.

I hope I have you understood me, the english is not my main languaje. 

Regarts :)

|------|------|------| <---those
0
Ivaylo Gergov
Telerik team
answered on 23 Nov 2012, 08:49 AM
Hello, Carlos

Thank you for getting back to us.

If I understand you correctly you are talking about the ticks of the Axis. In order to change their style you can use the MajorTickStyle property of the Axis(TargetType="Rectangle"). Here's an example:
<Style x:Key="ticks" TargetType="Rectangle">
    <Setter Property="Fill" Value="Green"/>
</Style>

And then you need to apply the Style to your desired axis e.g. if your horizontal axis is categorical it will look like this:
<Chart:CategoricalAxis MajorTickStyle="{StaticResource ticks}"/>

I hope this helps. If you have any other questions do not hesitate to contact us again.

Regards,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Carlos
Top achievements
Rank 1
answered on 23 Nov 2012, 01:51 PM
Thanks so much, now my chart looks nice! :)

Regarts :)
Tags
Chart for XAML
Asked by
Carlos
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Carlos
Top achievements
Rank 1
Share this question
or