Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
630
How to generate customized legends for a IGStackedColumnSeries
posted

Hello,

i am looking for a way for customizing the legends title in an chartview witih stacked columns. They always appears with "Value1", "Value2"....in the graph legend. Is there for e.g. a delegate like ResolveLabelForAxis or ResolveMarkerView to change the legend items dynamicaly?

Thanks, Johann

 

That's my sample-code:

const int legendWidth = 200;

List<NSObject> _data = new List<NSObject>();            

for (int i = 0; i < 5; i++)            

{                

StackedChartData item = new StackedChartData();                

item.Value1 = new Random((int)DateTime.Now.Ticks).Next(100);                

item.Value2 = new Random((int)DateTime.Now.Ticks).Next(100);                

item.Value3 = new Random((int)DateTime.Now.Ticks).Next(100);                

item.Label = string.Format("MYDATA {0}", i);                

 _data.Add(item);            

}

 

List<NSObject> valueList = new List<NSObject>                

{                    

new NSString("Value1"),                    

new NSString("Value2"),                    

new NSString("Value3")                

};

 

IGStackedSeriesDataSourceHelper stackedChartDataSourceHelper = new IGStackedSeriesDataSourceHelper(_data.ToArray(), valueList.ToArray());

stackedChartDataSourceHelper.LabelPath = "Label";            

StandardChart.AddStackedSeries(new Class(typeof(IGStackedColumnSeries)), "series", stackedChartDataSourceHelper, "xAxis", "yAxis");            

StandardChart.Frame = new RectangleF(0, 0, 500 - legendWidth, 300);

View.Frame = new RectangleF(0, 0, 500, 300);            

 (this.View).AddSubview(StandardChart);

IGLegend legend = new IGLegend(IGChartLegendType.IGChartLegendTypeSeries);            

legend.Frame = new RectangleF(500 - legendWidth, 0, legendWidth, 300);            

legend.BackgroundColor = UIColor.White;

legend.Orientation = IGOrientation.IGOrientationVertical;            

legend.VerticalAlignment = IGVerticalAlign.IGVerticalAlignCenter;            

StandardChart.Legend = legend;            

(this.View).AddSubview(legend);

 

 

Parents
No Data
Reply
  • 23930
    Verified Answer
    Offline posted

    Hi Johann,

    Thank you for contacting Infragistics Developer Support.

    You need to set the “Title” property of the each stacked fragment. You can get the fragments in a series using FindFragmentForPropertyName(string propertyName) method or you can iterate through the series.Series collection. In your case you can substitute the StandardChart.AddStackedSeries(new Class(typeof(IGStackedColumnSeries)), "series", stackedChartDataSourceHelper, "xAxis", "yAxis");”, with:

    IGStackedSeriesBase series = StandardChart.AddStackedSeries(new Class(typeof(IGStackedColumnSeries)), "series", stackedChartDataSourceHelper, "xAxis", "yAxis"); 
                foreach ( IGStackedFragmentSeries  item in series.Series)
                {
                    item.Title = @"Custom legend label";
                }

    Please let me know if you have any additional questions.

Children