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

Value under 0 when AxisY.Minimum is positive

1 Answer 38 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 14 Mar 2012, 09:46 PM
Was working with some data and I noticed some bug when the YValue of a point is negative while the minimum of an axis is positive.

I made a demo to reproduce the bug

xaml:
<Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
         
        <telerik:RadChart ItemsSource="{Binding Points}" >
            <telerik:RadChart.DefaultView>
                <telerik:ChartDefaultView>
                    <telerik:ChartDefaultView.ChartLegend>
                        <telerik:ChartLegend Visibility="Collapsed"/>
                    </telerik:ChartDefaultView.ChartLegend>
                    <telerik:ChartDefaultView.ChartArea>
                        <telerik:ChartArea >
                            <telerik:ChartArea.AxisX>
                                <telerik:AxisX MinValue="{Binding MinX}" MaxValue="{Binding MaxX}" AutoRange="False" Step="{Binding StepX}" />
                            </telerik:ChartArea.AxisX>
                            <telerik:ChartArea.AxisY>
                                <telerik:AxisY MinValue="{Binding MinY}" MaxValue="{Binding MaxY}" AutoRange="False" Step="{Binding StepY}" StripLinesVisibility="Collapsed"/>
                            </telerik:ChartArea.AxisY>
                        </telerik:ChartArea>
                    </telerik:ChartDefaultView.ChartArea>
                </telerik:ChartDefaultView>
            </telerik:RadChart.DefaultView>
            <telerik:RadChart.SeriesMappings>
                <telerik:SeriesMapping LegendLabel="Line">
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:LineSeriesDefinition ShowItemLabels="False">
                            <telerik:LineSeriesDefinition.Appearance>
                                <telerik:SeriesAppearanceSettings>
                                    <telerik:SeriesAppearanceSettings.PointMark>
                                        <telerik:PointMarkAppearanceSettings Shape="Diamond" />
                                    </telerik:SeriesAppearanceSettings.PointMark>
                                </telerik:SeriesAppearanceSettings>
                            </telerik:LineSeriesDefinition.Appearance>
                        </telerik:LineSeriesDefinition>
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:SeriesMapping.ItemMappings>
                        <telerik:ItemMapping FieldName="Item1" DataPointMember="XValue"/>
                        <telerik:ItemMapping FieldName="Item2" DataPointMember="YValue"/>
                    </telerik:SeriesMapping.ItemMappings>
                </telerik:SeriesMapping>
                <telerik:SeriesMapping LegendLabel="Line">
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:LineSeriesDefinition ShowItemLabels="False">
                            <telerik:LineSeriesDefinition.Appearance>
                                <telerik:SeriesAppearanceSettings>
                                    <telerik:SeriesAppearanceSettings.PointMark>
                                        <telerik:PointMarkAppearanceSettings Shape="Diamond" />
                                    </telerik:SeriesAppearanceSettings.PointMark>
                                </telerik:SeriesAppearanceSettings>
                            </telerik:LineSeriesDefinition.Appearance>
                        </telerik:LineSeriesDefinition>
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:SeriesMapping.ItemMappings>
                        <telerik:ItemMapping FieldName="Item1" DataPointMember="XValue"/>
                        <telerik:ItemMapping FieldName="Item4" DataPointMember="YValue"/>
                    </telerik:SeriesMapping.ItemMappings>
                </telerik:SeriesMapping>
            </telerik:RadChart.SeriesMappings>
        </telerik:RadChart>
         
        <Slider Grid.Row="1" Value="{Binding MinY, Mode=TwoWay}" Minimum="-10" Maximum="10" SmallChange=".5" LargeChange="5"/>
    </Grid>

ViewModel:
public class ViewModel : INotifyPropertyChanged
    {
 
        private double _minY = -10;
        private double _maxY = 50;
        private double _stepY = 10;
 
        private double _minX = 0;
        private double _maxX = 50;
        private double _stepX = 10;
 
        public ViewModel()
        {
            MaxY = 50;
            StepY = 10;
            MinX = 0;
            MaxX = 50;
            StepX = 10;
 
            Points = new ObservableCollection<Tuple<double, double, double, double>>();
 
            Random r = new Random();
 
            Points.Add(Tuple.Create(.1, -8d, 1d, 5d));
 
            for (double i = 20; i < 50; i += 4)
            {
                Points.Add(Tuple.Create(i, i - 8, (i - 5) + (r.NextDouble() * 9 - 4.5), i - 25));
            }
        }
 
        public ObservableCollection<Tuple<double, double, double, double>> Points { get; private set; }
 
        public double MinX { get; private set; }
 
        public double MaxX { get; private set; }
 
        public double StepX { get; private set; }
 
        public double MinY
        {
            get
            {
                return _minY;
            }
            set
            {
                _minY = value;
                OnPropertyChanged("MinY");
            }
        }
 
        public double MaxY { get; private set; }
 
        public double StepY { get; private set; }
 
        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
    }



The slider bar changes the Minimum of the AxisY and as soon as the minimum hit 0, you can see that the line are now rendered as if the YValue of the point was 0.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 19 Mar 2012, 09:52 AM
Hello Julien,

Thank you for the provided demo example, we have been able to reproduce this behavior, the issue has been logged and our developers have been notified.

I have also updated your Telerik points for the feedback.

Greetings,
Nikolay
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Chart
Asked by
Julien
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or