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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Transform Chart --> Datagrid

Thread ID:

Created:

Updated:

Platform:

Replies:

121363 Dec 7,2015 09:24 AM UTC Dec 7,2015 09:42 AM UTC Xamarin.Forms 1
loading
Tags: SfDataGrid
Rosemond Jordan
Asked On December 7, 2015 09:24 AM UTC

Hi, 

I have a chart : 

class DataModel
{
//Creation des collections
public Dictionary<int, ObservableCollection<ChartDataPoint>> ToutePorte;
public ObservableCollection<ChartDataPoint> Porte1;
public ObservableCollection<ChartDataPoint> Porte2;
public ObservableCollection<ChartDataPoint> Porte3;

public DataModel()
{


//Remplissage des collections
Porte1 = new ObservableCollection<ChartDataPoint>();

Porte1.Add(new ChartDataPoint("Jan", 6));
Porte1.Add(new ChartDataPoint("Feb", 6));
Porte1.Add(new ChartDataPoint("Mar", 8));
Porte1.Add(new ChartDataPoint("Apr", 3));
Porte1.Add(new ChartDataPoint("May", 7));
Porte1.Add(new ChartDataPoint("Jun", 6));
Porte1.Add(new ChartDataPoint("Jul", 7));
Porte1.Add(new ChartDataPoint("Aug", 7));
Porte1.Add(new ChartDataPoint("Sep", 6));
Porte1.Add(new ChartDataPoint("Oct", 6));
Porte1.Add(new ChartDataPoint("Nov", 6));
Porte1.Add(new ChartDataPoint("Dec", 6));

Porte2 = new ObservableCollection<ChartDataPoint>();

Porte2.Add(new ChartDataPoint("Jan", 4));
Porte2.Add(new ChartDataPoint("Feb", 2));
Porte2.Add(new ChartDataPoint("Mar", 6));
Porte2.Add(new ChartDataPoint("Apr", 8));
Porte2.Add(new ChartDataPoint("May", 4));
Porte2.Add(new ChartDataPoint("Jun", 3));
Porte2.Add(new ChartDataPoint("Jul", 2));
Porte2.Add(new ChartDataPoint("Aug", 4));
Porte2.Add(new ChartDataPoint("Sep", 5));
Porte2.Add(new ChartDataPoint("Oct", 4));
Porte2.Add(new ChartDataPoint("Nov", 7));
Porte2.Add(new ChartDataPoint("Dec", 3));

Porte3 = new ObservableCollection<ChartDataPoint>();

Porte3.Add(new ChartDataPoint("Jan", 3));
Porte3.Add(new ChartDataPoint("Feb", 2));
Porte3.Add(new ChartDataPoint("Mar", 3));
Porte3.Add(new ChartDataPoint("Apr", 8));
Porte3.Add(new ChartDataPoint("May", 4));
Porte3.Add(new ChartDataPoint("Jun", 3));
Porte3.Add(new ChartDataPoint("Jul", 4));
Porte3.Add(new ChartDataPoint("Aug", 4));
Porte3.Add(new ChartDataPoint("Sep", 3));
Porte3.Add(new ChartDataPoint("Oct", 3));
Porte3.Add(new ChartDataPoint("Nov", 2));
Porte3.Add(new ChartDataPoint("Dec", 2));

ToutePorte = new Dictionary<int, ObservableCollection<ChartDataPoint>>();

ToutePorte.Add(1, Porte1);
ToutePorte.Add(2, Porte2);
ToutePorte.Add(3, Porte3);

}
}

public void myChart()
{
Grid grid = new Grid
{
VerticalOptions = LayoutOptions.FillAndExpand,
RowDefinitions =
{
new RowDefinition { Height = (new GridLength (1, GridUnitType.Star ))},
new RowDefinition { Height = (GridLength.Auto)},
},
};
chart.Title = new ChartTitle() { Text = "Statistique" };

//Initializing Primary Axis
CategoryAxis primaryAxis = new CategoryAxis();
primaryAxis.Title = new ChartAxisTitle() { Text = "Mois" };
primaryAxis.LabelPlacement = LabelPlacement.OnTicks;

chart.PrimaryAxis = primaryAxis;

//Initializing Secondary Axis
NumericalAxis secondaryAxis = new NumericalAxis();
secondaryAxis.Title = new ChartAxisTitle() { Text = "Nombres de personnes" };
secondaryAxis.Interval = 1;
secondaryAxis.ShowMajorGridLines = true;
secondaryAxis.ShowMinorGridLines = true;

chart.SecondaryAxis = secondaryAxis;

DataModel dataModel = new DataModel();


//Ajoutes les valeurs au graphique
chart.Series.Add(new StackingAreaSeries()
{
//ItemsSource = dataModel.Porte1,
ItemsSource = dataModel.ToutePorte[1],
Label = "Porte 1",
});

chart.Series.Add(new StackingAreaSeries()
{
ItemsSource = dataModel.ToutePorte[2],
Label = "Porte 2",
});

chart.Series.Add(new StackingAreaSeries()
{
ItemsSource = dataModel.ToutePorte[3],
Label = "Porte 3",
});


//Adding Chart Legend for the Chart
chart.Legend = new ChartLegend() { IsVisible = true };
chart.Opacity = 1;
chart.IsVisible = true;

//Creation bouton
Button monBoutton = new Button();
monBoutton.Text = "Afficher la grille";
monBoutton.FontSize = 24;
monBoutton.Clicked += MonBoutton_Clicked;

//Ajout des contrôles dans la grid
grid.Children.Add(chart, 0, 0);
grid.Children.Add(monBoutton, 0, 1);

this.Content = grid;
}

It's working well, but now how construct DagaGrid like this : 

|primaryAxis.Name\SecondaryAxis.Name|       Chart.Series1     |         Chart.Series2    |      Chart.Series3     |
|          Jan                                                 |Chart.Series1.YValue|Chart.Series2.Yvalues|Chart.Series3.YValue|
|          Feb                                                |Chart.Serie1.Yvalues|Chart.Series2.YValue |ChartSeries3.YValues|
.... 

Do you understand ? 

Thank's :) 

Sivakumar R [Syncfusion]
Replied On December 7, 2015 09:42 AM UTC

Hi Jordan,

Refer the below documentation link on creating SfDataGrid in xamarin.forms.
http://help.syncfusion.com/xamarin/sfdatagrid/getting-started

Thanks,
Sivakumar

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;