Search code examples
c#wpfdynamic-data-display

Setting y-axis range using Interactive data display WPF


I'm stuck on a problem where i need to set y-axis based on its plot. Right now program stretches the plot to fit whole chart however i need it to let some free space above the plot. I wasn't able to come up with anything so far. Code looks like this:

Chart chart = new Chart()
{
    LegendVisibility = Visibility.Hidden,
    LeftTitle = YaxisName[i],
    BottomTitle = "Carrier i [-]",                      
};
chart.Content = getChart(graphIndex, GraphYvalues, GraphXvalues, GraphListOfNames[graphIndex]);
chartView.Children.Add(chart);

Could someone please help me out? Thank you


Solution

  • Eventually I was able to scramble something up. It's actually so damn easy. I gave up on setting the range of y-axis and instead of that I added padding to the plot itself like this:

    LineGraph lineGraphFar = new LineGraph()
    {
        Stroke = new SolidColorBrush(Colors.Red),
        Padding = new System.Windows.Thickness(0, 30, 0, 0)
    };
    

    It's surely not the greatest option but it will do the job.