Jump to content

Search the Community

Showing results for tags 'nvd3'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi, I'm absolutely stuck with this piece of code, I've searched and searched to get it working and have failed miserably. It also doesn't help that I'm brand new to php My Json output currently looks like this [ { "key": "OWM1", "values": [ [ "x : EW", "y :4" ], [ "x : RSE", "y :3" ], [ "x : SWE", "y :2" ], [ "x : WTE", "y :1" ], [ "x : WWE", "y :1" ] ] }, { "key": "OWM2", "values": [ [ "x : EW", "y :4" ], [ "x : RSE", "y :2" ], [ "x : SWE", "y :1" ], [ "x : WTE", "y :3" ], [ "x : WWE", "y :2" ] ] } ] But I need it to look like this for the sake of NVD3 chart to be able to process it correctly. [ { "key": "OWM1", "values": [ { x : "EW", y : 4 }, { x : "RSE", y : 3 }, { x : "SWE", y : 2 } { x : "WTE", y : 1 } { x : "WWE", y : 21 } ] }, { key: "OWM2", values: [ { x : "EW", y : 4 }, { x : "RSE", y : 2 }, { x : "SWE", y : 1 } { x : "WTE", y : 3 } { x : "WWE", y : 2 } ] }] Here is my PHP code that I am producing the first output of json with. $result = mysqli_query($con,"SELECT CODE, _POS, COUNT(CODE) AS COUNT from defects WHERE FPOS IN ('OWM1','OWM2') GROUP BY POS, CODE"); if($result) { $jsonData = convert($result); } function convert($result) { $intermediate = array(); while($rows = mysqli_fetch_assoc($result)) { $key = $rows['POS']; $x = $rows['CODE']; $y = $rows['']; $intermediate[$key][] = array('x : ' .$x,'y :' . $y); } $output = array(); foreach($intermediate as $key => $values) { $output[] = array( "key" => $key, 'values' => $values ); } echo json_encode($output); } mysqli_close($con); Is there any way anyone could help me manipulate the code I have to look exactly like the second set of JSON code that is compatible with NVD3 charts? Thanks alot.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.