User (Legacy) Posted February 12, 2007 Report Share Posted February 12, 2007 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 More sharing options...
User (Legacy) Posted February 13, 2007 Author Report Share Posted February 13, 2007 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 More sharing options...
Software FX Posted February 13, 2007 Report Share Posted February 13, 2007 Olivier has it right, notice that ItemAttributes is NOT the list of items in the legend box but rather a list of attributes to be applied to these items. This list is empty by default so clearing it does nothing. -- Francisco Padron www.chartfx.com Link to comment Share on other sites More sharing options...
User (Legacy) Posted February 14, 2007 Author Report Share Posted February 14, 2007 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 More sharing options...
Software FX Posted February 14, 2007 Report Share Posted February 14, 2007 In that case what you see is the X-Axis labels. To remove them: LegendItemAttributes legendItem = new LegendItemAttributes(); legendItem.Visible = false; this.LegendBox.ItemAttributes[this.AxisX] = legendItem; -- Francisco Padron www.chartfx.com Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.