question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with rendering the graph

See original GitHub issue

@beto-rodriguez Hi I installed the beta release 2.0.0-beta.32

And tried out the below code, but the graph is not visible. What am I missing? *.xaml

<Page x:Class="Test.LVC2"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:Test"
      xmlns:lvc2="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="LVC2">

    <Grid>
        <lvc2:CartesianChart Name="LVC2_Chart" Series="{Binding Series}"></lvc2:CartesianChart>
    </Grid>
</Page>

*.xaml.cs

using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;

namespace Test
{
    public partial class LVC2 : Page
    {
        public IEnumerable<ISeries> Series ;

        public LVC2()
        {
            InitializeComponent();
            Series= new ObservableCollection<ISeries>
            {
                new LineSeries<double>
                {
                    Values = new ObservableCollection<double> { 2, 1, 3, 5, 3, 4, 6 },
                    Fill = null
                }
            }
        }
    }
}

And from main window, on tab change event, I do the following

if (LVC2Tab.IsSelected)
       ContentFrame.NavigationService.Navigate(new LVC2());

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
LabuzzMichalcommented, Jul 21, 2021

Ohhh ok I see It. At first I didnt pay attention to your Series field. And thats the reason. Its a field but need to be property! Here you can find more information about difference between fields and properties: LINK

Just to be clear: Its not at all related to LiveCharts library. Its related to C#, WPF and its binding mechanism. Basically if you want binding to work you need to use property instead of a field. So instead of:

public IEnumerable<ISeries> Series;

it should rather be:

public IEnumerable<ISeries> Series {get; set;}

Then everything works fine 😃 However you can still have it working with a field but then you need to use reference to control. Example below:

<Page x:Class="Test.LVC2"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:Test"
      xmlns:lvc2="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="LVC2">

    <Grid>
        <lvc2:CartesianChart Name="LVC2_Chart"></lvc2:CartesianChart>
    </Grid>
</Page>
   public partial class LVC2 : Page
   {
       public IEnumerable<ISeries> Series;

       public LVC2()
       {
           InitializeComponent();
           Series= new ObservableCollection<ISeries>
           {
               new LineSeries<double>
               {
                   Values = new ObservableCollection<double> { 2, 1, 3, 5, 3, 4, 6 },
                   Fill = null
               }
           };
           LVC2_Chart.Series = Series;
       }
   }

BTW: sometimes binding might be tricky but Visual Studio introduced nice feature helping people get around it. image This red icon at the top of the image tells you that you have a problem with binding somewhere. Just click it to get more information.

Good luck!

1reaction
LabuzzMichalcommented, Jul 15, 2021

You are not setting datacontext for your binding as far as I see

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem when rendering graphs - Maybe a bug
I have developed a COVID-19 web app and I realized that on the “Forecasting” tab it renders the Total Cases graph but when...
Read more >
has anyone else been having trouble w/ their graph view ...
I used to have issues with the graph, i found it was the Persistent Graph plugin that was causing it. I uninstalled and...
Read more >
Error rendering the graph on DOM. #408 - dagrejs/dagre-d3
var svg = d3.select('svg'); var inner = svg.select('g'); var graphRender = new dagreD3.render();. the line of code that is issuing this error:.
Read more >
Issue while rendering d3 graph in html page
I am trying to render d3 graph with html, when i open the page in laptop browser it's working perfect, But when i...
Read more >
Problem with rendering graph - Oracle Forums
Hi OTN, In my ADF BC application I have a requirement of displaying data in a barGraph. Also I need to apply some...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found