Closed pswatton closed 7 years ago
Ive tried to upload the view as a text file as code keeps getting stripped out.
It looks like I accidentally left the echo
command out of that example. Just put echo in front, like this:
echo Highcharts::widget([
'options'=>'{
"title": { "text": "Fruit Consumption" },
"xAxis": {
"categories": ["Apples", "Bananas", "Oranges"]
},
"yAxis": {
"title": { "text": "Fruit eaten" }
},
"series": [
{ "name": "Jane", "data": [1, 0, 4] },
{ "name": "John", "data": [5, 7,3] }
]
}'
]);
Thank you for getting back to me.
I tried putting echo in front already and nothing appears. It just puts an opening and closing div with id w0 out.
Does your browser console show an error?
No, does not show any error.
I'm not able to reproduce. Try giving your chart an explicit ID, like this:
echo Highcharts::widget([
'id' => 'moo',
'options'=>'{
"title": { "text": "Fruit Consumption" },
"xAxis": {
"categories": ["Apples", "Bananas", "Oranges"]
},
"yAxis": {
"title": { "text": "Fruit eaten" }
},
"series": [
{ "name": "Jane", "data": [1, 0, 4] },
{ "name": "John", "data": [5, 7,3] }
]
}'
]);
If it works, it means you had another element on the page with the same ID. This can happen in partials and subviews depending on how you render them.
If it doesn't, search the browser's page source for 'moo'. It should occur twice: once for the div's 'id' attribute, and once just before the closing body tag in the script that renders the chart.
I have copied your example code straight into my view but nothing appears when the view renders.
I am using yii2. Here is the view.
<?php
/ @var $this yii\web\View /
use yii\helpers\Html; use miloschuman\highcharts\Highcharts;
?>