Hi,
i have a stacked column bar and i need to center the columns in the grid...they are align left and i want to center in grid like the labels (the labels are align center).
And on more thing, it's possible to define the individual background of the items in the legend?
thanks for you help.
hi Max,
thanks for your help, i followed your directions and it's done!
I think I see what the issue is. There are two ways to create a stacked chart: you can create a datasource helper and tell the chart to auto-create the stacked series and axes from it by using chartView.AddStackedSeries(...), or you can create the axes, the series and the stacked fragments with value paths in code yourself. You're kind of doing both in your code and you end up telling the x axis that there are two series attached to it, while only displaying one.
AddStackedSeries method actually creates the axes, the series and the fragments based on the string keys you provide and then adds them all to the chart view. You can remove the code that creates the axes and adds them to the chart as well as the code that creates the series and sets its xAxis and yAxis properties. To set the properties on the axes, get them from the chart by their key after calling AddStackedSeries method.
Let me know if you have any further questions.
I cannot find what i'm doing wrong (columns not centered):
public void ConstroiGraficoLoanAdvisor() { this.PopulateData(); chartView = new IGChartView(); IGChartThemeDefinition def = new IGChartThemeDefinition(); def.LegendPalette = new IGChartPaletteItem(); def.LegendPalette.Color = new IGBrush(0.9f,0.9f,0.9f,1); IGChartPaletteItem item1 = new IGChartPaletteItem(); item1.Color = new IGBrush (UIColor.FromRGB(249, 158, 45)); item1.OutlineColor = new IGBrush(0,0,0,0); def.SeriesPalettes.Add(item1); IGChartPaletteItem item2 = new IGChartPaletteItem(); item2.Color = new IGBrush (UIColor.FromRGB(229, 52, 30)); item2.OutlineColor = new IGBrush(0,0,0,0); def.SeriesPalettes.Add(item2); IGChartPaletteItem item3 = new IGChartPaletteItem(); item3.Color = new IGBrush (UIColor.FromRGB(156, 20, 55)); item3.OutlineColor = new IGBrush(0,0,0,0); def.SeriesPalettes.Add(item3); def.BackgroundColor = UIColor.Clear; def.Font = UIFont.FromName("Helvetica Neue", 9); def.FontColor = new IGBrush (UIColor.DarkGray); def.LegendFont = UIFont.FromName("Helvetica Neue", 9); def.LegendFontColor = new IGBrush (UIColor.DarkGray); chartView.Theme = def; chartView.GridMode = IGGridMode.IGGridModeBeforeSeries; chartView.Frame = new RectangleF (25, 10, 240, 150); chartView.BackgroundColor = UIColor.Clear; chartView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; chartView.Delegate = new MyChartViewDelegate(); List<NSString> valueList = new List<NSString> (); valueList.Add (new NSString("Interests")); valueList.Add (new NSString("Principal")); valueList.Add (new NSString("Costs")); stackedChartDataSourceHelper = new IGStackedSeriesDataSourceHelper(data.ToArray(),valueList.ToArray()); stackedChartDataSourceHelper.LabelPath = "Label"; IGCategoryXAxis xAxis = new IGCategoryXAxis("xAxis"); xAxis.LabelAlignment = IGVerticalAlign.IGVerticalAlignCenter; xAxis.LabelsLocation = IGAxisLabelsLocation.IGAxisLabelsLocationOutsideBottom; xAxis.LabelsVisible = true; IGNumericYAxis yAxis = new IGNumericYAxis("yAxis"); yAxis.LabelsVisible = true; chartView.AddAxis(xAxis); chartView.AddAxis(yAxis); IGStackedColumnSeries series = new IGStackedColumnSeries ("series"); series.XAxis = xAxis; series.YAxis = yAxis; chartView.AddStackedSeries(new Class(typeof(IGStackedColumnSeries)), "series", stackedChartDataSourceHelper, "xAxis", "yAxis"); UIScrollViewLoanAdvisor.AddSubview(chartView); legend = new IGLegend(IGChartLegendType.IGChartLegendTypeSeries); legend.Frame = new RectangleF(257, 55, 60, 55); chartView.Legend = legend; UIScrollViewLoanAdvisor.AddSubview(legend); IGStackedColumnSeries newSeries = (IGStackedColumnSeries)chartView.Series [0]; newSeries.XAxis.LabelBrush = new IGBrush (UIColor.DarkGray); newSeries.YAxis.LabelBrush = new IGBrush (UIColor.DarkGray); } void PopulateData() { data = new List<NSObject>(); DataModel item = new DataModel(); item.Interests = (float)ClassVariaveisGlobais.wOutputPlanoFinanceiroLoanInput.wOutputListaPlanoFinanceiroLoanInput [0].wOutputValorJurosLoanInput; item.Principal = (float)ClassVariaveisGlobais.wOutputPlanoFinanceiroLoanInput.wOutputListaPlanoFinanceiroLoanInput [0].wOutputValorAmortizacaoLoanInput; item.Costs = (float)ClassVariaveisGlobais.wOutputPlanoFinanceiroLoanInput.wOutputListaPlanoFinanceiroLoanInput [0].wOutputValorOutrosCustosLoanInput; item.Label = "Simulation";
data.Add (item);
item = new DataModel(); item.Interests = (float)ClassVariaveisGlobais.wOutputPlanoFinanceiroLoanAdvisor.wOutputListaPlanoFinanceiroLoanAdvisor [0].wOutputValorJurosLoanAdvisor; item.Principal = (float)ClassVariaveisGlobais.wOutputPlanoFinanceiroLoanAdvisor.wOutputListaPlanoFinanceiroLoanAdvisor [0].wOutputValorAmortizacaoLoanAdvisor; item.Costs = (float)ClassVariaveisGlobais.wOutputPlanoFinanceiroLoanAdvisor.wOutputListaPlanoFinanceiroLoanAdvisor [0].wOutputValorOutrosCustosLoanAdvisor;
item.Label = "Advisor"; data.Add (item); } public class DataModel : NSObject { [Export("Label")] public string Label { get; set; } [Export("Interests")] public float Interests { get; set; } [Export("Principal")] public float Principal { get; set; } [Export("Costs")] public float Costs { get; set; } } public class MyChartViewDelegate :IGChartViewDelegate { public override string ResolveLabelForAxis (IGChartView chartView, IGAxis axis, NSObject item) { if (axis is IGCategoryXAxis) { NSMutableDictionary dm = (NSMutableDictionary)item; return ((NSString)dm["label"]).ToString(); } if (axis is IGNumericYAxis) { return (item.ToString()); } return string.Empty; } }
The Stacked chart's columns are centered by default. They also don't have the large gap in between the stacks I'm seeing in your screenshot. I'm not entirely sure why your chart is being drawn like that. I would suggest following the code example in this help link:http://es.infragistics.com/help/topic/17651853-a205-4906-b7c9-71156a258ecf
The legend we provide always draws the legend items with a badge and text. For what you're trying to do, you'll have to create a custom legend class that derives from IGLegend or IGLegendBase. In your case it might be even easier to use a simple UIView, where the subviews will be UILabels. You can get the text string and the brush from your stacked fragments.
As for the multiline axis labels, the chart currently doesn't handle those, but we'll add that for future development.
One more thing, it's possible define - for the labels - multi-line text? i will need long text axis labels. Example: "Advisor - With interests only period"
can i get something like that:
Advisor - With
interests only
period