How do I do to put a legend

Thread is closed for posting
2 posts, 0 answers
  1. Paulo
    Paulo avatar
    56 posts
    Member since:
    Apr 2012

    Posted 18 Apr 2012 Link to this post

    This is my source code. I need to put a legend and Month/Year on XAxis. How do I do? Below my code.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    using Telerik.Charting;
    using System.Data.OracleClient;
    using System.Data.SqlClient;
    using System.IO;
    using System.Data;
    using System.Configuration;
    using System.Text.RegularExpressions;
    using System.Text;


    namespace GetNet.Monitoracao.UI.Web.Graficos
    {
        public partial class DesempenhoMensal : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                //Cria o objeto Chart, base de todos os gráficos
                RadChart radChart1 = new RadChart();
                radChart1.ChartTitle.TextBlock.Text = "EVOLUÇÃO MENSAL APROVADAS DÉBITO";            


                //Muda a cor de fundo do gráfico para transparente
                radChart1.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
                radChart1.Appearance.FillStyle.MainColor = System.Drawing.Color.Transparent;
                radChart1.PlotArea.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
                radChart1.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.Color.Transparent;
                this.Controls.Add(radChart1);


                RadChart radChart2 = new RadChart();
                radChart2.ChartTitle.TextBlock.Text = "EVOLUÇÃO MENSAL APROVADAS CRÉDITO";


                //Muda a cor de fundo do gráfico para transparente
                radChart2.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
                radChart2.Appearance.FillStyle.MainColor = System.Drawing.Color.Transparent;
                radChart2.PlotArea.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
                radChart2.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.Color.Transparent;
                this.Controls.Add(radChart2);
                                        
                ChartSeries chartSeries1 = radChart1.CreateSeries("DEBITO", System.Drawing.Color.LightBlue, System.Drawing.Color.LightBlue, ChartSeriesType.Bar);
                ChartSeries chartSeries2 = radChart2.CreateSeries("CRÉDITO", System.Drawing.Color.LightCyan, System.Drawing.Color.LightCyan, ChartSeriesType.Bar);
                ChartSeries chartSeries3 = radChart1.CreateSeries("DEBITO", System.Drawing.Color.LightGreen, System.Drawing.Color.LightGreen, ChartSeriesType.Bar);
                ChartSeries chartSeries4 = radChart2.CreateSeries("CREDITO", System.Drawing.Color.Silver, System.Drawing.Color.Silver, ChartSeriesType.Bar);


                chartSeries1.Type = ChartSeriesType.Bar;
                chartSeries2.Type = ChartSeriesType.Bar;
                chartSeries3.Type = ChartSeriesType.Bar;
                chartSeries4.Type = ChartSeriesType.Bar;


                chartSeries1.;


                //A orientação do gráfico
                radChart1.SeriesOrientation = ChartSeriesOrientation.Vertical;
                radChart2.SeriesOrientation = ChartSeriesOrientation.Vertical;
                
                //Tamanho da área do gráfico em pixels
                radChart1.Height = 300;
                radChart1.Width  = 800;


                radChart2.Height = 300;
                radChart2.Width = 800;


                int[] dataArray1 = new int[] { 12, 56, 23, 89, 12, 56, 34, 78, 32, 56 };
                int[] dataArray3 = new int[] { 2, 6, 53, 19,22, 36, 34, 18, 42, 26 };




                foreach (int i in dataArray1) {
                    chartSeries1.AddItem(i, "");
                }
                foreach (int i in dataArray3)
                {
                    chartSeries3.AddItem(i, "");
                }
                
                int[] dataArray2 = new int[] { 42, 16, 13, 9, 12, 86, 30, 38, 62, 26 };
                int[] dataArray4 = new int[] { 32, 36, 10, 39, 72, 16, 20, 58, 82, 36 }; 
                            
                foreach (int I in dataArray2)
                {
                    chartSeries2.AddItem(I, "");
                }
                foreach (int I in dataArray4)
                {
                    chartSeries4.AddItem(I, "");
                }
            }
        }
    }
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 23 Apr 2012 Link to this post

    Hello Paulo,

    You can examine our online examples here.
    The Numerical Axis example demonstrates how you can use DateTime for the X axis.

    If you are new to our controls I suggest that you explore our online examples and help so that you get familiar with the chart's features, possibilities, limitations and how-to's.  

    Regards,
    Petar Marchev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top