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

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

3 Answers 93 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Francisco
Top achievements
Rank 1
Francisco asked on 10 Jun 2016, 09:08 PM

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);

3 Answers, 1 is accepted

Sort by
0
Francisco
Top achievements
Rank 1
answered on 10 Jun 2016, 10:07 PM
By the way, the same problem happens with the BarSeries. 
0
Accepted
Danail Vasilev
Telerik team
answered on 15 Jun 2016, 01:54 PM
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.


0
Francisco
Top achievements
Rank 1
answered on 15 Jun 2016, 02:26 PM

Great answer!!!

Thanks a lot!!!

Tags
Chart (HTML5)
Asked by
Francisco
Top achievements
Rank 1
Answers by
Francisco
Top achievements
Rank 1
Danail Vasilev
Telerik team
Share this question
or