We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

re: Binding a datasource to Chart

I have a SQLDataSource that is returning the name of a column and the count. How can I bind the chart to a this datasource?

For example the data source will return
A 5
B 6
C 7

5 Replies

AD Administrator Syncfusion Team October 14, 2006 12:24 PM UTC

Hi Melissa,

Thanks for using Syncfusion products.

Here is the sample, which explains:
1. Connecting SqlDataBase with Chart using ConnectionString.
2. Object for ChartDataBindModel is created to access the DataTable.
3. Assigning fields to X and Y Axis.
4. Setting the labels.

And then appearance can be changed as you like.

I hope this sample will help you.

Let me know if you have any more queries.

Thanks,
Sureshbabu


ChartDataBinding.zip


ME Melissa October 16, 2006 12:28 PM UTC

That's doing everything in the code behind. Is it possible to bind to the chart using a SqlDatasource:

< a s p:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connStr %>"
SelectCommand="spQ_MarketingCounts" SelectCommandType="StoredProcedure">


>Hi Melissa,

Thanks for using Syncfusion products.

Here is the sample, which explains:
1. Connecting SqlDataBase with Chart using ConnectionString.
2. Object for ChartDataBindModel is created to access the DataTable.
3. Assigning fields to X and Y Axis.
4. Setting the labels.

And then appearance can be changed as you like.

I hope this sample will help you.

Let me know if you have any more queries.

Thanks,
Sureshbabu


ChartDataBinding.zip


ME Melissa October 16, 2006 04:41 PM UTC

I still want to know if I can bind directly to a SQL Datasource, but I tried to bind using the way in the zip file and that doesn't work either. It seems as if it is pulling the values for the x series, but I can only see one and a half of them and there is no data being displayed in the column.

I've attached the code behind. The stored procedure spQ_MarketingCounts returns 2 columns- MarketingSource which has a list of sources for marketing and MarketingCounts which is the count for each source.


>That's doing everything in the code behind. Is it possible to bind to the chart using a SqlDatasource:

< a s p:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connStr %>"
SelectCommand="spQ_MarketingCounts" SelectCommandType="StoredProcedure">


>Hi Melissa,

Thanks for using Syncfusion products.

Here is the sample, which explains:
1. Connecting SqlDataBase with Chart using ConnectionString.
2. Object for ChartDataBindModel is created to access the DataTable.
3. Assigning fields to X and Y Axis.
4. Setting the labels.

And then appearance can be changed as you like.

I hope this sample will help you.

Let me know if you have any more queries.

Thanks,
Sureshbabu


ChartDataBinding.zip

MarketingCounts.ascx.zip


ME Melissa October 16, 2006 05:53 PM UTC

I figured out what I was doing wrong with the datasource. I wasn't selecting an ID and binding to it and it couldn't bind to the text.

>I still want to know if I can bind directly to a SQL Datasource, but I tried to bind using the way in the zip file and that doesn't work either. It seems as if it is pulling the values for the x series, but I can only see one and a half of them and there is no data being displayed in the column.

I've attached the code behind. The stored procedure spQ_MarketingCounts returns 2 columns- MarketingSource which has a list of sources for marketing and MarketingCounts which is the count for each source.


>That's doing everything in the code behind. Is it possible to bind to the chart using a SqlDatasource:

< a s p:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connStr %>"
SelectCommand="spQ_MarketingCounts" SelectCommandType="StoredProcedure">


>Hi Melissa,

Thanks for using Syncfusion products.

Here is the sample, which explains:
1. Connecting SqlDataBase with Chart using ConnectionString.
2. Object for ChartDataBindModel is created to access the DataTable.
3. Assigning fields to X and Y Axis.
4. Setting the labels.

And then appearance can be changed as you like.

I hope this sample will help you.

Let me know if you have any more queries.

Thanks,
Sureshbabu


ChartDataBinding.zip

MarketingCounts.ascx.zip


AD Administrator Syncfusion Team October 18, 2006 10:12 AM UTC

Hi Melissa,

Thanks for using Syncfusion products.

I am able to reproduce this issue.

‘ChartValueType’ property set to any one of Custom, Double, DateTime, Logarithmic.

To work with string datatype, you can have the ChartValueType property set to Custom. This property helps in implementing user-defined datatypes.

Please take a look at the sample. Let me know if this helps.

Thanks,
Sureshbabu


stringDataBinding.zip

Loader.
Live Chat Icon For mobile
Up arrow icon