data from database to fusioncharts in laravel
I want to display the data from the database to myFusionCharts in laravel but somehow I got stuck. I can't find any answers from the documentations since they use predefined dataset in their sample.
Any help would be much appreciated.
This is my controller:
public function index()
{
$subj = DB::Table('tbl_subjects')
->select('subject')
->get();
// ->toArray()
foreach ( $subj as $s){
// $c = $s->subject;
$c = DB::table('tbl_ordinances')
->where('subject', 'like', '%'.$s->subject.'%')
->get()
->count();
}
// dd($subj,$c);
return view('statistics',compact('subj','c'));
}
I " dd($subj,$c); " and it returns this values:
Collection {#302 ▼
#items: array:9 [▼
0 => {#309 ▼
+"subject": "Peace & Order and Public Safety"
}
1 => {#311 ▼
+"subject": "Infrastructure"
}
2 => {#312 ▼
+"subject": "Livelihood/ Poverty Reduction"
}
3 => {#313 ▼
+"subject": "Finance/ Investment"
}
4 => {#314 ▼
+"subject": "Administrative Development"
}
5 => {#315 ▼
+"subject": "Agricultural Development"
}
6 => {#316 ▼
+"subject": "Social Services"
}
7 => {#317 ▼
+"subject": "Environment and Disaster Management"
}
8 => {#318 ▼
+"subject": "Tourism"
}
]
}
array:9 [▼
0 => 2
1 => 0
2 => 0
3 => 0
4 => 4
5 => 0
6 => 3
7 => 6
8 => 1
]
This is my blade:
<script type="text/javascript">
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'pie2d',
renderAt: 'chart-container',
width: '500',
height: '500',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Municipal Ordinances by subject categories",
// "subCaption": "Last year",
"numberPrefix": null,
"showPercentInTooltip": "1",
"decimals": "1",
"theme": "fusion",
},
"data": [ // I want THOSE VALUES HERE... but I don't know how..
{"label": "h","value": "25" },
{"label": "h2","value": "25"},
{"label": "h3","value": "55"},
]
}
}).render();
});
</script>
<div id="chart-container">FusionCharts will render here..</div>
javascript php laravel-5 fusioncharts
add a comment |
I want to display the data from the database to myFusionCharts in laravel but somehow I got stuck. I can't find any answers from the documentations since they use predefined dataset in their sample.
Any help would be much appreciated.
This is my controller:
public function index()
{
$subj = DB::Table('tbl_subjects')
->select('subject')
->get();
// ->toArray()
foreach ( $subj as $s){
// $c = $s->subject;
$c = DB::table('tbl_ordinances')
->where('subject', 'like', '%'.$s->subject.'%')
->get()
->count();
}
// dd($subj,$c);
return view('statistics',compact('subj','c'));
}
I " dd($subj,$c); " and it returns this values:
Collection {#302 ▼
#items: array:9 [▼
0 => {#309 ▼
+"subject": "Peace & Order and Public Safety"
}
1 => {#311 ▼
+"subject": "Infrastructure"
}
2 => {#312 ▼
+"subject": "Livelihood/ Poverty Reduction"
}
3 => {#313 ▼
+"subject": "Finance/ Investment"
}
4 => {#314 ▼
+"subject": "Administrative Development"
}
5 => {#315 ▼
+"subject": "Agricultural Development"
}
6 => {#316 ▼
+"subject": "Social Services"
}
7 => {#317 ▼
+"subject": "Environment and Disaster Management"
}
8 => {#318 ▼
+"subject": "Tourism"
}
]
}
array:9 [▼
0 => 2
1 => 0
2 => 0
3 => 0
4 => 4
5 => 0
6 => 3
7 => 6
8 => 1
]
This is my blade:
<script type="text/javascript">
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'pie2d',
renderAt: 'chart-container',
width: '500',
height: '500',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Municipal Ordinances by subject categories",
// "subCaption": "Last year",
"numberPrefix": null,
"showPercentInTooltip": "1",
"decimals": "1",
"theme": "fusion",
},
"data": [ // I want THOSE VALUES HERE... but I don't know how..
{"label": "h","value": "25" },
{"label": "h2","value": "25"},
{"label": "h3","value": "55"},
]
}
}).render();
});
</script>
<div id="chart-container">FusionCharts will render here..</div>
javascript php laravel-5 fusioncharts
you need to create the data object as label value, since this is the prescribed format for pie chart in fusioncharts, for example: "data":[{ "label":"Peace & Order and Public Safety", "value":"2" }, .....// rest of your data ]
– Zapdos13
Nov 26 '18 at 5:42
@Zapdos13 no, there's a big problem with that.. the values won't update in the chart. If I added more documents and put a subject Peace & Order, the column count will be 3. but the chart will always show 2 unless I edit again the javascipt which is inappropriate.
– Zukitung
Nov 26 '18 at 7:54
add a comment |
I want to display the data from the database to myFusionCharts in laravel but somehow I got stuck. I can't find any answers from the documentations since they use predefined dataset in their sample.
Any help would be much appreciated.
This is my controller:
public function index()
{
$subj = DB::Table('tbl_subjects')
->select('subject')
->get();
// ->toArray()
foreach ( $subj as $s){
// $c = $s->subject;
$c = DB::table('tbl_ordinances')
->where('subject', 'like', '%'.$s->subject.'%')
->get()
->count();
}
// dd($subj,$c);
return view('statistics',compact('subj','c'));
}
I " dd($subj,$c); " and it returns this values:
Collection {#302 ▼
#items: array:9 [▼
0 => {#309 ▼
+"subject": "Peace & Order and Public Safety"
}
1 => {#311 ▼
+"subject": "Infrastructure"
}
2 => {#312 ▼
+"subject": "Livelihood/ Poverty Reduction"
}
3 => {#313 ▼
+"subject": "Finance/ Investment"
}
4 => {#314 ▼
+"subject": "Administrative Development"
}
5 => {#315 ▼
+"subject": "Agricultural Development"
}
6 => {#316 ▼
+"subject": "Social Services"
}
7 => {#317 ▼
+"subject": "Environment and Disaster Management"
}
8 => {#318 ▼
+"subject": "Tourism"
}
]
}
array:9 [▼
0 => 2
1 => 0
2 => 0
3 => 0
4 => 4
5 => 0
6 => 3
7 => 6
8 => 1
]
This is my blade:
<script type="text/javascript">
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'pie2d',
renderAt: 'chart-container',
width: '500',
height: '500',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Municipal Ordinances by subject categories",
// "subCaption": "Last year",
"numberPrefix": null,
"showPercentInTooltip": "1",
"decimals": "1",
"theme": "fusion",
},
"data": [ // I want THOSE VALUES HERE... but I don't know how..
{"label": "h","value": "25" },
{"label": "h2","value": "25"},
{"label": "h3","value": "55"},
]
}
}).render();
});
</script>
<div id="chart-container">FusionCharts will render here..</div>
javascript php laravel-5 fusioncharts
I want to display the data from the database to myFusionCharts in laravel but somehow I got stuck. I can't find any answers from the documentations since they use predefined dataset in their sample.
Any help would be much appreciated.
This is my controller:
public function index()
{
$subj = DB::Table('tbl_subjects')
->select('subject')
->get();
// ->toArray()
foreach ( $subj as $s){
// $c = $s->subject;
$c = DB::table('tbl_ordinances')
->where('subject', 'like', '%'.$s->subject.'%')
->get()
->count();
}
// dd($subj,$c);
return view('statistics',compact('subj','c'));
}
I " dd($subj,$c); " and it returns this values:
Collection {#302 ▼
#items: array:9 [▼
0 => {#309 ▼
+"subject": "Peace & Order and Public Safety"
}
1 => {#311 ▼
+"subject": "Infrastructure"
}
2 => {#312 ▼
+"subject": "Livelihood/ Poverty Reduction"
}
3 => {#313 ▼
+"subject": "Finance/ Investment"
}
4 => {#314 ▼
+"subject": "Administrative Development"
}
5 => {#315 ▼
+"subject": "Agricultural Development"
}
6 => {#316 ▼
+"subject": "Social Services"
}
7 => {#317 ▼
+"subject": "Environment and Disaster Management"
}
8 => {#318 ▼
+"subject": "Tourism"
}
]
}
array:9 [▼
0 => 2
1 => 0
2 => 0
3 => 0
4 => 4
5 => 0
6 => 3
7 => 6
8 => 1
]
This is my blade:
<script type="text/javascript">
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'pie2d',
renderAt: 'chart-container',
width: '500',
height: '500',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Municipal Ordinances by subject categories",
// "subCaption": "Last year",
"numberPrefix": null,
"showPercentInTooltip": "1",
"decimals": "1",
"theme": "fusion",
},
"data": [ // I want THOSE VALUES HERE... but I don't know how..
{"label": "h","value": "25" },
{"label": "h2","value": "25"},
{"label": "h3","value": "55"},
]
}
}).render();
});
</script>
<div id="chart-container">FusionCharts will render here..</div>
javascript php laravel-5 fusioncharts
javascript php laravel-5 fusioncharts
asked Nov 23 '18 at 7:02
ZukitungZukitung
1
1
you need to create the data object as label value, since this is the prescribed format for pie chart in fusioncharts, for example: "data":[{ "label":"Peace & Order and Public Safety", "value":"2" }, .....// rest of your data ]
– Zapdos13
Nov 26 '18 at 5:42
@Zapdos13 no, there's a big problem with that.. the values won't update in the chart. If I added more documents and put a subject Peace & Order, the column count will be 3. but the chart will always show 2 unless I edit again the javascipt which is inappropriate.
– Zukitung
Nov 26 '18 at 7:54
add a comment |
you need to create the data object as label value, since this is the prescribed format for pie chart in fusioncharts, for example: "data":[{ "label":"Peace & Order and Public Safety", "value":"2" }, .....// rest of your data ]
– Zapdos13
Nov 26 '18 at 5:42
@Zapdos13 no, there's a big problem with that.. the values won't update in the chart. If I added more documents and put a subject Peace & Order, the column count will be 3. but the chart will always show 2 unless I edit again the javascipt which is inappropriate.
– Zukitung
Nov 26 '18 at 7:54
you need to create the data object as label value, since this is the prescribed format for pie chart in fusioncharts, for example: "data":[{ "label":"Peace & Order and Public Safety", "value":"2" }, .....// rest of your data ]
– Zapdos13
Nov 26 '18 at 5:42
you need to create the data object as label value, since this is the prescribed format for pie chart in fusioncharts, for example: "data":[{ "label":"Peace & Order and Public Safety", "value":"2" }, .....// rest of your data ]
– Zapdos13
Nov 26 '18 at 5:42
@Zapdos13 no, there's a big problem with that.. the values won't update in the chart. If I added more documents and put a subject Peace & Order, the column count will be 3. but the chart will always show 2 unless I edit again the javascipt which is inappropriate.
– Zukitung
Nov 26 '18 at 7:54
@Zapdos13 no, there's a big problem with that.. the values won't update in the chart. If I added more documents and put a subject Peace & Order, the column count will be 3. but the chart will always show 2 unless I edit again the javascipt which is inappropriate.
– Zukitung
Nov 26 '18 at 7:54
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442010%2fdata-from-database-to-fusioncharts-in-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442010%2fdata-from-database-to-fusioncharts-in-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you need to create the data object as label value, since this is the prescribed format for pie chart in fusioncharts, for example: "data":[{ "label":"Peace & Order and Public Safety", "value":"2" }, .....// rest of your data ]
– Zapdos13
Nov 26 '18 at 5:42
@Zapdos13 no, there's a big problem with that.. the values won't update in the chart. If I added more documents and put a subject Peace & Order, the column count will be 3. but the chart will always show 2 unless I edit again the javascipt which is inappropriate.
– Zukitung
Nov 26 '18 at 7:54