Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
creating a dynamic drilldown
posted

I am dyanmically creating a chart with the following code.  The chart is being created and rendered at run-time so there is no static object on any aspx page or form.  I would now like to add a drill down to the bars but can't figure out how to create it dynamically considering all the examples show use of the object's click event.  What options do I have.  here is the current charting code:

 UltraChart ultraChart1 = new UltraChart();

ultraChart1.ID = "UltraChart1";

DataTable mydata = new DataTable();mydata.Columns.Add("Label", typeof(string));

mydata.Columns.Add("OnPeak", typeof(double));

mydata.Columns.Add("OffPeak", typeof(double));

mydata.Rows.Add(new object[ {"Sat 3/1/2008",34,12});

mydata.Rows.Add(new object[ { "Sat 3/2/2008", 27, 8 });

mydata.Rows.Add(new object[ { "Sat 3/3/2008", 26, 9 });

System.IO.StringWriter stringWriter = new System.IO.StringWriter();HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

ultraChart1.Width = 650;

ultraChart1.Height = 400;

ultraChart1.Border.CornerRadius = 10;

ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.StackColumnChart;

ultraChart1.ColorModel.ModelStyle = ColorModels.CustomLinear;

ultraChart1.ColorModel.CustomPalette = new System.Drawing.Color[ { ApsOrange,ApsBlue };ultraChart1.Effects.Add(new Infragistics.UltraChart.Resources.Appearance.GradientEffect());

ultraChart1.DataSource = mydata;

ultraChart1.Data.DataBind();

ultraChart1.RenderControl(htmlWriter);

return stringWriter.ToString();

  • 5
    posted

    Go here for the basic setup:

    http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/Chart_WebChart_Set_Up_Drilldown_Charts.html

    but for the internal class do the following:  This assumes, based on the chartname passed in, you know what datasource you want for the drilldown

    internal class MyDrillDown : IDrillDown

     

        {

            private UltraChart myChart;

             private string chartName;

     

            public MyDrillDown(UltraChart chart, string chartName)

            {

                myChart = chart;

                this.chartName = chartName;

            }

     

            void Infragistics.UltraChart.Resources.IDrillDown.Drill(int row, int column,

              Infragistics.UltraChart.Shared.Styles.ChartType chartType,

              object dataSource)

            {

                // Initialize child chart

                myChart.ChartType = chartType;

                myChart.Drill.Enabled = false;

                switch (chartName)

                {

                    case"your Chart Name Here":

                        //build you datasource

                        break;

                    default:

                        break;

                }

     

                myChart.Data.DataSource = dataSource;

                myChart.Data.IncludeColumn(0, false);

                myChart.Data.IncludeColumn(1, false);

                myChart.Data.DataBind();

            }

        }

    }

     

    Then for you chart_ChartDataClicked event

    since the IDrillDown interface demands we have a datasource just pass a null when you call it because it will be handled in the internal class above's switch statement.

     

            private void Chart_ChartDataClicked(object sender, Infragistics.UltraChart.Shared.Events.ChartDataEventArgs e)

            {

                Chart.Drill.DrillElements[0].DrillDown.Drill(e.DataRow, e.DataColumn, ChartType.LineChart, null);

            }

     

     

  • 28496
    Offline posted

    if you're unable to add a server-side event handler, you can always handle the client-side click event.  the simplest drill-down scenario using client-side code would probably be to change the url using window.open or window.location.href, appending the current row and column numbers into a querystring.