Jump to content
Software FX Community

LegendBox and AxisX KeyLabels


Arys
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...