We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Chart Empty and 1 question

Hello
I have 2 problems with my application and SFCHART and 1 question.

1) When I open my application and click the "buttonFacture" in MainPage.xaml,  columns are empty in MainFacturePage.xaml

XAML

 <syncfusion:ColumnSeries ItemsSource="{Binding Facture}"
                                     XBindingPath="Annee"
                                     YBindingPath="Montant"
                                     Label="Factures en €">
              
                <syncfusion:ColumnSeries.AdornmentsInfo>
                    <syncfusion:ChartAdornmentInfo ShowConnectorLine="True"
                                                   ConnectorHeight="10"
                                                   ConnectorRotationAngle="90"
                                                   ShowLabel="True"
                                                   LabelRotationAngle="45"
                                                   LabelPosition="Outer"/>               
                </syncfusion:ColumnSeries.AdornmentsInfo>
            </syncfusion:ColumnSeries>

CS

public MainFacturePage()
        {
            this.InitializeComponent();
        }

        public class FacturesAnnuelle
        {
            public string Annee { get; set; }
            public double Montant { get; set; }
        }

        public static ObservableCollection<FacturesAnnuelle> Facture { get; set; }

        public class ViewModel
        {
            public ViewModel()
            {
                Facture = new ObservableCollection<FacturesAnnuelle>();
                Facture.Add(new FacturesAnnuelle() { Annee = "2010", Montant = 100.24 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2011", Montant = 100.09 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2012", Montant = 100.92 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2013", Montant = 100.48 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2014", Montant = 100.07 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2015", Montant = 100.88 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2016", Montant = 0 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2017", Montant = 0 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2018", Montant = 0 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2019", Montant = 0 });
                Facture.Add(new FacturesAnnuelle() { Annee = "2020", Montant = 0 });
            }
        }


2) If I do not put  "public ObservableCollection<FacturesAnnuelle> Facture { get; set; }"  in static, i have this issue  :  An object reference is required for , method, or property or the non-static field "MainFacturePage.Facture"

3) Is it possible to recover the data from a textbox to put in YBindingPath ?

Thanks for your help

Richard

Attachment: DavComptElec_a949f5d3.rar

7 Replies

RA Rachel A Syncfusion Team May 23, 2016 12:30 PM UTC

Hi Pineau, 

Thanks for contacting Syncfusion Support. 

Query1: Problem in displaying columns  

We have to set the data context for the control to provide source reference for the property binding in column series ItemsSource property. 

Query2: Regarding the object reference error  

We can resolve this error by defining the observable collection property inside the View Model class and also removed the static keyword.  

Query3: Is it possible to recover the data from a textbox to put in YBindingPath ? 

We have stored first column segment y-data in the textbox, if we edited the data in the textbox means it will be reflected in the column segment.  

We have prepared a sample for all your queries. Please find the sample from the below location. 
 
 
Please let us know, this solution satisfies your requirement. If not please provide more information about your requirements. 
 
Regards, 
Rachel. A 




PI PINEAU May 25, 2016 05:56 AM UTC

Hello

thank you for your reply

When I test your example it works very well but if I apply this in my application the columns are still empty..

This certainly comes again that I have an error in my xaml page : "The name "ViewModel" does not exist in the namespace "using: DavComptElec.PageFacture".

 <Grid>
        <Grid.DataContext>
            <local:ViewModel>
            </local:ViewModel>
        </Grid.DataContext>

but it is present in the cs page

Thanks for your help

Richard

Attachment: DavComptElec_83271fd8.7z


RA Rachel A Syncfusion Team May 26, 2016 06:43 AM UTC

Hi Pineau, 
 
Thanks for the update. 
 
We have checked your code and you need to define the ViewModel class outside of the MainPage Class. We have modified the  code and you can download from the following location. 
 
 
Regards, 
Rachel.A 



PI PINEAU May 31, 2016 06:53 AM UTC

Hello

Thank you for your reply.
I do not know why it does not work because of ViewModel and the Namespace.

I created a new project with just the necessary page and the problem recurs (cf screen and project in PJ ).

thank you in advance

Attachment: PBL_CompteurElectrique_ba7d1d61.rar


RA Rachel A Syncfusion Team June 1, 2016 04:35 AM UTC

Hi Pineau, 

Thanks for the update. 

We have modified the given sample and you can download the sample from the following location. 


You can view the output like the following screenshot. 

 

Regards, 
Rachel. A 



PI PINEAU June 10, 2016 04:32 PM UTC

Hello

Thank you for your reply.

Works perfectly

Regards, 
Richard


RA Rachel A Syncfusion Team June 13, 2016 03:44 AM UTC

Hi Pineau, 

Thanks for the update. 
  
Please let us know if you need any further assistance. 
  
Regards, 
Rachel. A 


Loader.
Up arrow icon