This is a migrated thread and some comments may be shown as answers.

Legend Icon to be PointMark Figure

6 Answers 192 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 15 Aug 2008, 08:44 AM
Hello,

I have a line chart which uses different PointMark Figures (Cross, Star etc.) depending on what lines are displayed from a custom list.  However, on the legend I always get a circle as the icon.  How can I set the legend to show the PointMark Figure set on the appropriate line?

I have read about setting the Appearance.FillStyle.FillSettings.BackgroundImage property, but the PointMark Figures are accessed by string and are as far as I can tell not static images.

Thanks in advance.

6 Answers, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 18 Aug 2008, 11:38 AM
Hello Jonathan,

You will need to manually add a custom legend item for each series and set its Figure property appropriately like this:

ASPX:
<telerik:RadChart ID="RadChart1" runat="server" OnBeforeLayout="RadChart1_BeforeLayout"
    <Series> 
        <telerik:ChartSeries Type="Line"
            <Appearance> 
                <PointMark Visible="true" Figure="Cross" Dimensions-AutoSize="False" Dimensions-Width="10" 
                    Dimensions-Height="10" FillStyle-MainColor="Red" FillStyle-FillType="Solid"
                </PointMark> 
            </Appearance> 
            <Items> 
                <telerik:ChartSeriesItem YValue="10"
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem YValue="50"
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem YValue="30"
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem YValue="20"
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem YValue="40"
                </telerik:ChartSeriesItem> 
            </Items> 
        </telerik:ChartSeries> 
    </Series> 
</telerik:RadChart> 

Code-behind:
protected void RadChart1_BeforeLayout(object sender, EventArgs e) 
    RadChart1.Legend.Items.Clear(); 
 
    LabelItem legendItem = new LabelItem("Series 1"); 
    legendItem.Marker.Appearance.Figure = DefaultFigures.Cross; 
    legendItem.Marker.Appearance.FillStyle.MainColor = Color.Red; 
    legendItem.Marker.Appearance.FillStyle.FillType = FillType.Solid; 
    RadChart1.Legend.Items.Add(legendItem); 


Hope this helps.


Best wishes,
Manuel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jonathan
Top achievements
Rank 1
answered on 18 Aug 2008, 02:27 PM
Thanks very much, thats exactly what I needed to know!
0
Melissa
Top achievements
Rank 1
answered on 18 Aug 2011, 05:27 AM
Hi admin,

I really need to solve this.I am using telerik chart reporting chart in Visual studio 2008 using Asp.net
and C#.I change the legend appearance property in the properties box, but when I rebuild the solution the
changes will go back to its original state.So what I do is change the code behind instead.Some properties
I manage to change but this itemMarkerApperance FIGURE I don't know what's the code to change.Please help!
I am looking for the solution for a week already and this is my first time to ask in forum. This is my code:


                    Telerik.Reporting.Processing.Chart chart = (Telerik.Reporting.Processing.Chart)sender;
                    Telerik.Reporting.Chart chartDef = (Telerik.Reporting.Chart)chart.ItemDefinition;
                    Telerik.Reporting.Charting.ChartSeries s = chartDef.Series[0];
                    s.Clear();
                    s.Appearance.LegendDisplayMode = Telerik.Reporting.Charting.ChartSeriesLegendDisplayMode.ItemLabels;


                    s.PlotArea.Appearance.Dimensions.Margins.Bottom.Value = 10;
                    s.PlotArea.Appearance.Dimensions.Margins.Right.Value = 40;
                    s.PlotArea.Appearance.Dimensions.Margins.Left.Value = 0;
                    s.PlotArea.Appearance.Dimensions.Margins.Top.Value = 3;
                    s.PlotArea.Appearance.Dimensions.Paddings.Left.Value = 0;
                    s.PlotArea.Appearance.Dimensions.Paddings.Right.Value = 0;
                    s.Appearance.DiameterScale = 0.87;
                    

                    foreach (DataRow row in dtAsset.Rows)
                    {
                        Telerik.Reporting.Charting.ChartSeriesItem item = new Telerik.Reporting.Charting.ChartSeriesItem();
                        item.YValue = Convert.ToDouble(row["ValueAsset"].ToString());
                        item.Name = row["LegendTitleAsset"].ToString() + " (" + Convert.ToDouble(row["ValueAsset"].ToString())+ "%)";
                        s.Items.Add(item);
                    }
0
Evgenia
Telerik team
answered on 23 Aug 2011, 08:12 AM
Hi Melissa,

Do you by any case use a Skin different than the Default one? If this is the case - then you should turn off the SkinsOverrideStyles property of the Chart for your appearance modifications to take effect.
If you are using the Default Skin, could you send us the code that you are setting in code-behind to change the LegendItemMarker figure so that we can get back to you with our suggestions?

All the best,
Evgenia
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Melissa
Top achievements
Rank 1
answered on 24 Aug 2011, 02:45 AM
Hi Evgenia,

This is how Properties of my chart in the code behind,because as I said every time I rebuild the solution the changes won't take effect.
I changed the size,margins etc. and I want to change the legend part, like resize the font, and the marker of it.In the code behind there it no property as ITEMMARKERAPPERANCE as what on the property box has, only marker,i dont know if its correct.With this code I am getting an error that the legend marker is read only.Thanks in  advance.

                    Telerik.Reporting.Processing.Chart chart = (Telerik.Reporting.Processing.Chart)sender;
                    Telerik.Reporting.Chart chartDef = (Telerik.Reporting.Chart)chart.ItemDefinition;
                    Telerik.Reporting.Charting.ChartSeries s = chartDef.Series[0];
                   
                    
                    s.Clear();
                    s.Appearance.LegendDisplayMode = Telerik.Reporting.Charting.ChartSeriesLegendDisplayMode.ItemLabels;

                    s.PlotArea.Appearance.Dimensions.Margins.Bottom.Value = 8;
                    s.PlotArea.Appearance.Dimensions.Margins.Right.Value = 30;
                    s.PlotArea.Appearance.Dimensions.Margins.Left.Value = 2;
                    s.PlotArea.Appearance.Dimensions.Margins.Top.Value = 5;
                    s.PlotArea.Appearance.Dimensions.Paddings.Left.Value = 0;
                    s.PlotArea.Appearance.Dimensions.Paddings.Right.Value = 0;
                    s.Appearance.DiameterScale = 0.90;
                    s.Appearance.PointRotationAngle = 100;
                    s.PlotArea.Chart.Legend.Marker = "Rectangle";  // read only
0
Evgenia
Telerik team
answered on 29 Aug 2011, 09:31 AM
Hello Melissa,

You should subscribe to BeforeLayout event of the chart to be able to change anything relating Legend Item Markers. Then you can set the Marker.Appearance.Figure to "Rectangle" like this:
void MilestoneChart_BeforeLayout(object sender, EventArgs e)
   {
       for (int i = 0; i < MilestoneChart.Legend.Items.Count; i++)
       {
           MilestoneChart.Legend.Items[i].Marker.Appearance.Figure = "Rectangle";
       
   }

Please note that the desired figure is set to Marker.Appearance.Figure property and not directly to the Marker itself.

Greetings,
Evgenia
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Chart (Obsolete)
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Jonathan
Top achievements
Rank 1
Melissa
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or