Solved

Help with a kendo chart

Posted on 2014-09-22
5
302 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 108

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now