RadCartesianChart change axis lose data

8 posts, 0 answers
  1. BobK
    BobK avatar
    7 posts
    Member since:
    Dec 2014

    Posted 07 Nov 2015 Link to this post

    Hello,

    Using RadCartesianChart with three LineSeries as below, ItemsSource bound to three members of ObservableCollection<prodnMonthly>.  Charts display nicely with initial LinearAxis, but when axes are programmatically changed to LogarithmicAxis, data disappears and no vertical axis values are shown.  Horizontal axis values are displayed correctly throughout.

    Guidance would be appreciated!

    Regards,
    Bob

                          <telerik:RadCartesianChart Grid.Row="2" x:Name="ProdnChart" Margin="10" Background="White"
                                                       Visibility="{Binding IsSelectedEntityProductionData, Converter={StaticResource BoolToVisibilityConverter}}">
                                                   
                                <telerik:RadCartesianChart.HorizontalAxis >
                                    <telerik:DateTimeContinuousAxis x:Name="ProdnChartHorAxis" LabelFitMode="Rotate" LastLabelVisibility="Clip" LabelFormat="MMM-yy"
                                        Minimum="{Binding ElementName=ProdnTimeBar, Path=SelectionStart}" Maximum="{Binding ElementName=ProdnTimeBar, Path=SelectionEnd}"
                                                                    MajorStepUnit="Month" />
                                </telerik:RadCartesianChart.HorizontalAxis>
                                <!-- Tooltip -->
                                <telerik:RadCartesianChart.Behaviors>
                                    <telerik:ChartTooltipBehavior Placement="Top" VerticalOffset="0"  />
                                </telerik:RadCartesianChart.Behaviors>
                              
                                <telerik:RadCartesianChart.TooltipTemplate>
                                    <DataTemplate>
                                        <Border Background="White" BorderBrush="Black" BorderThickness="1" CornerRadius="2">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="Auto" />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                               
                                                <Border Grid.Row="0" Grid.ColumnSpan="3" BorderBrush="Black" BorderThickness="0,0,0,1" >
                                                    <TextBlock Text="{Binding DataItem.ProductionDate, StringFormat='yyyy MMMMM'}" FontWeight="Black" HorizontalAlignment="Center" Margin="0,3,0,3" />
                                                </Border>
                                                <TextBlock Grid.Row="1" Grid.Column="0" Text="Oil:" Margin="5,3,5,0"/>
                                                <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding DataItem.Oil, StringFormat='#,0'}" HorizontalAlignment="Right" Margin="5,3,3,0" />
                                                <TextBlock Grid.Row="1" Grid.Column="2" Text="BBL" Margin="0,3,5,0"/>
                                                <TextBlock Grid.Row="2" Grid.Column="0" Text="Gas:" Margin="5,0,5,0"/>
                                                <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding DataItem.Gas, StringFormat='#,0'}" HorizontalAlignment="Right" Margin="5,0,3,0" />
                                                <TextBlock Grid.Row="2" Grid.Column="2" Text="MCF" Margin="0,0,5,0"/>
                                                <TextBlock Grid.Row="3" Grid.Column="0" Text="Water:" Margin="5,0,5,3"/>
                                                <TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding DataItem.Water, StringFormat='#,0'}" HorizontalAlignment="Right" Margin="5,0,3,3" />
                                                <TextBlock Grid.Row="3" Grid.Column="2" Text="BBL" Margin="0,0,5,3"/>
                                            </Grid>
                                        </Border>
                                    </DataTemplate>
                                </telerik:RadCartesianChart.TooltipTemplate>
                                <telerik:RadCartesianChart.Grid>
                                    <telerik:CartesianChartGrid MajorLinesVisibility="XY" />
                                </telerik:RadCartesianChart.Grid>
                               
                                <telerik:RadCartesianChart.Annotations >
                                    <telerik:CartesianGridLineAnnotation
                                        Axis="{Binding ElementName=ProdnChart, Path=HorizontalAxis}"
                                        Value="01/01/1960" Stroke="Tomato" StrokeThickness="3"
                                        ToolTipService.ToolTip="Well test Jan 1960"/>
                                   
                                </telerik:RadCartesianChart.Annotations>
                               
                               
                               
                                <telerik:RadCartesianChart.Series >
                                            
                                    <!-- Gas -->
                                    <telerik:LineSeries  x:Name="GasSeries" Stroke="Red" StrokeThickness="1"
                                                         ItemsSource="{Binding prodnMonthlies}" ValueBinding="Gas"
                                                         CategoryBinding="ProductionDate"
                                                         VerticalAxis="{Binding SelectedVerticalAxisOption.GasAxis}"                                                    
                                                         >
                                       
                                        <telerik:LineSeries.PointTemplate>
                                            <DataTemplate>
                                                <Ellipse Height="4" Width="4" Fill="Red" />
                                            </DataTemplate>
                                        </telerik:LineSeries.PointTemplate>
                                        <telerik:LineSeries.LegendSettings>
                                            <telerik:SeriesLegendSettings Title="Gas" />
                                        </telerik:LineSeries.LegendSettings>
                                    </telerik:LineSeries>
                                    <!-- Oil -->
                                    <telerik:LineSeries  x:Name="OilSeries" Stroke="DarkGreen" StrokeThickness="1"
                                                         ItemsSource="{Binding prodnMonthlies}" ValueBinding="Oil"
                                                         CategoryBinding="ProductionDate"
                                                         VerticalAxis="{Binding SelectedVerticalAxisOption.OilAxis}"
                                                         >
                                        <telerik:LineSeries.PointTemplate>
                                            <DataTemplate>
                                                <Ellipse Height="4" Width="4" Fill="DarkGreen" />
                                            </DataTemplate>
                                        </telerik:LineSeries.PointTemplate>
                                        <telerik:LineSeries.LegendSettings>
                                            <telerik:SeriesLegendSettings Title="DarkGreen" />
                                        </telerik:LineSeries.LegendSettings>
                                    </telerik:LineSeries>
                                    <!-- Water -->
                                    <telerik:LineSeries  x:Name="WaterSeries" Stroke="Blue" StrokeThickness="0.7"
                                                         ItemsSource="{Binding prodnMonthlies}" ValueBinding="Water"
                                                         CategoryBinding="ProductionDate"
                                                         VerticalAxis="{Binding SelectedVerticalAxisOption.WaterAxis}"
                                                         >
                                        <telerik:LineSeries.PointTemplate>
                                            <DataTemplate>
                                                <Ellipse Height="3" Width="3" Fill="Blue" />
                                            </DataTemplate>
                                        </telerik:LineSeries.PointTemplate>
                                        <telerik:LineSeries.LegendSettings>
                                            <telerik:SeriesLegendSettings Title="Blue" />
                                        </telerik:LineSeries.LegendSettings>
                                    </telerik:LineSeries>
                                </telerik:RadCartesianChart.Series>
                               
                                <!-- Chart Context Menu -->
                                <telerik:RadContextMenu.ContextMenu>
                                    <telerik:RadContextMenu>
                                        <!-- Vertical Axis -->
                                        <telerik:RadMenuItem Header="Axis">
                                           
                                            <telerik:RadMenuItem Header="Linear"
                                                IsCheckable="False" IsChecked="{Binding SelectedVerticalAxisOption.Label, Converter={StaticResource StringEqualityToBoolConverter}, ConverterParameter='Linear'}"
                                                ToolTipService.ToolTip="Click for a linear vertical axis"
                                                Command="{Binding ChartContextMenuAxisCommand}" CommandParameter="Linear"/>
                                           
                                            <telerik:RadMenuItem Header="Logarithmic"
                                                IsCheckable="False" IsChecked="{Binding SelectedVerticalAxisOption.Label, Converter={StaticResource StringEqualityToBoolConverter}, ConverterParameter='Logarithmic'}"              
                                                ToolTipService.ToolTip="Click for a linear vertical axis"
                                                Command="{Binding ChartContextMenuAxisCommand}" CommandParameter="Logarithmic"/>
                                           
                                        </telerik:RadMenuItem>   
                                    </telerik:RadContextMenu>
                                </telerik:RadContextMenu.ContextMenu>
                            </telerik:RadCartesianChart>


          public class prodnMonthly : INotifyPropertyChanged
            {
                private string _entity;
                private DateTime _productionDate;
                private int _gas;
                private int _oil;
                private int _water;
                private int _bOE;
                private double _percentWater;
                private double _ratioGasOil;
                private int _monthsInProduction;
                private double? _oilDecline;
                private double? _gasDecline;

                public string Entity
                {
                    get
                    {
                        return _entity;
                    }
                    set
                    {
                        if (value != _entity)
                        {
                            _entity = value;
                            RaisePropertyChanged("Entity");
                        }
                    }
                }
                public DateTime ProductionDate
                {
                    get
                    {
                        return _productionDate;
                    }
                    set
                    {
                        if (value != _productionDate)
                        {
                            _productionDate = value;
                            RaisePropertyChanged("ProductionDate");
                        }
                    }
                }
                public int Gas
                {
                    get
                    {
                        return _gas;
                    }
                    set
                    {
                        if (value != _gas)
                        {
                            _gas = value;
                            RaisePropertyChanged("Gas");
                        }
                    }
                }
                public int Oil
                {
                    get
                    {
                        return _oil;
                    }
                    set
                    {
                        if (value != _oil)
                        {
                            _oil = value;
                            RaisePropertyChanged("Oil");
                        }
                    }
                }
                public int Water
                {
                    get
                    {
                        return _water;
                    }
                    set
                    {
                        if (value != _water)
                        {
                            _water = value;
                            RaisePropertyChanged("Water");
                        }
                    }
                }
                public int BOE
                {
                    get
                    {
                        return _bOE;
                    }
                    set
                    {
                        if (value != _bOE)
                        {
                            _bOE = value;
                            RaisePropertyChanged("BOE");
                        }
                    }
                }
                public double PercentWater
                {
                    get
                    {
                        return _percentWater;
                    }
                    set
                    {
                        if (value != _percentWater)
                        {
                            _percentWater = value;
                            RaisePropertyChanged("PercentWater");
                        }
                    }
                }
                public double RatioGasOil
                {
                    get
                    {
                        return _ratioGasOil;
                    }
                    set
                    {
                        if (value != _ratioGasOil)
                        {
                            _ratioGasOil = value;
                            RaisePropertyChanged("RatioGasOil");
                        }
                    }
                }
                public int MonthsInProduction
                {
                    get
                    {
                        return _monthsInProduction;
                    }
                    set
                    {
                        if (value != _monthsInProduction)
                        {
                            _monthsInProduction = value;
                            RaisePropertyChanged("MonthsInProduction");
                        }
                    }
                }
                public double? OilDecline
                {
                    get
                    {
                        return _oilDecline;
                    }
                    set
                    {
                        if (value != _oilDecline)
                        {
                            _oilDecline = value;
                            RaisePropertyChanged("OilDecline");
                        }
                    }
                }
                public double? GasDecline
                {
                    get
                    {
                        return _gasDecline;
                    }
                    set
                    {
                        if (value != _gasDecline)
                        {
                            _gasDecline = value;
                            RaisePropertyChanged("GasDecline");
                        }
                    }
                }
                public event PropertyChangedEventHandler PropertyChanged;
                protected void RaisePropertyChanged(string _name)
                {
                    PropertyChangedEventHandler handler = PropertyChanged;
                    if (handler != null)
                    {
                        handler(this, new PropertyChangedEventArgs(_name));
                    }
                }
                public prodnMonthly(string _entity, DateTime _pdate, int _oil, int _gas, int _water, int _boe,
                                  double _ratioGasOil, double _percentWater, int _monthsInProduction)
                {
                    Entity = _entity;
                    ProductionDate = _pdate;
                    Oil = _oil;
                    Gas = _gas;
                    Water = _water;
                    BOE = _boe;
                    RatioGasOil = _ratioGasOil;
                    PercentWater = _percentWater;
                    MonthsInProduction = _monthsInProduction;
                    OilDecline = null;
                    GasDecline = null;
                }
            }

     

  2. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 11 Nov 2015 Link to this post

    Hi Bob,

    What do you mean by saying that the vertical axis values are disappearing? Are you referencing the axis' labels and ticks? If so, it seems that there is an issue in the chart's implementation which leads to such behavior. Basically, if you set the VerticalAxis property of a series, then set it to another axis instance, and after that set it to the previous axis,  the labels and ticks will be missing. I logged a report in our feedback portal about this issue. You can track its status there. I also updated your Telerik points as a small gesture of gratitude for reporting this.

    As a workaround, you can set a new axis instance every time you change the series' axis, instead of reusing the same instances.

    If this is not your case, can you please elaborate a little more and send me a sample project isolating the observed behavior along with a small description of the issue and steps to reproduce it.

    Thank you for any help you can provide.

    Regards,
    Martin
    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. BobK
    BobK avatar
    7 posts
    Member since:
    Dec 2014

    Posted 11 Nov 2015 in reply to Martin Link to this post

    Hello, Martin,

    Thanks for the guidance.  Changed logic so that axes are "new" each time they change -- and the behavior did change. 

    Now the Linear axes always work (even when switch back and forth), but the Logarithmic axes NEVER work (even when they are the first-used axes).  Please see attached screen snapshot for the logarithmic result -- horizontal (date) axis is OK, but vertical axis labels and ticks are missing -- as are the data series.

    Is there something wrong with my axis definition, which is:

    case "LOGARITHMIC":
         GasAxis = new Telerik.Windows.Controls.ChartView.LogarithmicAxis() { ElementBrush = Brushes.Red, Minimum = 0, LineThickness = 1, HorizontalLocation = Telerik.Charting.AxisHorizontalLocation.Right,
    LogarithmBase=10, Maximum=10000 };

         OilAxis = new Telerik.Windows.Controls.ChartView.LogarithmicAxis() { ElementBrush = Brushes.DarkGreen, Minimum = 0, LineThickness = 1, HorizontalLocation = Telerik.Charting.AxisHorizontalLocation.Left,
    LogarithmBase=10, Maximum=10000 };

         WaterAxis = new Telerik.Windows.Controls.ChartView.LogarithmicAxis() { ElementBrush = Brushes.Blue, Minimum = 0, LineThickness = 1, HorizontalLocation = Telerik.Charting.AxisHorizontalLocation.Left,
    LogarithmBase=10, Maximum=10000 };
                               

    Thanks again for the help,

    Bob

     

     

  5. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 12 Nov 2015 Link to this post

    Hello Bob,

    I wasn't able to reproduce the described behavior. The axes are working as expected. Can you please take a look at the attached project ans let me know if I am missing something?

    Regards,
    Martin
    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
  6. BobK
    BobK avatar
    7 posts
    Member since:
    Dec 2014

    Posted 12 Nov 2015 in reply to Martin Link to this post

    Hello, Martin,

    THANK YOU for the sample project.

    The sample project exhibits the described (failing) behavior on my system.  When linear selected, display is complete and correct.  When logarithmic selected, horizontal axis labels and tics are present, but vertical axes have no labels or tic marks and data series are not displayed.  It almost looks like the vertical scale lines are extending through the top of the window?

    Images from both (linear and logarithmic) states are attached.

    FYI, my system is Windows 7 SP1. 

    Thanks again,
    Bob

     

  7. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 17 Nov 2015 Link to this post

    Hi Bob,

    Can you elaborate a bit more on your case by answering the following questions:
    • What version of UI for WPF you are using?
    • What are the steps to reproduce the issue in the project from my last reply?
    If you think of any other information which you consider helpful you can share it with me.

    Regards,
    Martin
    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
  8. BobK
    BobK avatar
    7 posts
    Member since:
    Dec 2014

    Posted 17 Nov 2015 in reply to Martin Link to this post

    Hello, Martin,

    Thank you for your reply.

    I am using 2015.3.1104.45 with the project configured .Net Framework 4.5.

    Using the test project, I was able to discover that the problem occurs only when "Minimum=0" is specified while instantiating the LogarithmicAxis object.  When I remove "Minimum=0", the display is correct.

    I have removed "Minimum=0" from my original project and it also works correctly.

    Problem solved!  Thank you again for all your help. 

    Regards,
    Bob 

     

     

     

     

     

     

  9. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 20 Nov 2015 Link to this post

    Hi Bob,

    Thank you for the additional information. It helped me to reproduce the described behavior. I can confirm that this is caused by setting the axis' Minimum property to 0. This happens because log of zero is undefined and the chart doesn't know where to render it on the axis. 

    In order to resolve this you can set the Minimum to a property different than 0. Or you can skip setting the Maximum property and leave the axis to define its range automatically.

    As a side note, the chartview behaved differently in this scenario in the UI for WPF versions before Q3 2015 SP (2015.3 1104). Before that, if you set the Minimum of a LogarithmicAxis to 0 the chart coerces this value to a more reasonable one (in your case to 1). In Q3 2015 SP1, we introduced a change in the behavior of Logarithmic axis that concerns non-positives values (as zero), which brings the behavior which you are experiencing. We will think of returning the old behavior (or similar one) that coerces the value so that the data is displayed correctly.

    Regards,
    Martin
    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
UI for WPF is Visual Studio 2017 Ready