Rendering two LineSeries without being scaled
I have 2 line series-es, one which follow the other in its data, they both represent month days, for example:
1st Series:
1 2 3 4 5 6 72开发者_运维百科nd Series:
1 2 3 4 5 6 7 8 ... 29 30 31The first series is always contained in (or equals to) the second one.
I want to represent these two series-es on a Line Chart, in a way that the first series is not scaled up on the full chart width (7 / 31 ~= 0.25, so it must occupy the first horizontal quarter of the X axis).
So, I think I need some kind of a Chart Axis which will render the 31 days and then the 2 series-es will follow that axis and be rendered according to it. (without scaling the 1st series to fill all the horizontal space of the X axis).
It seems to be quite simple.
Here is the screenshot, 7 blue points represent the 1st series, 31 red points - the 2nd series. Check if it is that what you need

If the chart is displayed right, here is its source code:
XAML
    <chart:Chart>
        <chart:LineSeries ItemsSource="{Binding FirstWeekItems}" 
                          IndependentValueBinding="{Binding Day}" 
                          DependentValueBinding="{Binding Value}" />
        <chart:LineSeries ItemsSource="{Binding MonthItems}" 
                          IndependentValueBinding="{Binding Day}" 
                          DependentValueBinding="{Binding Value}" />
    </chart:Chart>
Code-behind
public partial class MainPage : UserControl
{
    public MainPage()
    {
        this.InitializeComponent();
        Random rd = new Random();
        var vm = new ChartModel
        {
            FirstWeekItems = Enumerable.Range(1,7).Select(i => new ItemViewModel{Day = i, Value = rd.Next(23,25)}).ToList(),
            MonthItems = Enumerable.Range(1, 31).Select(i => new ItemViewModel { Day = i, Value = 20+i }).ToList()
        };
        this.DataContext = vm;
    }
}
public class ChartModel
{
    public List<ItemViewModel> FirstWeekItems { get; set; }
    public List<ItemViewModel> MonthItems { get; set; }
}
public class ItemViewModel
{
    public int Day { get; set; }
    public double Value { get; set; }
}
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论