Click here to Skip to main content
15,888,053 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all,

I have generated charts dynamically in tab panel. The problem I faced now is when many charts are generated, it generates side by side each other. How do I only have 1 chart in each row instead of having them being displayed horizontally side by side together? Each chart is supposed to be on 1 row each.

This is what I currently see when I executed my program: http://i.stack.imgur.com/2lnIR.png[^]

This is what I want to achieve: http://i.stack.imgur.com/CAMUf.png[^]

This is my codes:
ASP.NET
//Aspx file
 <div>
             <asp:scriptmanager ID="ScriptManager1" runat="server">
            </asp:scriptmanager>
        </div>
        <asp:updatepanel ID="UpdatePanel1" runat="server" ScrollBars="Horizontal">
            <contenttemplate>
        <asp:placeholder ID="PlaceHolder1" runat="server"></asp:placeholder>

            </contenttemplate>
        </asp:updatepanel>

//Cs file
AjaxControlToolkit.TabContainer container = new AjaxControlToolkit.TabContainer();
            container.ID = "TabContainer";
            container.EnableViewState = false;
            container.Tabs.Clear();

foreach (ListItem item in SelectionListBox.Items)
        {
            if (item.Selected)
            {
                Label tabContent = new Label();
                tabContent.ID = "lbl_tab_";
                tabContent.Text += item.Value;

Chart Chart1 = new Chart();
                        Chart1.DataSource = dt;
                        Chart1.Width = 715;
                        Chart1.Height = 450;

                        Chart1.Series.Add(new Series());
                        Chart1.Series[0].ChartType = SeriesChartType.BoxPlot;
                        List<object> List1 = dt_LVL1RISKCHART.AsEnumerable().ToList<object>();

                        foreach (DataRow row in dt.Rows)
                            Chart1.Series[0].Points.AddXY(row["STATUS"], new object[] { row["MIN"], row["MAX"], row["25TH_PERCENTILE"], row["75TH_PERCENTILE"], row["AVG"], row["50TH_PERCENTILE"] });

                        //create chartareas
                        ChartArea ca = new ChartArea();
                        ca .AxisX = new Axis();
                        ca .AxisY = new Axis();
                        Chart1.ChartAreas.Add(ca);

                        //databind
                        Chart1.DataBind();
                        Chart1.Visible = true;

                AjaxControlToolkit.TabPanel panel = new AjaxControlToolkit.TabPanel();
                panel.HeaderText += item.Value;
                container.Tabs.Add(panel);
                panel.Controls.Add(tabContent);
                panel.Controls.Add(Chart1);
            }
        }
        PlaceHolder1.Controls.Add(container);
    }

    public AjaxControlToolkit.TabPanel GetManualTab()
    {
        AjaxControlToolkit.TabPanel panel = new AjaxControlToolkit.TabPanel();
        return panel;
    }

Question: how do I display only 1 chart at each row in tab panel if there are many charts being generated at one go?

I need help on this, appreciate if someone can provide me help on this, thanks a lot!!
Posted
Comments
Ralf Meier 7-Oct-15 3:41am    
If you generate your Charts dynamicly ... why don't you set the Location of the Chart(s) also in this way (and perhaps also the Size) ?

1 solution

use

C#
chart.Legends["Legend1"].Position.Auto = false;

chart.Legends["Legend1"].Position = new ElementPosition(x, y, Height, Width);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900