This question is locked. New answers and comments are not allowed.
hi,
I was analysis zooming functionality.I found that Tooltip is not working.
I am pasting the code files here. Please let me know how can I resolve this issue.
Sample CS file: (I am only using the code from the Demo site)
XAML file:
I was analysis zooming functionality.I found that Tooltip is not working.
I am pasting the code files here. Please let me know how can I resolve this issue.
Sample CS file: (I am only using the code from the Demo site)
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Net; |
| using System.Windows; |
| using System.Windows.Controls; |
| using System.Windows.Documents; |
| using System.Windows.Input; |
| using System.Windows.Media; |
| using System.Windows.Media.Animation; |
| using System.Windows.Shapes; |
| using System.ComponentModel; |
| using Telerik.Windows.Controls.Charting; |
| namespace TelerikZoomTest |
| { |
| public partial class MainPage : UserControl |
| { |
| Random r = new Random(); |
| public MainPage() |
| { |
| InitializeComponent(); |
| this.ConfigureChart(); |
| this.FillSampleChartData(); |
| RadChart1.DefaultView.ChartArea.MouseMove += new MouseEventHandler(ChartArea_MouseMove); |
| } |
| void ChartArea_MouseMove(object sender, MouseEventArgs e) |
| { |
| } |
| private void FillSampleChartData() |
| { |
| List<TemperatureData> temperatureData = new List<TemperatureData>(); |
| DateTime baseDate = new DateTime(2000, 1, 1); |
| for (int year = 0; year < 12; year++) |
| { |
| for (int day = 0; day < 365; day++) |
| { |
| for (int hour = 0; hour < 24; hour++) |
| { |
| TemperatureData tempData = new TemperatureData(); |
| tempData.Temperature = TranslateTemperatureValue(CalculateBaseTemperatureValue(day)); |
| tempData.Date = baseDate.AddYears(year).AddDays(day).AddHours(hour); |
| temperatureData.Add(tempData); |
| } |
| } |
| } |
| RadChart1.ItemsSource = temperatureData; |
| } |
| private void ConfigureChart() |
| { |
| RadChart1.DefaultView.ChartArea.EnableAnimations = false; |
| RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart = 0.0; |
| RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 1.0; |
| RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.001; |
| RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom; |
| RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.PropertyChanged += ZoomScrollSettingsX_PropertyChanged; |
| RadChart1.DefaultView.ChartTitle.Content = "Temperature measurements for Sofia over 12 years"; |
| //RadChart1.DefaultView.ChartArea.AxisX.Title = "Time Period"; |
| RadChart1.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible; |
| RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMMM yyyy"; |
| RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 2; |
| RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelHeight = 15; |
| RadChart1.DefaultView.ChartArea.AxisY.AutoRange = false; |
| RadChart1.DefaultView.ChartArea.AxisY.AddRange(-15, 35, 5); |
| RadChart1.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Visible; |
| RadChart1.DefaultView.ChartArea.AxisY.MinorGridLinesVisibility = Visibility.Visible; |
| RadChart1.DefaultView.ChartArea.AxisY.Title = "Temperature in Celsius"; |
| AxisY fahrenheitAxis = new AxisY(); |
| fahrenheitAxis.AutoRange = false; |
| fahrenheitAxis.AddRange(5, 95, 9); |
| fahrenheitAxis.Title = "Temperature in Fahrenheit"; |
| RadChart1.DefaultView.ChartArea.AdditionalYAxes.Add(fahrenheitAxis); |
| SeriesMapping temperatureMapping = new SeriesMapping(); |
| LineSeriesDefinition lineDefinition = new LineSeriesDefinition(); |
| lineDefinition.ShowItemLabels = true; |
| lineDefinition.ShowItemToolTips = true; |
| lineDefinition.ShowPointMarks = true; |
| temperatureMapping.SeriesDefinition = lineDefinition; |
| temperatureMapping.ItemMappings.Add(new ItemMapping("Date", DataPointMember.XValue)); |
| temperatureMapping.ItemMappings.Add(new ItemMapping("Date", DataPointMember.Tooltip)); |
| ItemMapping yItemMapping = new ItemMapping("Temperature", DataPointMember.YValue); |
| yItemMapping.SamplingFunction = ChartSamplingFunction.Average; |
| temperatureMapping.ItemMappings.Add(yItemMapping); |
| temperatureMapping.LegendLabel = "Temperature"; |
| RadChart1.SeriesMappings.Add(temperatureMapping); |
| } |
| private void ZoomScrollSettingsX_PropertyChanged(object sender, PropertyChangedEventArgs e) |
| { |
| double range = (sender as ZoomScrollSettings).Range; |
| if (range > 0.7d) |
| { |
| RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "yyyy"; |
| RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 1; |
| } |
| else if (range > 1d / 12d) |
| { |
| RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMMM yyyy"; |
| RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 2; |
| } |
| else if (range > 1d / 12d / 30d) |
| { |
| RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd MMM yyyy"; |
| RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 2; |
| } |
| else |
| { |
| RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd-MMM (HH:mm)"; |
| RadChart1.DefaultView.ChartArea.AxisX.StepLabelLevelCount = 2; |
| } |
| } |
| private static double CalculateBaseTemperatureValue(int day) |
| { |
| return Math.Sin(day / 365d * 2 * Math.PI - Math.PI / 2); |
| } |
| private double TranslateTemperatureValue(double baseTemperatureValue) |
| { |
| return (baseTemperatureValue + 1) * 20 - 10 + r.Next(-5, 5); |
| } |
| public class TemperatureData |
| { |
| private DateTime _date; |
| private double _temperature; |
| public DateTime Date |
| { |
| get |
| { |
| return this._date; |
| } |
| set |
| { |
| this._date = value; |
| } |
| } |
| public double Temperature |
| { |
| get |
| { |
| return this._temperature; |
| } |
| set |
| { |
| this._temperature = value; |
| } |
| } |
| } |
| private void OneYear_Click(object sender, RoutedEventArgs e) |
| { |
| this.SetRange(1d / 12d); |
| } |
| private void SixMonths_Click(object sender, RoutedEventArgs e) |
| { |
| this.SetRange(1d / 24d); |
| } |
| private void OneMonth_Click(object sender, RoutedEventArgs e) |
| { |
| this.SetRange(1d / 144d); |
| } |
| private void OneWeek_Click(object sender, RoutedEventArgs e) |
| { |
| this.SetRange(1d / 625d); |
| } |
| private void SetRange(double newRange) |
| { |
| if (RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd + newRange > 1) |
| RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.SetSelectionRange(1 - newRange, 1); |
| else |
| RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeStart + newRange; |
| } |
| private void RadChart1_MouseMove(object sender, MouseEventArgs e) |
| { |
| } |
| } |
| } |
XAML file:
| <UserControl x:Class="TelerikZoomTest.MainPage" |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| mc:Ignorable="d" |
| xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" |
| xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" |
| > |
| <Grid> |
| <Grid.RowDefinitions> |
| <RowDefinition Height="*" /> |
| <RowDefinition Height="Auto" /> |
| </Grid.RowDefinitions> |
| <telerikChart:RadChart x:Name="RadChart1" |
| MouseMove="RadChart1_MouseMove" |
| /> |
| <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,5,0,0"> |
| <TextBlock Foreground="White" VerticalAlignment="Center" Text="Time Period: " /> |
| <Button Click="OneYear_Click" Content="1 Year" /> |
| <Button Click="SixMonths_Click" Content="6 Months" /> |
| <Button Click="OneMonth_Click" Content="1 Month" /> |
| <Button Click="OneWeek_Click" Content="1 Week" /> |
| </StackPanel> |
| </Grid> |
| </UserControl> |