Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to take values from a json array and use in highchart

Posted on 2013-01-09
2
Medium Priority
?
2,229 Views
Last Modified: 2013-01-09
Hi,
I'm painfully new at this so my explanation may not be the best.

I have a number of div's being populated as a result of a call to mysql database. I am trying to use a few of the values in the return json to populate a highcharts column as well.

I can't figure out how to get at the returned values that I'm using for the div's so I can populate my chart as well with some of them.

Code example (simplified so you can see the issue easier).

How to get the data.phonetotal, data.uniquetotal and data.texttotal into the first values of my chart as the example??

$(document).ready( function () {

 $.get("assets/db/contest_history_detail.php?contest_id=" + $("select[name='contests']").val(),
   function(data){
	$('#stat1').html( data.phonetotal );
	$('#stat2').html( data.uniquetotal );
	$('#stat3').html( data.texttotal );
   }, "json");
   
 var chart;
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'bars',
                 backgroundColor: 'rgba(255,255,255,0)',
                type: 'column'
            },
             series: [{
                name: 'This Contest',
                data: [?, ?, ?]
    
            }, {
                name: 'Last Contest',
                data: [10, 4, 3]
              
            }]
        });
    });

Open in new window


Any help would be very much appreciated.

In case it helps, this is what is being echo'd back to my page when the mysql request is made:
echo json_encode(array(
"phonetotal"=>$phonetotal,
"uniquetotal"=>$uniquetotal,
"texttotal"=>$texttotal));

Open in new window

0
Comment
Question by:tjyoung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
sivagnanam chandrakanth earned 2000 total points
ID: 38758554
So the problem is getting the returned array into hightchart..If yes, below is the solution

move your highchart code into function(data){ ......} and pass data like below

series: [{
                name: 'This Contest',
                data: data
   
            },
0
 
LVL 1

Author Closing Comment

by:tjyoung
ID: 38759440
Thanks simple as you described. Much appreciated
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

721 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