Question about populatin data

Hello. I wanna know if its possible to have a chart like this example https://help.syncfusion.com/xamarin-android/sfchart/getting-started , but only one column and pass data without class, just with a single value. For example I wanna display a column with value to 60% with max to 100%. Is it possible? Thank you very much

6 Replies

DV Divya Venkatesan Syncfusion Team April 12, 2018 09:17 AM UTC

Hi Konstantinos, 
 
Thanks for using Syncfusion products. 
 
We have achieved your requirement by setting Maximum property of axis with one datapoint value. Please refer the below code snippet.  
 
Code snippet[C#]: 
secondaryAxis.Maximum = 100; 
 
Output: 
 
 
Note: If you need to show string values in x axis, you should use one separate class(Model class). 
 
Code snippet[C#]: 
    public class Model 
    { 
        public string XValue { get; set; } 
        public double YValue { get; set; } 
 
        public Model(string xValue,double yValue) 
        { 
            XValue = xValue; 
            YValue = yValue; 
        } 
    } 
 
 
Output: 
 
 
We have prepared a sample for this which can be downloaded from the following link. 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Divya Venkatesan 



KE Konstantinos Evangelidis April 12, 2018 11:30 AM UTC

Hello and thank you for your answer. Works like this and thank you. In the case I am using StackingColumn100Series, how can I put different between the 60% and the rest 40%?  Exactly the same example with color for the rest 40% value. And how to change the displayed value '60' with accustom text? Thank you very much.


DV Divya Venkatesan Syncfusion Team April 13, 2018 06:46 AM UTC

Hi Konstantinos, 
 
Query 1: how can I put different between the 60% and the rest 40%? 
We have achieved your requirement by adding another series for the rest value with CategoryAxis as primary axis as shown in the below code snippets. 
 
Code snippet[C#]: 
void ValidateData(ObservableCollection<Model> data) 
{ 
    Data1 = new ObservableCollection<Model>(); 
    for (int i = 0; i < data.Count; i++) 
    { 
        Data1.Add(new Model(data[i].XValue, 100 - data[i].YValue)); 
    } 
    StackingColumn100Series series1 = new StackingColumn100Series(); 
    series1.ItemsSource = Data1; 
    series1.XBindingPath = "XValue"; 
    series1.YBindingPath = "YValue"; 
    series1.DataMarker.ShowLabel = true; 
    series1.DataMarkerLabelCreated += Series_DataMarkerLabelCreated; 
    series1.Label = "Remaining"; 
    series1.TooltipEnabled = true; 
    chart.Series.Add(series1); 
} 
 
If you are using NumericalAxis as primary axis, you can achieve your requirement with single series and by adding data with remaining y value and same x value. 
 
Code snippet[C#]: 
void ValidateData1(ObservableCollection<Model> data) 
{ 
    data.Add(new Model(data[data.Count-1].XValue, 100 - data[data.Count-1].YValue)); 
} 
 
Query 2: And how to change the displayed value '60' with accustom text? 
We have achieved your requirement by adding custom view to the datamarker in DataMarkerLabelCreated event. Please refer the below code snippet. 
 
Code snippet[C#]: 
private void Series_DataMarkerLabelCreated(object sender, ChartSeries.DataMarkerLabelCreatedEventArgs e) 
{ 
    TextView text = new TextView(chart.Context); 
    text.Text = e.DataMarkerLabel.Label + "%"; 
    e.DataMarkerLabel.View = text; 
} 
 
We have prepared a sample for this which can be downloaded from the following link. 
 
 
Output: 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Divya Venkatesan 
 



KE Konstantinos Evangelidis April 18, 2018 10:48 AM UTC

Hello. The problem is that when I am using StackingColumn100Series, it looks like there is right and left margin. The graph is now more tight that before. How can I solve this problem? Thank you.


KE Konstantinos Evangelidis April 18, 2018 10:54 AM UTC

Sorry. I just had to add series.Width = 1; and series1.Width = 1;


DV Divya Venkatesan Syncfusion Team April 19, 2018 11:59 AM UTC

Hi Konstantinos, 
 
Thanks for the update. We are glad that you have got a solution. 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Divya Venkatesan 
 
 


Loader.
Up arrow icon