Jump to content
Software FX Community

Replace LegendBox items completely


User (Legacy)

Recommended Posts

Hello:

I am trying to customize the items in the legend box.

My code looks like this:

-------------------------------------

chart1.LegendBox.ItemAttributes.Clear();

CustomLegendItem ccc = new CustomLegendItem();

ccc.Text = "Legend Item 1";

chart1.LegendBox.CustomItems.Add(ccc);

-------------------------------------

As a result, the legend box contains the previous labels (in my case the

point labels) plus the new custom label.

Is there a why I can really clear the legen box items and provide my own

items, completely unrelated to the data source?

Thank you,

Mira

Link to comment
Share on other sites

Hello. Try this:

///////////////////////// LEGEND ///////////////////////////////////////

//First show the standard Chart FX Legend Box

this.LegendBox.Visible = true;

//Now let´s hide the standard Legend Box Items

LegendItemAttributes legendItem = new LegendItemAttributes();

legendItem.Visible = false;

this.LegendBox.ItemAttributes[this.Series] = legendItem;

this.LegendBox.CustomItems.Clear();

// Your code

CustomLegendItem ccc = new CustomLegendItem();

ccc.Text = "Legend Item 1";

chart1.LegendBox.CustomItems.Add(ccc);

base.LegendBox.Highlight.Enabled = false;

--

Olivier Voyer

CYME International T&D

"Mira Goutseva" <mira.goutseva@platespin.com> wrote in message

news:lzo1i4tTHHA.3404@webserver3.softwarefx.com...

> Hello:

>

> I am trying to customize the items in the legend box.

>

> My code looks like this:

> -------------------------------------

> chart1.LegendBox.ItemAttributes.Clear();

>

> CustomLegendItem ccc = new CustomLegendItem();

> ccc.Text = "Legend Item 1";

> chart1.LegendBox.CustomItems.Add(ccc);

> -------------------------------------

>

> As a result, the legend box contains the previous labels (in my case the

> point labels) plus the new custom label.

>

> Is there a why I can really clear the legen box items and provide my own

> items, completely unrelated to the data source?

>

> Thank you,

> Mira

>

>

Link to comment
Share on other sites

Thank you. The solution you propose works fine when the 

AllSeries.MultipleColors is false.

My chart thas this propery set to true:

----

chart1.AllSeries.MultipleColors = false;

------

I can reproduce this effect with the AxisLabels application from the ChartFX

samples.

Can I hide the legend items in this case?

Thank you,

Mira

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...