Solved

Help with a kendo chart

Posted on 2014-09-22
5
307 Views
Last Modified: 2014-09-22
Hello,

I need a little help with a kendo chart.  I have attached my "attempt" below.

What i am trying to do is have a bar chart with 12 bars each with a single value.  I need to give each bar a seperate colour.  An example is shown below.

I am trying to separate my data from everything else such as the bar colours.  

I am not a JS expert, or kendo expert!, and i can't seem to get the chart working.  I think i am 80% there but there is an error(s) in the code.

How it should look
<script>
 
  var  zdata = 
                [{"name": "Vanföreställningar", "data": "4"},
                {name: "Hallucinationer", data: [4]},
	{name: "Agitation/aggressivitet",data: [9]},
                {name: "Depression/dysfori", data: [4]},
                {name: "Ångest", data: [2]},
                {name: "Eufori/upprymdhet", data: [1]},
                {name: "Apati/likgiltighet", data: [9]},
                {name: "Hämningslöshet", data: [6]},
                {name: "Irritabilitet/labilitet", data: [4]},
                {name: "Motorisk av. beteende",data: [2]},
                {name: "Sömn", data: [4]},
                {name: "Aptit/ätstörningar", data: [12]}] ;

  
$("#chart").kendoChart({

  categoryAxis: { field: "name"},
  datasource:{data: zdata},
  series: [{field: "data" }],

  seriesColors: ["STEELBLUE", "FIREBRICK", "GOLD", "LIGHTBLUE", "INDIANRED", "DIMGREY", "MEDIUMBLUE", "POWDERBLUE",  "GREY", "MEDIUMVIOLETRED", "GREEN","SKYBLUE" ],
	legend: { visible: true, position: "bottom" }}
                      );
</script>

Open in new window

0
Comment
Question by:soozh
  • 2
  • 2
5 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40336557
Have you tried putting quotes around the fields in the zdata JSON?
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40336727
http://jsfiddle.net/9VZdS/342/

  $("#chart").kendoChart({
      series: [{
          name: "Vanföreställningar",
          data: [3]
      }, {
          name: "Hallucinationer",
          data: [4]
      }, {
          name: "Agitationaggressivitet",
          data: [9]
      }, {
          name: "Depression/dysfori",
          data: [4]
      }, {
          name: "Ångest",
          data: [2]
      }, {
          name: "Eufori/upprymdhet",
          data: [1]
      }, {
          name: "Apati/likgiltighet",
          data: [9]
      }, {
          name: "Hämningslöshet",
          data: [6]
      }, {
          name: "Irritabilitet/labilitet",
          data: [4]
      }, {
          name: "Motorisk av. beteende",
          data: [2]
      }, {
          name: "Sömn",
          data: [4]
      }, {
          name: "Aptit/ätstörningar",
          data: [12]
      }],
      seriesColors: ["STEELBLUE", "FIREBRICK", "GOLD", "LIGHTBLUE", "INDIANRED", "DIMGREY", "MEDIUMBLUE", "POWDERBLUE", "GREY", "MEDIUMVIOLETRED", "GREEN", "SKYBLUE"],
      legend: {
          position: "bottom"
      }
  });

Open in new window


Couldn't get it to work using a datasource
0
 

Author Comment

by:soozh
ID: 40337265
ok thanks.  How would i update the chart with new data?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40337343
Thats a different question.
0
 

Author Closing Comment

by:soozh
ID: 40337736
i guess you  have a point... see my next question.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Placeholder text not disappearing in Contact Form 7 2 16
javascript comparing two dates 3 18
Google Maps API and PHP 25 30
where is team.js? 3 25
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question