Width of column series doesn't go back to same width

4 posts, 1 answers
  1. Francisco
    Francisco  avatar
    11 posts
    Member since:
    Oct 2012

    Posted 10 Jun Link to this post

    Hi, I'm using telerik RadHtmlChart column series. I add the series dynamically in the code behind.

    In my first screen, after page_load, I have three series, (attachment named 3 series first) but then the user can select more series. When I select more than three series, for example 15 series (attachment named 15 series), the columns, of course, are thinner than the ones in the first screen. After that, if I select to show me 3 series (attachment named 3 series last), the columns width remains the same as when I selected the 15 series. The same happens if I select 30 or any other number with thinner columns than the 3 series case.

    I guess that the columns width should have been automatically adjusted according to the series quantity.

    Maybe there is a property or something that I could add and solve my problem.

    Please, any help would be appreciated.

    Here is part of the code:

    CliAltBajChart.PlotArea.XAxis.TitleAppearance.Text = "Mes";
    CliAltBajChart.PlotArea.XAxis.AxisCrossingValue = 0;
    CliAltBajChart.PlotArea.XAxis.MajorTickType = Telerik.Web.UI.HtmlChart.TickType.None;
    CliAltBajChart.PlotArea.XAxis.MinorTickType = Telerik.Web.UI.HtmlChart.TickType.None;
    CliAltBajChart.PlotArea.XAxis.MajorGridLines.Width = 2;

     

    CliAltBajChart.PlotArea.YAxis.TitleAppearance.Text = "Cantidad de clientes";
    CliAltBajChart.PlotArea.YAxis.MajorTickType = Telerik.Web.UI.HtmlChart.TickType.Outside;
    CliAltBajChart.PlotArea.YAxis.MinorTickType = Telerik.Web.UI.HtmlChart.TickType.Outside;
    CliAltBajChart.PlotArea.YAxis.LabelsAppearance.DataFormatString = "{0:N0}";

    ColumnSeries TotalClientes = new ColumnSeries();
    ColumnSeries Altas = new ColumnSeries();
    ColumnSeries Bajas = new ColumnSeries();
    List<EntCliente> LstC = new BusCliente().ObtenerClientes(0).ToList();

     

    string name = "Total de Clientes" + nombre;

    ColumnSeries TotalClientes = new ColumnSeries();
    TotalClientes.Name = name;
    TotalClientes.LabelsAppearance.Visible = false;
    TotalClientes.TooltipsAppearance.Color = System.Drawing.Color.White;
    TotalClientes.TooltipsAppearance.DataFormatString = "{0:N0}";

    ColumnSeries Altas = new ColumnSeries();
    Altas.Name = "Altas" + nombre;
    Altas.LabelsAppearance.Visible = false;
    Altas.LabelsAppearance.DataFormatString = "{0:N0}";
    Altas.TooltipsAppearance.Color = System.Drawing.Color.White;
    Altas.TooltipsAppearance.DataFormatString = "{0:N0}";

    ColumnSeries Bajas = new ColumnSeries();
    Bajas.Name = "Bajas" + nombre;
    Bajas.LabelsAppearance.Visible = false;
    Bajas.LabelsAppearance.Position = Telerik.Web.UI.HtmlChart.BarColumnLabelsPosition.Center;
    Bajas.LabelsAppearance.DataFormatString = "{0:N0}";
    Bajas.TooltipsAppearance.Color = System.Drawing.Color.White;
    Bajas.TooltipsAppearance.DataFormatString = "{0:N0}";

    CliAltBajChart.PlotArea.XAxis.Items.Clear();

    foreach (EntCliente e in LstC)
    {
        string mes = Convert.ToString(e.mes);
        CliAltBajChart.PlotArea.XAxis.Items.Add(mes);
        decimal? cantClientes = Convert.ToDecimal(e.cantClientes);

        TotalClientes.SeriesItems.Add(cantClientes);

        decimal? cantAltas = Convert.ToDecimal(e.cantAltas);
        Altas.SeriesItems.Add(cantAltas);

        decimal? cantBajas = Convert.ToDecimal(e.cantBajas);
        Bajas.SeriesItems.Add(cantBajas);  
    }

    CliAltBajChart.PlotArea.Series.Add(TotalClientes);
    CliAltBajChart.PlotArea.Series.Add(Altas);
    CliAltBajChart.PlotArea.Series.Add(Bajas);

    HtmlChartHolder.Controls.Add(CliAltBajChart);

  2. Francisco
    Francisco  avatar
    11 posts
    Member since:
    Oct 2012

    Posted 10 Jun Link to this post

    By the way, the same problem happens with the BarSeries. 
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Danail Vasilev
    Admin
    Danail Vasilev avatar
    1493 posts

    Posted 15 Jun Link to this post

    Hi Francisco,

    I guess this behavior happens because you don't clear the old series before adding the new ones and the ViewState of the chart and its container are true by default.

    If that is the case you can either clear the series, but ensure this is done after the chart itself is added to the page or disable the ViewState of the chart or its container element. More details are available in this feedback item - http://feedback.telerik.com/Project/108/Feedback/Details/125269

    Regards,
    Danail Vasilev
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.


  5. Francisco
    Francisco  avatar
    11 posts
    Member since:
    Oct 2012

    Posted 15 Jun in reply to Danail Vasilev Link to this post

    Great answer!!!

    Thanks a lot!!!

Back to Top