RadChart X-Axis don't start from 0

4 posts, 0 answers
  1. Alessandro
    Alessandro avatar
    4 posts
    Member since:
    Oct 2011

    Posted 27 Oct 2015 Link to this post

    I have a User Control with this RadChart defined in xaml:

    <telerik:RadChart Grid.Row="1" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Center" Name="radChart"  >
        <telerik:RadChart.SeriesMappings>
            <telerik:SeriesMapping LegendLabel="Fin" >
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:SplineSeriesDefinition ShowItemToolTips="True" ShowItemLabels="False" ShowPointMarks="False"></telerik:SplineSeriesDefinition>
                </telerik:SeriesMapping.SeriesDefinition>
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="XValue" FieldName="XValue" />
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="YValue1" />
                </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
            <telerik:SeriesMapping LegendLabel="Avv" >
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:SplineSeriesDefinition ShowItemToolTips="True" ShowItemLabels="False" ShowPointMarks="False"></telerik:SplineSeriesDefinition>
                </telerik:SeriesMapping.SeriesDefinition>
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="XValue" FieldName="XValue" />
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="YValue2" />
                </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
            <telerik:SeriesMapping LegendLabel="Avv" >
                <telerik:SeriesMapping.SeriesDefinition>
                    <telerik:SplineSeriesDefinition ShowItemToolTips="True" ShowItemLabels="False" ShowPointMarks="False"></telerik:SplineSeriesDefinition>
                </telerik:SeriesMapping.SeriesDefinition>
                <telerik:SeriesMapping.ItemMappings>
                    <telerik:ItemMapping DataPointMember="XValue" FieldName="XValue" />
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="YValue3" />
                </telerik:SeriesMapping.ItemMappings>
            </telerik:SeriesMapping>
        </telerik:RadChart.SeriesMappings>
        <telerik:RadChart.DefaultView>
            <telerik:ChartDefaultView>
                <telerik:ChartDefaultView.ChartArea>
                    <telerik:ChartArea PaletteBrushesRepeat="False" x:Name="chartArea"  >
                        <telerik:ChartArea.PaletteBrushes>
                            <SolidColorBrush Color="Red" />
                            <SolidColorBrush Color="Blue" />
                            <SolidColorBrush Color="Green" />
                        </telerik:ChartArea.PaletteBrushes>
                    </telerik:ChartArea>
                </telerik:ChartDefaultView.ChartArea>
                <telerik:ChartDefaultView.ChartLegend>
                    <telerik:ChartLegend Visibility="Hidden" Width="0" />
                </telerik:ChartDefaultView.ChartLegend>
            </telerik:ChartDefaultView>
        </telerik:RadChart.DefaultView>
    </telerik:RadChart>

    In code behind of this User Control I have this property:

    public object SignalsItemsSource
    {
        get { return radChart.ItemsSource; }
        set { radChart.ItemsSource = value; }
    }

    I set this property with 700 points that start on x from 0:

    Dictionary<int, double> _dicY1 = new Dictionary<int, double>();
    Dictionary<int, double> _dicY2 = new Dictionary<int, double>();
    Dictionary<int, double> _dicY3 = new Dictionary<int, double>();
     
    for (int _ii = 0; _ii < 700; _ii++)
    {
        Random _random = new Random(DateTime.Now.Millisecond);
        _dicY1[_ii] = _random.NextDouble();
        _dicY2[_ii] = _random.NextDouble();
        _dicY3[_ii] = _random.NextDouble();
    }
    _itemSource = _dicY1.Keys.Select(_k => new { XValue = _k, YValue1 = _dicY1[_k], YValue2 = _dicY2[_k], YValue3 = _dicY3[_k] }).OrderBy(_v => _v.XValue);
     
    _userControl.SignalsItemsSource = _itemSource;

    I have the X-Axis start from negative value, it is possibile configure RadChart to start from 0 or min value of X-Axis?

    Greetings,
    Paolo​​

  2. Dinko
    Admin
    Dinko avatar
    201 posts

    Posted 29 Oct 2015 Link to this post

    Hi Paolo,

    The range of the chart's axis (including its minimum) depends on the plotted data items. The minimum is determined by the minimum value plotted on Y axis, small tolerance and few other factors. In your case the values on the Y axis are generated randomly so the axis' minimum is always different.

    You can set the Y-axis minimum value by adding the XAML in the code snippet bellow:
    <telerik:ChartArea.AxisY>
        <telerik:AxisY AutoRange="False" MinValue="-5" MaxValue="200" />
    </telerik:ChartArea.AxisY>
    Also, you can read more about the Y-axis and X-axis properties and events in the axis Overview article.

    Instead of RadChart we recommend you to use the new RadChartView suite that resolves many known issues and limitations of the old chart. The new components have better implementation and improved performance. Furthermore, they are very flexible and easy to set up. You can read about the differences between the charts in the RadChart vs. RadChartView help article.

    If this is not the solution you are looking for please don't hesitate to contact us again.

    Regards,
    Dinko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alessandro
    Alessandro avatar
    4 posts
    Member since:
    Oct 2011

    Posted 30 Oct 2015 in reply to Dinko Link to this post

    It is possible to have an example that replicate this example from radchart to radchartview?

    Greetings,
    Paolo​​​

  5. Dinko
    Admin
    Dinko avatar
    201 posts

    Posted 04 Nov 2015 Link to this post

    Hi Alessandro,

    We have replicated the example above where you can see how to migrate from RadChart to RadChartView. You can get more information about LineSeries and RadChartView Palette colorization mechanism in our help documentation.

    Regards,
    Dinko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top