Hello Telerik,
I have a few problems with the chart.
Attached NO example. (!! we are unable to attach zip files)
Flickering:
When i set the 'DefaultView.ChartArea.AxisY.AutoRange' to TRUE, the chart flickers,
when set it to FALSE and specify the min/max/step value it does not have this problem,
but .... i would like to use the AutoRange function :)
Horizontal scroll/zoom:
- I cannot get this working, i think when setting the min/max values for the X axis, everything is reset?
Is there a solution for this behavior?
- When i start the application and press ALT-F4 (to close the application), it works,
when i first try to scroll/zoom the horizontal bar (or clicking on the slider), i cannot press ALT-F4 again, or any other common keyboard shortcuts.
With kind regards,
Rob
As we are unable to attach ZIP files, here the .cs code for the window (it only has one radchart)
Window.xaml
Window.xaml.cs
I have a few problems with the chart.
Attached NO example. (!! we are unable to attach zip files)
Flickering:
When i set the 'DefaultView.ChartArea.AxisY.AutoRange' to TRUE, the chart flickers,
when set it to FALSE and specify the min/max/step value it does not have this problem,
but .... i would like to use the AutoRange function :)
Horizontal scroll/zoom:
- I cannot get this working, i think when setting the min/max values for the X axis, everything is reset?
Is there a solution for this behavior?
- When i start the application and press ALT-F4 (to close the application), it works,
when i first try to scroll/zoom the horizontal bar (or clicking on the slider), i cannot press ALT-F4 again, or any other common keyboard shortcuts.
With kind regards,
Rob
As we are unable to attach ZIP files, here the .cs code for the window (it only has one radchart)
Window.xaml
<Window x:Class="TelerikChart.Window1" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" |
Title="Window1" Height="600" Width="800" |
Loaded="OnLoaded" |
> |
<Grid> |
<Grid.Resources> |
<Style x:Key="ItemLabelStyle" TargetType="TextBlock"> |
<Setter Property="Foreground" Value="Orange" /> |
</Style> |
</Grid.Resources> |
<telerikChart:RadChart x:Name="RadChart1" /> |
</Grid> |
</Window> |
Window.xaml.cs
using System; |
using System.Collections.Generic; |
using System.Linq; |
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; |
using Telerik.Windows.Controls.Charting; |
using System.Windows.Threading; |
namespace TelerikChart |
{ |
/// <summary> |
/// Interaction logic for Window1.xaml |
/// </summary> |
public partial class Window1 : Window |
{ |
private DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); |
private const int queueCapacity = 3600; |
private RadHierarchicalObservableCollection<ValueLoadInfo> ChartData = new RadHierarchicalObservableCollection<ValueLoadInfo>(); |
private Random rnd = new Random(); |
private DispatcherTimer timer1 = null; |
public Window1() |
{ |
InitializeComponent(); |
//Setup Chart |
RadChart1.DefaultView.ChartTitle.Content = "Legend Title"; |
RadChart1.DefaultView.ChartArea.NoDataString = "Waiting for data..."; |
RadChart1.DefaultView.ChartArea.EnableAnimations = false; |
//Setup X-As |
RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#VAL{HH:mm:ss}"; |
RadChart1.DefaultView.ChartArea.AxisX.LabelRotationAngle = 90; |
RadChart1.DefaultView.ChartArea.AxisX.LabelStep = 2; |
RadChart1.DefaultView.ChartArea.AxisX.Title = "Time"; |
RadChart1.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Normal; |
RadChart1.DefaultView.ChartArea.AxisX.AutoRange = false; |
//Setup Y-As |
RadChart1.DefaultView.ChartArea.AxisY.AutoRange = false; |
RadChart1.DefaultView.ChartArea.AxisY.MinValue = 38000; |
RadChart1.DefaultView.ChartArea.AxisY.MaxValue = 38001; |
RadChart1.DefaultView.ChartArea.AxisY.Step = 0.100; |
RadChart1.DefaultView.ChartArea.AxisY.AxisName = "Value"; |
RadChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{0.000}"; |
RadChart1.DefaultView.ChartArea.AxisY.Title = "Value (double)"; |
//Setup mapping |
SeriesMapping memoryDataMapping = new SeriesMapping(); |
memoryDataMapping.LegendLabel = "My Label"; |
memoryDataMapping.SeriesDefinition = new LineSeriesDefinition(); |
(memoryDataMapping.SeriesDefinition as LineSeriesDefinition).ShowPointMarks = false; |
(memoryDataMapping.SeriesDefinition as LineSeriesDefinition).ShowItemLabels = false; |
memoryDataMapping.SeriesDefinition.AxisName = "Value"; |
memoryDataMapping.ItemMappings.Add(new ItemMapping("Time", DataPointMember.XValue)); |
memoryDataMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue)); |
RadChart1.SeriesMappings.Add(memoryDataMapping); |
//Could not find Resource 'ItemLabelStyle' |
RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom; |
//RadChart1.DefaultView.ChartLegend.Visibility = Visibility.Collapsed; |
} |
private void OnLoaded(object sender, RoutedEventArgs e) |
{ |
//Start timer |
timer1 = new DispatcherTimer(); |
timer1.Interval = TimeSpan.FromMilliseconds(300); |
timer1.Tick += timer1_Tick; |
timer1.Start(); |
} |
private void SetUpAxisXRange(DateTime now) |
{ |
if (this.ChartData.Count() > 0) |
{ |
RadChart1.DefaultView.ChartArea.AxisX.MinValue = ChartData[0].Time.ToOADate(); |
RadChart1.DefaultView.ChartArea.AxisX.MaxValue = now.ToOADate(); |
double Range = RadChart1.DefaultView.ChartArea.AxisX.MaxValue - RadChart1.DefaultView.ChartArea.AxisX.MinValue; |
RadChart1.DefaultView.ChartArea.AxisX.Step = Range / 10.0; |
} |
} |
private void timer1_Tick(object sender, EventArgs e) |
{ |
if (this.ChartData.Count >= queueCapacity) |
this.ChartData.RemoveAt(0); |
this.nowTime = this.nowTime.AddMilliseconds(300); |
ValueLoadInfo systemInfo = new ValueLoadInfo(); |
systemInfo.Value = 38000 + (rnd.NextDouble()%1000); |
systemInfo.Time = this.nowTime; |
this.ChartData.Add(systemInfo); |
this.SetUpAxisXRange(this.nowTime); |
if (RadChart1.ItemsSource == null) |
RadChart1.ItemsSource = this.ChartData; |
} |
} |
public class ValueLoadInfo |
{ |
private DateTime _time; |
private double _Value; |
public DateTime Time |
{ |
get { return this._time; } |
set { this._time = value; } |
} |
public double Value |
{ |
get { return this._Value; } |
set { this._Value = value; } |
} |
} |
} |