2017-05-15 20 views
2

私はLive ChartsのTimeDateの基本的な例をできるだけ詳しく追ってきましたが、X軸が適切に表示されないようです。私のメインウィンドウ基本的なWPF LiveCharts DateTimeの例が正しく動作しない

<Grid> 
    <lvc:CartesianChart x:Name="RankGraph" Series="{Binding Series}"> 
     <lvc:CartesianChart.AxisX> 
      <lvc:Axis LabelFormatter="{Binding Formatter}"></lvc:Axis> 
     </lvc:CartesianChart.AxisX> 
    </lvc:CartesianChart> 
</Grid> 

日モデルオブジェクト上

https://lvcharts.net/App/examples/v1/wpf/Date%20Time

私のメイン・ウィンドウコード

public partial class MainWindow : Window 
{ 
    public Func<double, string> Formatter { get; set; } 

    public MainWindow() 
    { 
     InitializeComponent(); 

     var dayConfig = Mappers.Xy<DateModel>() 
      .X(dateModel => dateModel.DateTime.Ticks/TimeSpan.FromDays(1).Ticks) 
      .Y(dateModel => dateModel.Value); 

     SeriesCollection Series = new SeriesCollection(dayConfig) 
     { 
      new LineSeries 
      { 
       Title = "Google Rank", 

       Values = new ChartValues<DateModel> 
       { 
        new Wpf.CartesianChart.Using_DateTime.DateModel 
        { 
         DateTime = System.DateTime.UtcNow, 
         Value  = 5 
        }, 
        new Wpf.CartesianChart.Using_DateTime.DateModel 
        { 
         DateTime = System.DateTime.UtcNow.AddDays(1), 
         Value  = 9 
        }, 
        new Wpf.CartesianChart.Using_DateTime.DateModel 
        { 
         DateTime = System.DateTime.UtcNow.AddDays(2), 
         Value  = 4 
        } 
       }, 

       Fill = Brushes.Transparent, 

      }, 
     }; 

     Formatter = value => new System.DateTime((long)(value * TimeSpan.FromDays(1).Ticks)).ToString("t"); 

     RankGraph.Series = Series; 
    } 
} 

私のXAML

namespace Wpf.CartesianChart.Using_DateTime 
{ 
    public class DateModel 
    { 
     public DateTime DateTime { get; set; } 
     public double Value { get; set; } 
    } 
} 

これはfolloを生成めちゃくちゃ日付の翼...

enter image description here

答えて

2

あなたのデータコンテキストを設定するのを忘れ:

DataContext = this; 

enter image description here

関連する問題