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

Set Chart Title with Data from Data Source

3 Answers 33 Views
Charts
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 26 Oct 2015, 09:52 PM
Is it possible to use data from my data source to initially set the title of a chart?  I am using JSON and when my data is returned I want to take a field i.e. Title and use the value to initialize my chart title.

3 Answers, 1 is accepted

Sort by
0
Iliana Nikolova
Telerik team
answered on 28 Oct 2015, 03:58 PM
Hi James,

For this I would suggest setting title via the chart.options in the dataBound event. For your I prepared a basic dojo.

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
James
Top achievements
Rank 1
answered on 28 Oct 2015, 06:32 PM

Thanks for the reply.  Is it possible to have a datasource similar to the following that will work in the dojo you showed?  It seems little clunky to have the title in the list of comments.

var chartInfo = {
    "chartTitle": "Chart Title",
    blogComments = [ {
        "blog": "My blog",
        "day": "1",
        "value": 3,
        "userColor": "#ffd600",
         
      }, {
        "blog": "My blog",
        "day": "2",
        "value": 7,
        "userColor": "#ffd600"
      }, {
        "blog": "My blog",
        "day": "3",
        "value": 12,
        "userColor": "#ffd600"
      }, {
        "blog": "My blog",
        "day": "4",
        "value": 15,
        "userColor": "#ffd600"
      }
    ]
};

0
EZ
Top achievements
Rank 2
answered on 28 Oct 2015, 07:57 PM

 Updated DOJO:  http://dojo.telerik.com/@ezanker/UHase

$("#chart").kendoChart({
  title: chartInfo.chartTitle,
  dataSource: {
    data: chartInfo.blogComments
  },...

Tags
Charts
Asked by
James
Top achievements
Rank 1
Answers by
Iliana Nikolova
Telerik team
James
Top achievements
Rank 1
EZ
Top achievements
Rank 2
Share this question
or