Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
how to apply customized axis style on XamWebChart? Please help !!!!
posted

Hi guys , it doesn't work when i apply customized style to Axis PrimaryY on XamWebChart , neither in xaml nor in the code behind .

in code :

 Axis aY = _dataChart.Axes.FirstOrDefault<Axis>(axis => axis.AxisType == AxisType.PrimaryY);
            if (aY == null)
            {
                aY = new Axis { AxisType = AxisType.PrimaryY };
                //it works when properties are set in this way
              /*  aY.AutoRange = false;
                aY.Minimum = - 70;
                aY.Maximum = 100;
                aY.Unit = 10;*/

                //it doesn't work when apply style to aY
                aY.Style = (Style)this.Resources["AxisStyle1"];

                _dataChart.Axes.Add(aY);
            }

 

 

in Xaml:

<UserControl x:Class="ChartTest.LineChart"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igChart="clr-namespace:Infragistics.Silverlight.Chart;assembly=Infragistics.Silverlight.Chart.v9.2"
    Width="400" Height="300">
    <UserControl.Resources>
        <Style x:Key="AxisStyle1" TargetType="igChart:Axis">
            <Setter Property="AutoRange" Value="false"/>
            <Setter Property="Minimum" Value="-70"/>
            <Setter Property="Maximum" Value="100"/>
            <Setter Property="Unit" Value="10"/>
            <Setter Property="Background" Value="#58FFFFFF"/>
        </Style>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <igChart:XamWebChart x:Name="dataChart">
            <igChart:XamWebChart.Axes>
                <igChart:Axis AxisType="PrimaryY" Style="{StaticResource AxisStyle1}">
                    <igChart:Axis.MajorGridline>
                        <igChart:GridlineGroup Stroke="#00eaeaea" StrokeThickness=".5">
                           <!-- <igChart:GridlineGroup.GridlineStyle>
                                <Style TargetType="igChart:GridlineGroup">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="igChart:GridlineGroup">
                                                <Grid></Grid>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </igChart:GridlineGroup.GridlineStyle>-->
                        </igChart:GridlineGroup>
                    </igChart:Axis.MajorGridline>
                </igChart:Axis>
            </igChart:XamWebChart.Axes>
            <igChart:XamWebChart.Series>
               <igChart:Series ChartType="Line">
                    <igChart:Series.Marker>
                        <igChart:Marker Type="Star5" MarkerSize="1.5" Fill="#3298F9" Foreground="#00C1F30B" LabelDistance="1" />
                    </igChart:Series.Marker>
                    <igChart:Series.DataPoints>
                        <igChart:DataPoint Label="Q1" Value="25" />
                        <igChart:DataPoint Label="Q2" Value="30" />
                        <igChart:DataPoint Label="Q3" Value="45" />
                        <igChart:DataPoint Label="Q4" Value="55">
                            <igChart:DataPoint.Marker>
                                <igChart:Marker Format="{}{Value:c}"></igChart:Marker>
                            </igChart:DataPoint.Marker>
                        </igChart:DataPoint>
                    </igChart:Series.DataPoints>
                </igChart:Series>
                <igChart:Series ChartType="Line">
                    <igChart:Series.DataPoints>
                        <igChart:DataPoint Label="Q1" Value="10" />
                        <igChart:DataPoint Label="Q2" Value="-30" />
                        <igChart:DataPoint Label="Q3" Value="-20" />
                        <igChart:DataPoint Label="Q4" Value="25" />
                    </igChart:Series.DataPoints>
                </igChart:Series>
                <igChart:Series ChartType="Line">
                    <igChart:Series.DataPoints>
                        <igChart:DataPoint Label="Q1" Value="25" />
                        <igChart:DataPoint Label="Q2" Value="30" />
                        <igChart:DataPoint Label="Q3" Value="45" />
                        <igChart:DataPoint Label="Q4" Value="60" />
                    </igChart:Series.DataPoints>
                </igChart:Series><!---->
            </igChart:XamWebChart.Series>
        </igChart:XamWebChart>
    </Grid>
</UserControl>

Parents
  • 30692
    Offline posted

    This is a bug in the chart control having to do with the precedence of some of these properties in the way they are set. I've submitted this as a bug: 25979. You can check on the status of this bug at any time by contacting Developer Support.

    In the interim, if you set these properties directly in the xaml for the axis, rather than through the style, it should work appropriately.

    -Graham

Reply Children