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

Y-Axis IsLogarithmic Property and Pointmarks

3 Answers 136 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Taylor
Top achievements
Rank 1
Taylor asked on 03 Oct 2011, 06:41 PM
I have a chart which implements a Logarithmic Scale for the Y-Axis as described here:
http://www.telerik.com/help/wpf/radchart-features-axes-logarithmic-scale.html

I some cases, when the IsLogarithmic Property is toggled for Line Series types, the Point Marks become skewed.  The lines themselves seem to be plotted correctly, but the Point Marks will appear in their old positions.  This behavior only occurs for only certain data sets.

Below is an example which demonstrates the problem.

XAML:
<Window x:Class="LogarithmicScale.MainWindow"
        xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
        xmlns:telerikCharting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"            
        xmlns:example="clr-namespace:Telerik.Windows.Examples.Chart.LogarithmicScale"
        Title="MainWindow" Height="700" Width="900" WindowStartupLocation="CenterScreen">
 
    <Window.DataContext>
        <example:ExampleViewModel />
    </Window.DataContext>
 
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
 
        <CheckBox x:Name="ToggleLogModeCheckBox" Content="Use Logarithmic Y-Axis"
                  IsChecked="False" Margin="6" Grid.Row="0"
                  Checked="ToggleLogModeCheckBox_Checked"
                  Unchecked="ToggleLogModeCheckBox_Checked" />
 
        <telerikChart:RadChart x:Name="RadChart1" Grid.Row="1" ItemsSource="{Binding Data}">
            <telerikChart:RadChart.DefaultView>
                <telerikCharting:ChartDefaultView>
                    <telerikCharting:ChartDefaultView.ChartArea>
                        <telerikCharting:ChartArea LegendName="PrimaryLegend">
                            <telerikCharting:ChartArea.AxisX>
                                <telerikCharting:AxisX/>
                            </telerikCharting:ChartArea.AxisX>
                            <telerikCharting:ChartArea.AxisY>
                                <telerikCharting:AxisY x:Name="LogAxis"
                                         IsLogarithmic="False"
                                         Title="Total population" />
                            </telerikCharting:ChartArea.AxisY>
                        </telerikCharting:ChartArea>
                    </telerikCharting:ChartDefaultView.ChartArea>
                    <telerikCharting:ChartDefaultView.ChartLegend>
                        <telerikCharting:ChartLegend x:Name="PrimaryLegend"/>
                    </telerikCharting:ChartDefaultView.ChartLegend>
                </telerikCharting:ChartDefaultView>
            </telerikChart:RadChart.DefaultView>
            <telerikChart:RadChart.SeriesMappings>
                <telerikCharting:SeriesMapping CollectionIndex="0">
                    <telerikCharting:SeriesMapping.SeriesDefinition>
                        <telerikCharting:LineSeriesDefinition ShowItemLabels="False" />
                    </telerikCharting:SeriesMapping.SeriesDefinition>
                    <telerikCharting:SeriesMapping.ItemMappings>
                        <telerikCharting:ItemMapping FieldName="Population"
                                      DataPointMember="YValue" />
                        <telerikCharting:ItemMapping FieldName="Time"
                                      DataPointMember="XValue" />
                    </telerikCharting:SeriesMapping.ItemMappings>
                </telerikCharting:SeriesMapping>
                <telerikCharting:SeriesMapping CollectionIndex="1">
                    <telerikCharting:SeriesMapping.SeriesDefinition>
                        <telerikCharting:LineSeriesDefinition ShowItemLabels="False" />
                    </telerikCharting:SeriesMapping.SeriesDefinition>
                    <telerikCharting:SeriesMapping.ItemMappings>
                        <telerikCharting:ItemMapping FieldName="Population"
                                      DataPointMember="YValue" />
                        <telerikCharting:ItemMapping FieldName="Time"
                                      DataPointMember="XValue" />
                    </telerikCharting:SeriesMapping.ItemMappings>
                </telerikCharting:SeriesMapping>
            </telerikChart:RadChart.SeriesMappings>
        </telerikChart:RadChart>
    </Grid>
</Window>


Code Behind:
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
 
namespace LogarithmicScale
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
 
private void ToggleLogModeCheckBox_Checked(object sender, RoutedEventArgs e)
{
  if (this.RadChart1 != null)
  RadChart1.DefaultView.ChartArea.AxisY.IsLogarithmic = (bool)((CheckBox)sender).IsChecked;
}
 
}
}

View Model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
 
namespace Telerik.Windows.Examples.Chart.LogarithmicScale
{
    public class ExampleViewModel : ViewModelBase
    {
        private List<List<Stats>> data;
        public List<List<Stats>> Data
        {
            get
            {
                return this.data;
            }
            set
            {
                if (this.data != value)
                {
                    this.data = value;
                    this.NotifyPropertyChanged("Data");
                }
            }
        }
 
        public ExampleViewModel()
        {
            List<Stats> list0 = new List<Stats>();
            List<Stats> list1 = new List<Stats>();
            List<List<Stats>> listindex = new List<List<Stats>>();
 
            for (int i = 0; i <= 1000; i++)
                list0.Add(new Stats(i, 1 * i));
 
            for (int i = 0; i <= 1000; i++)
                list1.Add(new Stats(i, i * 10));
 
            listindex.Add(list0);
            listindex.Add(list1);
 
            this.Data = listindex;
        }
    }
 
    public class ViewModelBase : INotifyPropertyChanged, INotifyPropertyChanging
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public event PropertyChangingEventHandler PropertyChanging;
 
        protected void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
 
        protected void NotifyPropertyChanging(String info)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(info));
            }
        }
    }
}


Model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Telerik.Windows.Examples.Chart.LogarithmicScale
{
    public class Stats
    {
        private int _time;
        public int Time
        {
            get
            {
                return this._time;
            }
            set
            {
                this._time = value;   
            }
        }
 
        private int _population;
        public int Population
        {
            get
            {
                return this._population;
            }
            set
            {
                this._population = value;   
            }
        }
 
        public Stats(int time, int population)
        {
            this.Time = time;
            this.Population = population;
        }
    }
}


3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 06 Oct 2011, 07:41 AM
Hello Taylor,

We have been able to reproduce the issue locally and indeed the pointmarks do not update their positions correctly until the layout is updated as well ( resizing the window fixes the issue ). It has been logged for our developers to investigate further and provide a fix for one of the upcoming Latest Internal Builds, released each Monday.

Thank you for the feedback, your Telerik points have been updated.

All the best,
Nikolay
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Asutosh
Top achievements
Rank 1
answered on 01 Jul 2014, 08:04 AM
hi 
i am using following code to set logarithm in my radhtml chart but TYPE property for Yaxis in not valid showing there how to set that
<telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="800px" Height="400px">
    <PlotArea>
        <YAxis Type="Log" Step="10"></YAxis>
        <Series>
            <telerik:ColumnSeries>
                <LabelsAppearance Visible="false"></LabelsAppearance>
            </telerik:ColumnSeries>
        </Series>
    </PlotArea>
    <ChartTitle Text="Fibonacci Sequence"></ChartTitle>
</telerik:RadHtmlChart>
and also i have attached 1 image i want bar for .01 and .05 value
how can i get it

0
Pavel R. Pavlov
Telerik team
answered on 01 Jul 2014, 08:29 AM
Hello Asutosh,

You have actually reached the RadChart control for WPF. Please post your question in our UI ASPNET-AJAX forum.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Chart
Asked by
Taylor
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Asutosh
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Share this question
or