Yii Framework Forum: [Extension] Yii2 Highcharts Widget - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[Extension] Yii2 Highcharts Widget Rate Topic: -----

#1 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 18 February 2014 - 12:29 PM

This is a discussion forum for the yii2-highcharts-widget extension.

The extension brings all the functionality of the popular Yii Highcharts extension to Yii2.

More information available here:



Posted Image
1

#2 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 18 February 2014 - 01:25 PM

Yii2 Highcharts Widget v3.0.9 is now available! Please see the extension page for installation and usage instructions.
0

#3 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 17 March 2014 - 12:27 PM

Yii2 Highcharts Widget v3.0.10 is now available! Please see the extension page for installation and usage instructions. Enjoy.
0

#4 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 24 April 2014 - 01:06 PM

Yii2 Highcharts Widget v4.0.1 is now available! Please see the extension page for installation and usage instructions. Enjoy.
0

#5 User is offline   copyme 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 01-December 14

Posted 02 December 2014 - 03:15 AM

I test your extension on the yii2 advanced application template, i add "miloschuman/yii2-highcharts-widget": "*" in the require section of my composer.json file. Then i update with composer.

I insert the sample code in frontend/views/index.php by choosing the php arrays method but i have an error :

Class "miloschuman\highcharts\Highcharts" not found
and echo Highcharts::widget is highlighted ...
0

#6 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 02 December 2014 - 04:04 PM

View Postcopyme, on 02 December 2014 - 03:15 AM, said:

I test your extension on the yii2 advanced application template, i add "miloschuman/yii2-highcharts-widget": "*" in the require section of my composer.json file. Then i update with composer.

I insert the sample code in frontend/views/index.php by choosing the php arrays method but i have an error :

Class "miloschuman\highcharts\Highcharts" not found
and echo Highcharts::widget is highlighted ...


Have you tried adding any other composer packages, and do you get the same error? If you haven't already done so, check that your /vendor folder is in sync with your server.
0

#7 User is offline   copyme 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 01-December 14

Posted 09 December 2014 - 04:10 AM

Ok thank you, i update with composer with the good rights and the error gone.

Is it possible to instantiate multiple charts in the same page ? How to use the widget to have multiple graphics in the same page ?

Br,
0

#8 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 09 December 2014 - 10:27 AM

Yes. Just include multiple widgets. Each widget corresponds to one chart.
0

#9 User is offline   Jeff Spotts 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 05-December 14

Posted 10 February 2015 - 07:48 PM

Great widget. Had no problem getting it installed and rendering a nice looking multi-series line chart. One issue has me confounded, which is setting the width and height of my chart. I've tried wrapping the widget in a container div styled at width:100%, as suggested in the Highcharts docs, and I've also set the width and height option properties in the widget. No matter what I've tried, when I inspect the element I see that the highchairs-container style sets width at 600px and height at 400px. My 100% width container is just over 1100px wide so it's not a constraint. I'm clearly doing something wrong. Any help will be greatly appreciated!
0

#10 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 11 February 2015 - 10:50 AM

Jeff, I'm unable to reproduce your issue. Could you post sample code?
0

#11 User is offline   Jeff Spotts 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 05-December 14

Posted 11 February 2015 - 05:26 PM

Milo, I just figured this out. I'd misread the Highcharts API Reference discussion on setting width and height. Once I'd clicked through to the JSFiddle example I realized my mistake. I was passing values as strings, e.g., 'width' => '1100px' instead of the correct approach shown in the code excerpt below.

'options' => [
'chart' => ['width' => 1100,
'height' => 734],

Works brilliantly now that I'm on the right track. Thanks again for a great widget.

Jeff
0

#12 User is offline   domenor 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 11-February 15

Posted 22 April 2015 - 07:01 AM

Hi, How I can add json data like this?

$.getJSON("data.php", function(json) {
		options.xAxis.categories = json[0]['data'];
	        options.series[0] = json[1];
	        options.series[1] = json[2];
	        options.series[2] = json[3];
		chart = new Highcharts.Chart(options);
	        });


This file was make from db:


.....

while($r = mysqli_fetch_array($query, MYSQLI_BOTH)) 
{

    $category['data'][] = $r['field_1'];
    $series1['data'][] = $r['field_2'];
    $series2['data'][] = $r['field_3'];
    $series3['data'][] = $r['field_4'];

}

$result = array();
array_push($result,$category);
array_push($result,$series1);
array_push($result,$series2);
array_push($result,$series3);

print json_encode($result, JSON_NUMERIC_CHECK);

mysqli_close($link);


Thanks
0

#13 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 22 April 2015 - 10:17 AM

domenor, I've added documentation for this exact case. Check https://github.com/m...es/highstock.md, and let me know if you have any questions.
0

#14 User is offline   hajdar 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 16-November 13

Posted 02 May 2015 - 08:39 AM

Would you please provide a real example with model, controller and view
Thanks
0

#15 User is offline   Jim K 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 18-December 13

Posted 01 July 2015 - 01:55 PM

I'm trying to display a bar graph and I pass in an array (using SeriesDataHelper) that has 43 items. Only the first 20 show on the chart and I can't for the life of me figure out why. I've tried setting plotOptions-bar-cropThreshold = 100 but that didn't make any difference. Nor does changing the height/width of the chart.

I've confirmed in debugger that the dataProvider actual does have the 43 data points.

Any help would be greatly appreciated.

Jim

echo Highcharts::widget([
	'setupOptions' => [
		'global' => ['useUTC' => FALSE],
	],
	'options' => [
		'chart' => [
			'type' => 'bar', 
			'width' => 800,
			'height' => 700,
			'zoomType' => 'x',
		],
		'credits' => ['enabled' => FALSE],
		'title' => ['text' => NULL],
		'xAxis' => [
			'type' => 'category',
			'labels' => [
				'style' => [
					'fontSize' => '12px',
					'fontFamily' => 'Verdana, sans-serif',
				]
			]
		],
		'yAxis' => [
			'title' => [
				'enabled' => TRUE,
				'text' => 'Message Count',
			],
			'min' => 0,
		],
		'legend' => ['enabled' => FALSE],
		'tooltip' => [
			'pointFormat' => 'Messages: <b>{point.y:.1f}</b>'
		],
		'plotOptions' => [
			'bar' => [
				'cropThreshold' => 100,
			],
		],
		'series' => [
			[
				'name' => 'Messages', 
				'color' => '#318233',
				'data' => new SeriesDataHelper($dataProvider, ['feed','count:int']),
			],
		],
	],
]);

0

#16 User is offline   smiff 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 01-September 11

Posted 28 July 2015 - 02:51 PM

View PostJim K, on 01 July 2015 - 01:55 PM, said:

I'm trying to display a bar graph and I pass in an array (using SeriesDataHelper) that has 43 items. Only the first 20 show on the chart and I can't for the life of me figure out why.


Exactly the same issue here Jim. I don't suppose you solved it did you?
0

#17 User is offline   smiff 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 01-September 11

Posted 28 July 2015 - 02:59 PM

Jim - solved it, just add the pagination => false to the ArrayDataProvider, eg:

$dataProvider = new \yii\data\ArrayDataProvider(['allModels' => $data, 'pagination' =>false]);

0

#18 User is offline   Jim K 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 18-December 13

Posted 28 July 2015 - 04:30 PM

Worked like a charm, thanks!

Jim

View Postsmiff, on 28 July 2015 - 02:59 PM, said:

Jim - solved it, just add the pagination => false to the ArrayDataProvider, eg:

$dataProvider = new \yii\data\ArrayDataProvider(['allModels' => $data, 'pagination' =>false]);


0

#19 User is offline   Fadex 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 25-January 16

Posted 07 March 2016 - 10:47 AM

Hi Milo Schuman, i was using the extension highcharts, i haven't problem with the charts until i used the type columnrange. I couldn't make it work, the chart doesn't display in the page. I'm working on the yii2 advanced application template. My code:

echo Highcharts::widget([
        'options' => [
            'chart'=>[
                'type'=>'columnrange',
                'inverted'=>true,
            ],
            'title' => ['text' => 'Meses'],
            'xAxis' => [

                'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            ],
            'yAxis' => [
                'title' => ['text' => 'Temperatura']
            ],
            'legend'=> [
                'enabled'=> false
            ],
            'series'=> [[
                'name'=> 'Temperatura',
                'data'=> [
                    [-9.7, 9.4],
                    [-8.7, 6.5],
                    [-3.5, 9.4],
                    [-1.4, 19.9],
                    [0.0, 22.6],
                    [2.9, 29.5],
                    [9.2, 30.7],
                    [7.3, 26.5],
                    [4.4, 18.0],
                    [-3.1, 11.4],
                    [-5.2, 10.4],
                    [-13.5, 9.8]
                ]
            ]]
        ]
    ]);

0

#20 User is offline   Milo Schuman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 17-September 10

Posted 07 March 2016 - 01:24 PM

View PostFadex, on 07 March 2016 - 10:47 AM, said:

Hi Milo Schuman, i was using the extension highcharts, i haven't problem with the charts until i used the type columnrange. I couldn't make it work, the chart doesn't display in the page. I'm working on the yii2 advanced application template. My code:
...


Fadex, the 'columnrange' chart type is defined in a separate file, 'highcharts-more.js', which you must include via the top-level scripts option, like this:

echo Highcharts::widget([
    'scripts' => [
        'highcharts-more',
    ],
    'options' => [
        'chart' => [
            'type' => 'columnrange',
            'inverted' => true,
        ],
        'title' => ['text' => 'Meses'],
        'xAxis' => [
            'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        ],
        'yAxis' => [
            'title' => ['text' => 'Temperatura']
        ],
        'legend' => [
            'enabled' => false
        ],
        'series' => [[
            'name' => 'Temperatura',
            'data' => [
                [-9.7, 9.4],
                [-8.7, 6.5],
                [-3.5, 9.4],
                [-1.4, 19.9],
                [0.0, 22.6],
                [2.9, 29.5],
                [9.2, 30.7],
                [7.3, 26.5],
                [4.4, 18.0],
                [-3.1, 11.4],
                [-5.2, 10.4],
                [-13.5, 9.8]
            ]
        ]]
    ]
]);

0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users