Jump to content
Software FX Community

legend box for pie chart


tiffany

Recommended Posts

Hi,

I was wondering if there's any way to change the order of the items in the legend box. It currently shows the items in alpha and numerical ascending order.

I have pie chart where the legend have the items shown in this order:

Below 100MB

Below 1GB

Below 2GB

Below 500MB

Over 2GB

 

I would like the legend to show the items in this order:

Below 100MB

Below 500MB

Below 1GB

Below 2GB

Over 2GB

Thanks

Tiffany 

 

Link to comment
Share on other sites

Unfortunately, the standard legend box in ChartFX for .NET 6.2 does not provide a way to order the legend box items; however, you could hide the standard legend box and create your own UserLegendBox adding each UserLegendBoxItem in the order in which you need them to show. You could do something like the following:

chart1.UserLegendBox = true;

UserLegendBoxItem userLegendBoxItem = chart1.UserLegendBoxObj.Item[0];userLegendBoxItem.Label = "Below 100MB";

userLegendBoxItem.Color = System.Drawing.

Color.Red;userLegendBoxItem.MarkerShape = SoftwareFX.ChartFX.MarkerShape.Rect;

userLegendBoxItem.BorderEffect = SoftwareFX.ChartFX.

BorderEffect.None;userLegendBoxItem.BorderColor = System.Drawing.Color.Black;

userLegendBoxItem = chart1.UserLegendBoxObj.Item[1];

userLegendBoxItem.Label = "Below 500MB";

userLegendBoxItem.Color = System.Drawing.

Color.Yellow;userLegendBoxItem.MarkerShape = SoftwareFX.ChartFX.MarkerShape.Rect;

userLegendBoxItem.BorderEffect = SoftwareFX.ChartFX.

BorderEffect.None;userLegendBoxItem.BorderColor = System.Drawing.Color.Black;

userLegendBoxItem = chart1.UserLegendBoxObj.Item[2];

userLegendBoxItem.Label =

"Below 1GB"; userLegendBoxItem.Color = System.Drawing.Color.Green;

userLegendBoxItem.MarkerShape = SoftwareFX.ChartFX.

MarkerShape.Rect; userLegendBoxItem.BorderEffect = SoftwareFX.ChartFX.BorderEffect.None;

userLegendBoxItem.BorderColor = System.Drawing.

Color.Black;

Please note that the functionality you are looking for is available in ChartFX 7 via the LegendItemAttributes Collection.

Charts.zip

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...