Arys Posted September 8, 2008 Report Share Posted September 8, 2008 By default the legendbox takes the axisY as the main one to show the items. I would like to set it to take the AxisX Keylabels instead, and in the help document says it can show Series (AxisY), Keylabels(AxisX), Gridlines and CustomItems. How do you set it to load the Keylabels? There is an example of creating custom items but is not so useful. Quote Link to comment Share on other sites More sharing options...
Arys Posted September 8, 2008 Author Report Share Posted September 8, 2008 mFarmLoadChart.DataSourceSettings.Fields.Clear();mFarmLoadChart.Series.Clear();mFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap(data.Table.Columns[0].ColumnName, FieldUsage.NotUsed));mFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap(data.Table.Columns[1].ColumnName, FieldUsage.Label));mFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap(data.Table.Columns[2].ColumnName, FieldUsage.NotUsed));mFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap(data.Table.Columns[3].ColumnName, FieldUsage.NotUsed));mFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap(data.Table.Columns[4].ColumnName, FieldUsage.NotUsed));mFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap(data.Table.Columns[5].ColumnName, FieldUsage.NotUsed)); if (data.Table.Columns.Count > Keys.Analyzer.ColumnarFarmLoad.ColumnsToSkipBeforeSeries){for (int i = Keys.Analyzer.ColumnarFarmLoad.ColumnsToSkipBeforeSeries; i < data.Table.Columns.Count; i++){mFarmLoadChart.DataSourceSettings.Fields.Add(new FieldMap(data.Table.Columns.ColumnName, FieldUsage.Value));mFarmLoadChart.DataSourceSettings.Fields.DisplayName = data.Table.Columns.Caption;}mFarmLoadChart.Gallery = Gallery.Bar;mFarmLoadChart.LegendBox.Visible = false;mFarmLoadChart.AxisX.Step = 3;mFarmLoadChart.AxisX.Staggered = true;mFarmLoadChart.DataSourceSettings.DataSource = data;for (int i = Keys.Analyzer.ColumnarFarmLoad.ColumnsToSkipBeforeSeries; i < data.Table.Columns.Count; i++){int iCounter = i - Keys.Analyzer.ColumnarFarmLoad.ColumnsToSkipBeforeSeries;ChartFX.WinForms.SeriesAttributes serie = mFarmLoadChart.Series[iCounter];// === Set Fram Load Id ===serie.Tag = data.Table.Columns.ExtendedProperties[Keys.Analyzer.ColumnarFarmLoad.ExtPropFarmLoadId];// === Set Color ===if (RtgAnalyzerConfigurationManager.Current.Configuration.UseAlgorithmColors || RtgAnalyzerConfigurationManager.Current.Configuration.MonochromaticMode){serie.Color = (Color)data.Table.Columns.ExtendedProperties[Keys.Analyzer.ColumnarFarmLoad.ExtPropColorKey];}// === Set Series Legend ===serie.Text = data.Table.Columns.Caption;serie.AxisY = mFarmLoadChart.AxisY;}} Basically it adds the first 6 columns (only 1 usable to get the name) and then create the rest of the columns depending on the number of items. This code basically binds the dataview and loads the chart but i am not able to set the legendbox to show the AxisX labels. Quote Link to comment Share on other sites More sharing options...
Arys Posted September 8, 2008 Author Report Share Posted September 8, 2008 Basically i had to fill the chart.AxisX.KeyLabel for each element since the legend box uses it to show the names. One this property was filled the legend box was showing the data correctly. Quote Link to comment Share on other sites More sharing options...
Arys Posted September 9, 2008 Author Report Share Posted September 9, 2008 this.mFarmLoadChart.LegendBox.ItemAttributes.Clear();this.mFarmLoadChart.LegendBox.ItemAttributes[this.mFarmLoadChart.Series].visible = false;this.mFarmLoadChart.LegendBox.ItemAttributes[this.mFarmLoadChart.AxisX].visible = true;for (int i = 1; i < this.mFarmLoadChart.AxisX.Labels.Count + 1; i++){this.mFarmLoadChart.AxisX.KeyLabels[i - 1] = this.mFarmLoadChart.AxisX.Labels[i - 1];this.mFarmLoadChart.AxisX.Labels[i - 1] = i.ToString();}this.mFarmLoadChart.LegendBox.Visible = true; I perform this code each time after the data has been binded to the chart. The first time it loads the legend box is correct, next tryes legendbox appears empty. I have checked the properties and Keylabels contains strings, and are > 0, and the visible propertie for that axis is true. Anyone knows what could be the problem? Quote Link to comment Share on other sites More sharing options...
Arys Posted September 9, 2008 Author Report Share Posted September 9, 2008 The FOR loop only changes the keylabels the first time, thus apearing in the chart like 0,1,2,3,4,5... and so but the second time onwards the keylabels get modified if i perform a watch on them but they are not updated in the chart and not updated in the legendbox. I also tried to perform a axesx.clear() at the beggining but nothing. And sometimes when i put a breakpoint in the code to add watches to the keylabels, they get added correctly, then remove the break point and there is the problem again. Is there any method i should call to finalize the data edition? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.