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

Add legend to RadChartView, is possible? How?

9 Answers 416 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Antonio Ibáñez Oliva
Top achievements
Rank 1
Antonio Ibáñez Oliva asked on 25 Jul 2012, 09:05 AM
Hi, i want to add a legend to RadChartView. How?

Thanks

9 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 25 Jul 2012, 01:42 PM
Hi Antonio,

Thank you for writing.

Currently, RadChartView does not support legends. We will do our best to introduce such a functionality for Q3 2012.

I hope that you find this information useful.
 
Regards,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Traace
Top achievements
Rank 2
answered on 09 Aug 2012, 09:18 PM
Ok, 

We are in Q3 where are legends?? I've been using the ChartView control for a couple weeks now and I've had to look at your demo application to figure out most of how it works. The online documentation is lacking in my opinion on this control. 

Now that I've vented...

 I've noticed that you use a legend control in the Demo application with the ChartView control? It appears to me that it is a work in progress with adding the legend to the ChartView object. I really want this to work so when can we see some progress...I'm currently working on using your example "legends" code to create my own that we can use along with ChartView. I guess if i get my control working I'll post the code here so others can make use of it. Of course that is until you guys get it all worked out.

thanks..

Traace 
0
Stefan
Telerik team
answered on 14 Aug 2012, 02:45 PM
Hello Traace,

Thank you for writing.

The latest official release is Q2 2012 SP1. Q3 will be released sometime in October, so this is when the legends will exists. 

In regards to the documentation, we have tried to describe all of the currently available functionalities. If you have any comments or suggestions about it, feel free to write an email to documentation@telerik.com.

The legends in the demo application are just a custom control created for the matter of the example, so feel free to use it until the official legends are released.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Traace
Top achievements
Rank 2
answered on 24 Aug 2012, 06:44 PM
Ok to have your custom control you need the following files from the demo application:

1) LegendControl.cs
2) LegendElement.cs
3) LegendItemElement.cs

Now you need to modify the LegendControl.cs file here is the code:

using Telerik.WinControls;
using Telerik.WinControls.UI;
using System.Drawing;
using System.ComponentModel;
using System.Drawing.Design;
 
 
namespace SSIControl
{
     
    [ToolboxItem(true)]
    public class Legend : RadControl, IComponent
    {
        LegendElement legendElement = new LegendElement();
        //public event EventHandler Disposed;
 
        public Legend()
        {       
            //container.Add(this);
            InitializeComponent();       
        }
 
        protected override void CreateChildItems(RadElement parent)
        {
 
            base.CreateChildItems(parent);
            legendElement = new LegendElement();
            parent.Children.Add(legendElement);
 
            this.BackColor = Color.White;
        }              
 
        public void BuildLegend(RadChartElement element)
        {
            try
            {
                this.legendElement.BuildLegend(element);
            }
            catch (System.Exception ex)
            {
                RadMessageBox.Show(ex.ToString());
            }
        }
 
        private void InitializeComponent()
        {
            this.SuspendLayout();
            this.ResumeLayout(false);
        }
        
    }  
}

Note that i've added the Interface IComponent also you need to set [ToolBoxItem(true)] because inside the RadControl it is set to false. I'm sorry for the delay I've had this done for awhile now. Honestly you may not event need IComponent because its inherited in RadControl. Please no flames i'm just trying to help others that may have issues trying to create a legend. We will be using this until Telerik comes out with their version...so for us this was just a temporary fix.

PS> Look for these files in the Demo application provided by Telerik..go into the directory where Telerik is installed and you will find it. For us it was in the following: C:\Program Files (x86)\Telerik\RadControls for WinForms Q2 2012\Examples\QuickStart\ChartView

As with any control you should see it in your toolbox from the solution where you create it. Just drag and drop onto a form and your good to good. Also to test this use the Data class objects in the same directory as well as the csv file. That way you don't have to change much and you can get this working fast. ;-)

I'm no expert but this worked for us...If anyone can get some knowledge from it and it also helps them that is great!

Happy coding,

Traace
0
Stefan
Telerik team
answered on 29 Aug 2012, 06:02 AM
Hi Traace,

Thank you for sharing your solution with the community. I am sure that someone will benefit from it.

Just one thing to note. You have correctly guessed that since RadControl implements the IComponent interface, you do not need to do that explicitly in your descendant.
 
Greetings,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
codeputer
Top achievements
Rank 2
answered on 03 Nov 2012, 08:01 PM
Is there an update to this?  I'm using the RadCartesianChart and dynamically creating the series depending on what is found in the data.  The only thing that I'm missing is the legend. If I have to create my own control, how do I pick the color for each series?  Usign the Palette="Metro", the control nicely picks various colors for each series.

  

var DataWindow = context.MessageQueueStatus.Where(pMsg => pMsg.CaptureTime > SelectedDateTimeinUTC && pMsg.CaptureTime <= EndOfPeriod

 ).OrderByDescending(pMsg => pMsg.CaptureTime).ToList();


//retrieve a unique list of queue names within the period
var LineSeries = DataWindow.Select(pMsg => pMsg.GroupName).Distinct().OrderBy(pMsg => pMsg);

//remove if any previous series that may be here
this.chartQueues.Series.Clear();
  
//load each queue name as a series within the graph
foreach (var series in LineSeries)
{
  var lineseries = new LineSeries();
  lineseries.DisplayName = series;
  lineseries.ShowLabels = true;
  lineseries.CategoryBinding = new GenericDataPointBinding<SolArcMsgMonitor.DataLayer.MessageQueueStatu, DateTimeOffset>() { ValueSelector = Msg => Msg.CaptureTime.ToLocalTime() };
  lineseries.ValueBinding = new GenericDataPointBinding<SolArcMsgMonitor.DataLayer.MessageQueueStatu, int>() { ValueSelector = Msg => Msg.GrpTaskCount };
  lineseries.ItemsSource = DataWindow.Where(pMsg => pMsg.GroupName == series);
  this.chartQueues.Series.Add(lineseries);
}
0
Stefan
Telerik team
answered on 07 Nov 2012, 11:58 AM
Hi Richard,

Yes, there is an update. Legends are now available in the control out of the box. Information how to use them is available in our online documentation: http://www.telerik.com/help/winforms/chartview-features-legend.html.

I hope this helps.

Greetings,
Stefan
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Edward Wilde
Top achievements
Rank 1
answered on 07 Dec 2012, 01:56 PM
Is this feature available in the WPF ChartView?. Unless i'm mistaken the current Q32012 sample ChartView.WPF:Gallery->Bar->Example.xaml draws a legend using stackpanels and rectangles

Cheers

Ed.
0
Stefan
Telerik team
answered on 07 Dec 2012, 02:42 PM
Hi Edward,

This forum concerns RadChartView for WinForms. Please address it to the WPF forum where you can get appropriate answer: http://www.telerik.com/community/forums/wpf/charting-kit.aspx.

Kind regards,
Stefan
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
ChartView
Asked by
Antonio Ibáñez Oliva
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Traace
Top achievements
Rank 2
codeputer
Top achievements
Rank 2
Edward Wilde
Top achievements
Rank 1
Share this question
or