hi all again, i asked you about muptiple line series in radchart in this post: https://www.telerik.com/forums/multiple-line-series-radhtmlchart
I created RadHtmlChart with the same parameters as previous post and using SqlDataSource. And this is my ASPX code:
<
telerik:RadHtmlChart
ID
=
"RadHtmlChart1"
runat
=
"server"
DataSourceID
=
"dsJournal"
><
br
> <
PlotArea
><
br
> <
YAxis
MaxValue
=
"100"
MinValue
=
"-100"
><
br
> </
YAxis
><
br
> <
Series
><
br
> <
telerik:LineSeries
DataFieldY
=
"param_d"
Name
=
"LineSeries1"
><
br
> </
telerik:LineSeries
><
br
> <
br
> </
Series
><
br
> <
XAxis
DataLabelsField
=
"sensor_type"
><
br
> <
LabelsAppearance
RotationAngle
=
"-90"
Visible
=
"false"
></
LabelsAppearance
><
br
> </
XAxis
><
br
> <
CommonTooltipsAppearance
Visible
=
"true"
Shared
=
"true"
/><
br
> <
YAxis
Step
=
"10000"
></
YAxis
><
br
> </
PlotArea
><
br
> <
br
> </
telerik:RadHtmlChart
>
This is my C# code with setting RadHtmlChart:
protected
void
RadChart1_ItemDataBound(
object
sender, ChartItemDataBoundEventArgs e)<br> {<br> e.SeriesItem.Name = (
string
) DataBinder.Eval(e.DataItem,
"sensor_type"
);<br> }
Bellow i will attach two picture:
1. what i have right now in RadHtmlChart with one LineSeries
2. the same structure table from database, where i need only a column "sensor_type" for multiple LineSeries in RadHtmlChart.
Thank you for your attention, i hope you will help me, and sorry for two similar post
7 Answers, 1 is accepted
I advise that you review the information I provided in the other thread to see how to data bind a RadHtmlChart. It is important to add that it does not have server-side events: https://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/troubleshooting/known-issues/known-limitations. If you will be creating series dynamically, you must set their properties when you create them, you cannot do this in a DataBoud-type server event.
Regards,
Marin Bratanov
Progress Telerik
The following sample shows one way you can group the data source so it gets split into the separate fields the chart needs: https://www.telerik.com/support/code-library/group-radhtmlchart-data-source.
Regards,
Marin Bratanov
Progress Telerik
thank u, Marin Bratanov, for answer.
so i understand correctly that this is impossible make with help SqlDataSource or other DataBound? Just like manually?
than You for answer
It is possible, and you can data bind multiple series to a chart through an SqlDataSource.
What is important is that you provide data in the proper shape to the chart, as described in the following documentation article: https://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/data-binding/overview.
If you cannot provide such shape from the database, you need to write some additional code in order to create the needed shape programmatically, as shown in the following post: https://www.telerik.com/support/code-library/group-radhtmlchart-data-source.
This will allow you to data bind multiple series.
Regards,
Marin Bratanov
Progress Telerik
hi , Mark Bratanov, thank you for answer
can i do this (group radhtmlchart data source multi line series) via JavaScript?
You can see how to use JavaScript objects to bind the chart in the following resources:
- https://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/client-side-programming/overview#modify-the-radhtmlcharts-data-source-on-the-client
- https://demos.telerik.com/aspnet-ajax/htmlchart/examples/clientsidedatabinding/defaultcs.aspx
You need to declare the series and their fields from the server, so it is likely that you will have to perform the grouping on the server so you can know the field names. If you can predict the field names, you can use JavaScript to group your data and then pass it to the chart.
Regards,
Marin Bratanov
Progress Telerik