2013-02-28 113 views
2

我想知道如何更改我的d3 chartplotter的日期时间轴的颜色。WPF C#DynamicDataDisplay - 更改DateTimeAxis颜色

enter image description here

,我想改变颜色为褐色,两杆之间的白色背景颜色。

如果我这样做:

它只是改变了上述第一条褐色的东西。

enter image description here

是否有可能改变这两个栏的颜色?

回答

1

奇怪的是,我碰巧试图做同样的事情。事实证明,这些颜色是​​(我注意到下面的评论中的行)中的硬编码。如果您使用编译的DLL,那么无法更改这些值。就个人而言,D3非常不成熟,所以我保留自己的版本并进行更改以根据需要进行扩展(例如在这种情况下!)。

public override UIElement[] CreateLabels(ITicksInfo<DateTime> ticksInfo) 
{ 
    object info = ticksInfo.Info; 
    var ticks = ticksInfo.Ticks; 
    UIElement[] res = new UIElement[ticks.Length - 1]; 
    int labelsNum = 3; 

    if (info is DifferenceIn) 
    { 
     DifferenceIn diff = (DifferenceIn)info; 
     DateFormat = GetDateFormat(diff); 
    } 
    else if (info is MayorLabelsInfo) 
    { 
     MayorLabelsInfo mInfo = (MayorLabelsInfo)info; 
     DifferenceIn diff = (DifferenceIn)mInfo.Info; 
     DateFormat = GetDateFormat(diff); 
     labelsNum = mInfo.MayorLabelsCount + 1; 

     //DebugVerify.Is(labelsNum < 100); 
    } 

    DebugVerify.Is(ticks.Length < 10); 

    LabelTickInfo<DateTime> tickInfo = new LabelTickInfo<DateTime>(); 
    for (int i = 0; i < ticks.Length - 1; i++) 
    { 
     tickInfo.Info = info; 
     tickInfo.Tick = ticks[i]; 

     string tickText = GetString(tickInfo); 

     Grid grid = new Grid 
     { 
      Background = Brushes.Beige // **** HARD CODED HERE 
     }; 
     Rectangle rect = new Rectangle 
     { 
      Stroke = Brushes.Peru,  // **** AND HERE 
      StrokeThickness = 2 
     }; 
     Grid.SetColumn(rect, 0); 
     Grid.SetColumnSpan(rect, labelsNum); 

     for (int j = 0; j < labelsNum; j++) 
     { 
      grid.ColumnDefinitions.Add(new ColumnDefinition()); 
     } 

     grid.Children.Add(rect); 

     for (int j = 0; j < labelsNum; j++) 
     { 
      var tb = new TextBlock 
      { 
       Text = tickText, 
       HorizontalAlignment = HorizontalAlignment.Center, 
       Margin = new Thickness(0, 3, 0, 3) 
      }; 
      Grid.SetColumn(tb, j); 
      grid.Children.Add(tb); 
     } 

     ApplyCustomView(tickInfo, grid); 

     res[i] = grid; 
    } 

    return res; 
}