or
| <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> |
| 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; } |
| } |
| } |
| } |
private void fullyLoadedCostListRadGridView_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e) {
e.Column.CellTemplate = (DataTemplate)FindResource("telerikContentColumnTemplate");
}
private void gvCount_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e) { //if edit editing on Quantity cell, then position focus to product code -- edit end typically comes from when tab key is clicked if (e.Cell.Column.UniqueName == "Quantity") { txtProductCode.Focus(); } }| <Grid> |
| <Grid.RowDefinitions> |
| <RowDefinition Height="0.913*"/> |
| </Grid.RowDefinitions> |
| <Expander Grid.Row="1" |
| Header="Berthing Slots" |
| IsExpanded="True" |
| VerticalAlignment="Top" Margin="0,4.988,0,0"> |
| <telerik:RadGridView x:Name="radBerthingSlots" |
| AutoGenerateColumns="False" |
| IsEnabled="True" |
| ItemsSource="{Binding BerthingSlots}" |
| SelectedItem="{Binding SelectedBerthingSlot, Mode=TwoWay}" |
| AddingNewDataItem="radBerthingSlots_AddingNewDataItem" |
| RowEditEnded="radBerthingSlots_RowEditEnded" Deleting="radBerthingSlots_Deleting"> |
| <telerik:RadGridView.Columns> |
| <telerik:GridViewCheckBoxColumn Header="Available" DataMemberBinding="{Binding Path=HtDiff, Converter={StaticResource HtDiffNumberConverter}, Mode=TwoWay}" /> |
| <telerik:GridViewDataColumn Header="HT Diff" DataMemberBinding="{Binding Path=HtDiff, Converter={StaticResource HtDiffNumberConverter}, Mode=TwoWay}" /> |
| </telerik:RadGridView.Columns> |
| </telerik:RadGridView> |
| </Grid> |
this
.calPaydate.SelectedDate = null;
this.calPayDate.displaydate = ?????
thx
