{"action":"opened","issue":{"url":"https://api.github.com/repos/novus/nvd3/issues/1836","repository_url":"https://api.github.com/repos/novus/nvd3","labels_url":"https://api.github.com/repos/novus/nvd3/issues/1836/labels{/name}","comments_url":"https://api.github.com/repos/novus/nvd3/issues/1836/comments","events_url":"https://api.github.com/repos/novus/nvd3/issues/1836/events","html_url":"https://github.com/novus/nvd3/issues/1836","id":180692158,"number":1836,"title":"Dumb Question: How to pass JSON generated by a PHP script to the \"datum()\"","user":{"login":"kavitama","id":5692413,"avatar_url":"https://avatars.githubusercontent.com/u/5692413?v=3","gravatar_id":"","url":"https://api.github.com/users/kavitama","html_url":"https://github.com/kavitama","followers_url":"https://api.github.com/users/kavitama/followers","following_url":"https://api.github.com/users/kavitama/following{/other_user}","gists_url":"https://api.github.com/users/kavitama/gists{/gist_id}","starred_url":"https://api.github.com/users/kavitama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kavitama/subscriptions","organizations_url":"https://api.github.com/users/kavitama/orgs","repos_url":"https://api.github.com/users/kavitama/repos","events_url":"https://api.github.com/users/kavitama/events{/privacy}","received_events_url":"https://api.github.com/users/kavitama/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-03T17:01:22Z","updated_at":"2016-10-03T17:01:22Z","closed_at":null,"body":"I am using a default PHP script to generate a JSON format to be displayed into a Pie chart.\r\n>     public function actionSelectWaysByDate()\r\n    {\r\n        $sql  = 'SELECT way_date as label, count(*) as value ';\r\n        $sql .= 'FROM one_way GROUP BY way_date';\r\n        $command = Yii::app()->db->createCommand($sql);\r\n        $ways = $command->queryAll();\r\n        //echo json_encode($ways);\r\n        echo CJSON::encode($ways);\r\n        //return CJSON::encode($ways);\r\n    }\r\nMy html page looks like this\r\n\r\n>     <script type=\"text/javascript\">\r\n        //Regular pie chart example\r\n        nv.addGraph(function() {\r\n            var chart = nv.models.pieChart()\r\n                .x(function(d) { return d.label })\r\n                .y(function(d) { return d.value })\r\n                .showLabels(true);\r\n            d3.select(\"#chart svg\")\r\n                .datum(statFixedJson())\r\n                .transition().duration(350)\r\n                .call(chart);\r\n            return chart;\r\n        });\r\n        nv.addGraph(function() {\r\n            var chart = nv.models.pieChart()\r\n                .x(function(d) { return d.label })\r\n                .y(function(d) { return d.value })\r\n                .showLabels(true)     //Display pie labels\r\n                .labelThreshold(.05)  //Configure the minimum slice size for labels to show up\r\n                .labelType(\"percent\") //Configure what type of data to show in the label. Can be \"key\", \"value\" or \"percent\"\r\n                .donut(true)          //Turn on Donut mode. Makes pie chart look tasty!\r\n                .donutRatio(0.35);     //Configure how big you want the donut hole size to be.\r\n            d3.select(\"#chart2 svg\")\r\n                .datum(statSqlJson())\r\n                .transition().duration(350)\r\n                .call(chart);\r\n            return chart;\r\n        });\r\n    </script>\r\n\r\nand my customized javascript is like this\r\n\r\n> function statFixedJson() {\r\n    return  [\r\n        {\r\n            \"label\": \"Eventuales\",\r\n            \"value\" : 201\r\n        } ,\r\n        {\r\n            \"label\": \"Abonados\",\r\n            \"value\" : 132\r\n        } ,\r\n        {\r\n            \"label\": \"Abonados Parciales\",\r\n            \"value\" : 61\r\n        } ,\r\n        {\r\n            \"label\": \"Cuponeros\",\r\n            \"value\" : 120\r\n        } ,\r\n        {\r\n            \"label\": \"Sin Cargo\",\r\n            \"value\" : 2\r\n        } ,\r\n    ];\r\n}\r\nfunction statSqlJson() {\r\n    return [\r\n        $.getJSON(\r\n            'selectWaysByDate',\r\n            function (data) {\r\n                console.log(data);\r\n            }\r\n        )\r\n    ];\r\n}\r\n"}}
{"actor":{"display_login":"kavitama"}}