in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Adding a webchartcontrol to a page at runtime

Last post 10/22/2008 2:43 PM by Ernesto Pedraza. 7 replies.
Page 1 of 1 (8 items)
Sort Posts:
Previous Next
  • 6/1/2007 3:36 AM

    Adding a webchartcontrol to a page at runtime

    Hi all,

    I've tried to add a webchartcontrol with a seriestemplate to a web page for a while now without success. I check the online documentation but even on the webchartcontrol.seriestemplate property section the example given is for the windows chartcontrol. The last line of it _chartcontrol.Dock = DockStyle.Fill doesn't seem to apply to the webcontrol.

    Can anybody tell what I'm doing wrong?

    Thanks,
    Sebastian

    This is my code:

    String _query = "SELECT SalesPerson, Product, SUM(Sales) Sales FROM Products;";
    DataSet _ds = new DataSet();
    SqlDataAdapter _adap = new SqlDataAdapter(_query, _con);
    _adap.Fill(_ds);

    WebChartControl chart = new WebChartControl();
    chart.DataAdapter = _adap;
    chart.DataSource = _ds.Tables[0];

    chart.SeriesDataMember =
    "SalesPerson";
    chart.SeriesTemplate.ValueDataMembers.AddRange(
    new string[] { "Sales" });
    chart.SeriesTemplate.ArgumentDataMember =
    "Product";
    chart.SeriesTemplate.View =
    new StackedBarSeriesView();

    this.form1.Controls.Add(chart);

     

  • 6/1/2007 9:22 AM In reply to

    Re: Adding a webchartcontrol to a page at runtime

    Hi Sebastian,

    The WebChartControl doesn't have the Dock property, and hence it can't be specified. Please try the code below to create a WebChartControl at runtime (note that you need to specify your own credentials when creating an SqlDataSource object instead of "YourServerName", "YourDatabaseName" and other parameters).


    protected void Page_Load(object sender, EventArgs e) {
        SqlDataSource dataSource = new SqlDataSource("Data Source=YourServerName;Initial Catalog=YourDatabaseName;Persist Security Info=True;User ID=YourUserID;Password=YourPassword", "SELECT SalesPerson, Product, SUM(Sales) Sales FROM Products");
        WebChartControl chart = new WebChartControl();
        chart.Width = 500;
        chart.Height = 300;
        chart.DataSource = dataSource;

        chart.SeriesDataMember = "SalesPerson";
        chart.SeriesTemplate.ArgumentDataMember = "Product";
        chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Sales" });
        chart.SeriesTemplate.View = new StackedBarSeriesView();
        this.Controls.Add(chart);
    }


    Does this work for you?

    @.
    R&D, .NET Team.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/sc.
  • 6/11/2007 9:05 AM In reply to

    Re: Adding a webchartcontrol to a page at runtime

    Will this code work in a button click event or does it have to run in the Page_Load event?
     
    Rob
  • 9/12/2008 10:55 AM In reply to

    Re: Adding a webchartcontrol to a page at runtime

    Hi Alan, what is the method or property to add or change the title of the webchartcontrol?

  • 9/17/2008 10:07 AM In reply to

    Re: Adding a webchartcontrol to a page at runtime

    Hello Ernesto,

    You can add titles to a chart via the WebChartControl.Titles collection. Or do you need something else?

    @.
    R&D, .NET Team.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/sc.
  • 10/10/2008 12:21 PM In reply to

    Re: Adding a webchartcontrol to a page at runtime

    Yes thats what I looking for, so I've another question. It's about saving a chart (from a webchartcontrol) to PDF, I was trying with the version 8.1 but I can't do it 'cause my chart has no printing available property set in true (ex. ((chart_resultado as IChartContainer).Chart.IsPrintingAvailable) is always false), I try using the printlibrary but it can't link with my webchartcontrol then I found this issues (Q50754 and Q50742) about isn't possible pass to PDF directly but the answer date is from 11/8/2007 so, with the new version 8.1 or 8.2 its possible do this? I found another method (ASPxClientWebChartControl.SaveToDisk Method) but I don't know how to apply it and when I try to see it on the demo site (for example this), the function of save to PDF doesn't works and it doesn't show the code about the functions in the toolbar in the code area. I work with C# 2008, if you have any idea about this give me an example or a reference please.

    Best regards

     

  • 10/14/2008 9:59 AM In reply to

    Re: Adding a webchartcontrol to a page at runtime

    Hi Ernesto,

    I've prepared an example for you at http://www.devexpress.com/example=E544.

    Does this help you?

    @.
    R&D, .NET Team.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center at http://www.devexpress.com/sc.
  • 10/22/2008 2:43 PM In reply to

    Re: Adding a webchartcontrol to a page at runtime

    Hi Alan, thanks a lot for the example it works perfectly

    Best regards

Page 1 of 1 (8 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED