51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
|
|
// Copyright (c) Microsoft Corporation. All Rights Reserved.
|
|||
|
|
// Licensed under the MIT License.
|
|||
|
|
|
|||
|
|
using System;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Data;
|
|||
|
|
using System.Windows.Media;
|
|||
|
|
using InteractiveDataDisplay.WPF;
|
|||
|
|
|
|||
|
|
namespace LineGraphSample
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interaction logic for MainWindow.xaml
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class MainWindow : Window
|
|||
|
|
{
|
|||
|
|
public MainWindow()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
double[] x = new double[200];
|
|||
|
|
for (int i = 0; i < x.Length; i++)
|
|||
|
|
x[i] = 3.1415 * i / (x.Length - 1);
|
|||
|
|
|
|||
|
|
for (int i = 0; i < 25; i++)
|
|||
|
|
{
|
|||
|
|
var lg = new LineGraph();
|
|||
|
|
lines.Children.Add(lg);
|
|||
|
|
lg.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, (byte)(i * 10), 0));
|
|||
|
|
lg.Description = String.Format("Data series {0}", i + 1);
|
|||
|
|
lg.StrokeThickness = 2;
|
|||
|
|
lg.Plot(x, x.Select(v => Math.Sin(v + i / 10.0)).ToArray());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class VisibilityToCheckedConverter : IValueConverter
|
|||
|
|
{
|
|||
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
return ((Visibility)value) == Visibility.Visible;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
return ((bool)value) ? Visibility.Visible : Visibility.Collapsed;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|