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);
Hello Johann,
Thank you for the reply.
I was able to reproduce this behavior on my machine so I logged it in our internal issue tracking system with ID 174741. I have also created a private case for you in our internal issue tracking system with - CAS-139834-N0K7F5. You can view this case at https://es.infragistics.com/my-account/support-activity.
Hi,
thanks it works fine. But there are two more things with my legends. First the order of the legend items are reverse. I used
series.ReverseLegendOrder = true;
but it doesn't change. And further i don'l like gray the background of the legend. I tried
or changed it to an other color but nothing happend.
Thank you,
Johann
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.