This is a migrated thread and some comments may be shown as answers.

Radhtmlcharts in codebehind

4 Answers 681 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
V
Top achievements
Rank 1
V asked on 20 Sep 2014, 01:53 AM
Hi
I am creating some charts and i have some requirement where
charts are rendered dynamically
ex: user 1 can have 3 charts, 1 line, 1 bar, 1 pie 
user2 can have 4 charts etc

also i need to provide dropdown on each chart so they can toggle back and forth so users can see same chart in pie/line/bar view etc

i was able to create charts in aspx and bind them in code behind but was looking if there is some sample available for creating charts from codebehind dynamically as some instances there could be 10 charts so i don't want to hardcode radhtml1, to 10 etc on aspx.

i need to provide drill downs also which i saw sample on telerik site which i will test and incorporate.
thanks for help

4 Answers, 1 is accepted

Sort by
0
V
Top achievements
Rank 1
answered on 22 Sep 2014, 01:18 PM
i was able to create charts programatically

for barchart i have couple of issues
1. DataLabelsField not working
2. tooltip shows undefined if i use clienttemplate
3. legend does not show up

below is the sample code, i am using q2 2013 telerik dll

   Dim chart1 As New RadHtmlChart()
        chart1.ID = "ch1"
        chart1.Width = Unit.Pixel(240)
        chart1.Height = Unit.Pixel(240)

        Dim chartData As New BarSeries
        For Each dr As DataRow In dt.Rows
            Dim item As New SeriesItem
            item.Name = dr("col1")
            item.YValue = dr("col2")
            chartData.Items.Add(item)
            chart1.PlotArea.XAxis.DataLabelsField = dr("col1")
            
        Next


        chartData.DataFieldY = ycol
        chart1.PlotArea.XAxis.MinorGridLines.Visible = False
        chart1.PlotArea.YAxis.MinorGridLines.Visible = False
        chart1.ChartTitle.Text = charttitle
        chartData.LabelsAppearance.Visible = True
        chart1.PlotArea.Series.Add(chartData)
        chart1.Legend.Appearance.Visible = True

        chartData.TooltipsAppearance.ClientTemplate = "#=dataItem.col3#"
0
Danail Vasilev
Telerik team
answered on 23 Sep 2014, 03:09 PM
Hello,

Please find my comments and suggestions below:

 - DataLabelsField property and templates that has this structure "#=dataItem.dataSourceFieldName#" require a data bound chart. More details on data bound charts and using clients templates is available in the following resources:
  Templates related articles and demos:

  Databinding related articles and demos:

  - Creating items programmatically requires that you use the corresponding series classes. More
information on the matter is available in the Important Changes Regarding Series Declaration help article.

 

  - Legend consists of series names. Therefore you should set the Name property of each series.

Regards,
Danail Vasilev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
V
Top achievements
Rank 1
answered on 25 Sep 2014, 09:49 PM
Thanks Danail
datalabels, tooltip issue was of case sensitive dataitems which got resolved.
legend, i have a requirement
1. can legend take line breaks or display each series/category in new line
2. can piecharts have color separator between each item
3. can tooltip font/styles can be changed, i tried OnClientSeriesHovered to change style but it did not work as it was overriding.
4. can x-axis labels be listed as legend in columnseries instead of overlapping labels any samples?. i see that new telerik dll have smart labels
0
Danail Vasilev
Telerik team
answered on 29 Sep 2014, 02:27 PM
Hi,

Please find my answers to your questions below:
  - Multiline labels - feature will be available in the upcoming Q3 2014. For the time being you can use the workaround provided in this feedback item.
  - Series border - You can use the workaround from this feedback item.
  - Tooltips appearance options - You can use the workaround from this feedback item.
  - x-axis labels issue - Can you please elaborate more about this issue? What is the actual and the expected behavior form the x-axis labels?

Regards,
Danail Vasilev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
V
Top achievements
Rank 1
Answers by
V
Top achievements
Rank 1
Danail Vasilev
Telerik team
Share this question
or