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
close icon

SfChart Histogram Yaxis range setting

My Y binding data for  HistogramSeries definitely has frequency counts of more than 1. However, after binding, it detects that the maximum is 1 and plots my histogram as shown below.

The x axis is fine.

My understanding for HistogramSeries data is
X data -> location of each bin
Y data -> Number of counts in each bin
and then I set some bin interval.
Is this correct? If not, what is the series expecting for X and Y data?


Below is the code that I use.

=====================================================

var plotPoints = new ObservableCollection<HistoPlotPoint>();

            foreach (var pt in pgDataSet.Histogram.HistogramPoints)

            {

                plotPoints.Add(new HistoPlotPoint(pt.X, pt.Y));

            }

 

            // Perform Data Binding

            var series = new HistogramSeries();

            series.ItemsSource = plotPoints;

            series.XBindingPath = "X";

            series.YBindingPath = "Y";

            series.HistogramInterval = pgDataSet.Histogram.BucketSize;

            series.ShowTooltip = true;

           

            series.Interior = Brushes.Orange;

           

            series.ShowNormalDistributionCurve = true;

           

            chart.Series.Add(series);



=====================================================

private class HistoPlotPoint




{



public HistoPlotPoint(double x, double y, string toolTip = null)




{



X = x;


Y = (int) y;


ToolTip = toolTip;




}



public double X { get; set; }


public int Y { get; set; }


public string ToolTip { get; set; }




}



3 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team March 17, 2017 09:34 AM UTC

Hi Keenan, 
  
Thanks for contacting Syncfusion Support. 
  
In SfChart, the histogram series Y-values are calculated internally as number of x-values fall in each bin (in provided HistogramInterval). So, we no need to define Y-data (Number of count in each bin) externally in sample.  
  
We have prepared a demo sample with histogram series for your reference and it can be downloaded from below link, 
  
Sample: HistogramSample 
  
Please find the output screenshot for the above code snippet 
 
  
Regards, 
Devi 
 



LL llllllllll March 17, 2017 03:00 PM UTC

Thank you. I can get my histogram working now.

However, I do not understand why in the example you have histogram.YBindingPath = "Value" when only Model.Price is set but Model.Value is null. Why is histogram.YBindingPath = "Value" needed and what does it do?


DA Devi Aruna Maharasi Murugan Syncfusion Team March 20, 2017 10:36 AM UTC

Hi Keenan, 
  
Thanks for your update. 
  
We would like to inform you that we have generated data points for all the XYDataSeries based on XBindingPath and YBindingPath property. So, we must specify the YBindingPath for HistogramSeries (here we can define the empty YData). 
  
As we mentioned in our earlier update, we have calculated Y-Values internally based on the number of X-values falls in each bin. 
  
Regards, 
Devi 


Loader.
Live Chat Icon For mobile
Up arrow icon