Yii Framework Forum: [Extension] HighchartsWidget - Yii Framework Forum

Jump to content

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

[Extension] HighchartsWidget Wrapper widget for Highcharts Javascript library Rate Topic: ***** 2 Votes

#1 User is offline   Milo Schuman 

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

Posted 07 October 2010 - 09:43 AM

I have created a wrapper extension for the Highcharts library, available here:

Yii Highcharts Extension
Yii Highcharts Repository

Quote

Highcharts is a charting library written in pure JavaScript, offering an easy way of adding interactive charts to your web site or web application. Highcharts currently supports line, spline, area, areaspline, column, bar, pie and scatter chart types.

The extension is clean, compact, and supports configuration via either standard PHP arrays or a JSON string. Please let me know if you have any questions, comments, or suggestions.
0

#2 User is offline   m1m1m1 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 23-May 10

Posted 07 October 2010 - 11:38 AM

Hi,
as far as I know Highcharts in not allow in commercial projects (unless you buy licence).

but can I use your extension a commercial project it seems to be very useful? :)
0

#3 User is offline   Milo Schuman 

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

Posted 07 October 2010 - 04:04 PM

View Postm1m1m1, on 07 October 2010 - 11:38 AM, said:

Hi,
as far as I know Highcharts in not allow in commercial projects (unless you buy licence).

but can I use your extension a commercial project it seems to be very useful? :)


You're right. Highcharts is only free for non-commercial use. You can use my (PHP) code however you like, but I have no authority to grant you the same privilege for the packaged Highcharts JavaScript files. For those, I can only refer you to the Highcharts License and Pricing page.

My own advice would be to go ahead and purchase the Single Website license, which is (at the time of this post) only $80, and pass the expense on to your client. If you are the client, then it's your call. ;)
0

#4 User is offline   haldrik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 14-October 10

Posted 14 October 2010 - 12:55 PM

Hi Milo,
Thanks for this extension, it's just what I've been looking for.
0

#5 User is offline   monico 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 27-July 10

Posted 15 October 2010 - 10:36 AM

Hi, Milo. After to read the Highcharts documentation, I read about Exporting module.

Question: How can I use it in the widget?

TIA

Cheers

Monico
0

#6 User is offline   Milo Schuman 

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

Posted 15 October 2010 - 11:49 AM

View Postmonico, on 15 October 2010 - 10:36 AM, said:

Hi, Milo. After to read the Highcharts documentation, I read about Exporting module.

Question: How can I use it in the widget?

Good call, Monico. I overlooked that functionality in the initial release. I will add that module and update the documentation in the next day or two.

Sorry for the inconvenience.
0

#7 User is offline   monico 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 27-July 10

Posted 15 October 2010 - 12:16 PM

Hi, Milo. Please don't mention it. I'll check it out !

Cheers

Monico
0

#8 User is offline   Milo Schuman 

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

Posted 15 October 2010 - 04:36 PM

View Postmonico, on 15 October 2010 - 12:16 PM, said:

Hi, Milo. Please don't mention it. I'll check it out !

Monico, I posted the update. The Exporting module should now be enabled by default. For instructions on disabling the module, see the Tips section of the Documentation.

Let me know if anything is missing or unclear.
0

#9 User is offline   monico 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 27-July 10

Posted 18 October 2010 - 08:09 AM

Hi, Milo. I appreciate your time to update this excellent Highchart wiget. Yes, I'll test it this new update. I'll write down if I have problems with it.

Cheers

Monico
0

#10 User is offline   stickdog 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 29-April 10

Posted 18 October 2010 - 06:09 PM

This looks great, Milo!

I am downloading it test right now.
0

#11 User is offline   gauviz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 22-June 10

Posted 22 November 2010 - 02:38 AM

Thanks a Lot Milo,
I do have a small issue though

In highchartswidget.php you have used array_replace_recursive().
This was introduced only in 5.3 and most webhosts only have 5.2.

I came to know about this after some debugging. I think you should make it backward compatible with 5.2

Thanks
Gaurav
0

#12 User is offline   mrwallace 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 12-September 10

Posted 18 December 2010 - 02:19 PM

View Postgauviz, on 22 November 2010 - 02:38 AM, said:

Thanks a Lot Milo,
I do have a small issue though

In highchartswidget.php you have used array_replace_recursive().
This was introduced only in 5.3 and most webhosts only have 5.2.

I came to know about this after some debugging. I think you should make it backward compatible with 5.2

Thanks
Gaurav


I had the same problem and made a small work-around.
I created a new file in components called CompatibleFunctions.php.
<?php
/* 
 * To use the needed PHP 5.3 functions in a PHP 5.2 environment
 * 
 */
// as of PHP 5.3.0 array_replace_recursive() does the work for us
if (function_exists('array_replace_recursive'))
{
	return call_user_func_array('array_replace_recursive', func_get_args());
}
if (!function_exists('array_replace_recursive'))
{
  function array_replace_recursive($array, $array1)
  {
	function recurse($array, $array1)
	{
	  foreach ($array1 as $key => $value)
	  {
		// create new key in $array, if it is empty or not an array
		if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key])))
		{
		  $array[$key] = array();
		}

		// overwrite the value in the base array
		if (is_array($value))
		{
		  $value = recurse($array[$key], $value);
		}
		$array[$key] = $value;
	  }
	  return $array;
	}

	// handle the arguments, merge one by one
	$args = func_get_args();
	$array = $args[0];
	if (!is_array($array))
	{
	  return $array;
	}
	for ($i = 1; $i < count($args); $i++)
	{
	  if (is_array($args[$i]))
	  {
		$array = recurse($array, $args[$i]);
	  }
	}
	return $array;
  }
}
?>


And added this file to be loaded in the index.php of Yii.
<?php
// change the following paths if necessary
$yii=dirname(__FILE__).'/../framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
$compfunctions=dirname(__FILE__).'/protected/components/CompatibleFunctions.php';

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($compfunctions);
require_once($yii);
Yii::createWebApplication($config)->run();


Problem solved. After you upgrade to PHP 5.3 the original function will be used instead of this work-around one.
Retreat is no longer an option...
2

#13 User is offline   Milo Schuman 

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

Posted 19 December 2010 - 04:23 PM

View Postgauviz, on 22 November 2010 - 02:38 AM, said:

Thanks a Lot Milo,
I do have a small issue though

In highchartswidget.php you have used array_replace_recursive().
This was introduced only in 5.3 and most webhosts only have 5.2.

I came to know about this after some debugging. I think you should make it backward compatible with 5.2

Thank you for the tip, Gaurav. That was an oversight on my part. I have updated the requirements section of the documentation and will add support for PHP 5.2 in the next release.
0

#14 User is offline   Milo Schuman 

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

Posted 19 December 2010 - 04:38 PM

View Postmrwallace, on 18 December 2010 - 02:19 PM, said:

I had the same problem and made a small work-around.
I created a new file in components called CompatibleFunctions.php.
...

Great workaround, mrwallace. This is a big help. I have added a link to your post in the requirements section of the documentation.
0

#15 User is offline   mrwallace 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 12-September 10

Posted 20 December 2010 - 07:11 PM

I'm having problems with fitting the axis-labels on the screen. After a certain length the label just gets cut off. Ideas anyone?
Retreat is no longer an option...
0

#16 User is offline   Milo Schuman 

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

Posted 21 December 2010 - 01:28 PM

View Postmrwallace, on 20 December 2010 - 07:11 PM, said:

I'm having problems with fitting the axis-labels on the screen. After a certain length the label just gets cut off. Ideas anyone?

Do you have a screenshot you can post?
0

#17 User is offline   mrwallace 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 31
  • Joined: 12-September 10

Posted 22 December 2010 - 07:47 AM

View PostMilo S, on 21 December 2010 - 01:28 PM, said:

Do you have a screenshot you can post?


Here you go. The first 4 labels are cut off. At first I thought it was because of my use of a bar chart, so I've changed to a column chart. But as you can see, the problem is the same.

Edit:
It seems to be caused by differences in div sizes and SVG size.

Attached File(s)

  • Attached File  chart.jpg (10.4K)
    Number of downloads: 117

This post has been edited by mrwallace: 23 December 2010 - 09:42 AM

Retreat is no longer an option...
0

#18 User is offline   canreo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 21-July 09

Posted 31 January 2011 - 04:56 PM

View Postmrwallace, on 20 December 2010 - 07:11 PM, said:

I'm having problems with fitting the axis-labels on the screen. After a certain length the label just gets cut off. Ideas anyone?

Try using the "renderTo" chart option.:
$this->Widget('ext.highcharts.HighchartsWidget', array(
                    'options' => array(
                        'chart' => array(
                            'renderTo' => 'myContainer',
                            'defaultSeriesType' => 'column', 
                            ....                           
                        ),
                       ...
                       ));
echo '<div id="myContainer"></div>';

Where "myContainer" is the DIV ID of your choice. If you display more than one chart, you can use "myContainer1", "myContainer2", etc...
0

#19 User is offline   sbasuki 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 14-January 10

Posted 12 February 2011 - 12:42 AM

View Postcanreo, on 31 January 2011 - 04:56 PM, said:

Try using the "renderTo" chart option.:
$this->Widget('ext.highcharts.HighchartsWidget', array(
                    'options' => array(
                        'chart' => array(
                            'renderTo' => 'myContainer',
                            'defaultSeriesType' => 'column', 
                            ....                           
                        ),
                       ...
                       ));
echo '<div id="myContainer"></div>';

Where "myContainer" is the DIV ID of your choice. If you display more than one chart, you can use "myContainer1", "myContainer2", etc...


How to display pie chart using highcharts?
0

#20 User is offline   Milo Schuman 

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

Posted 13 February 2011 - 01:37 PM

View Postsbasuki, on 12 February 2011 - 12:42 AM, said:

How to display pie chart using highcharts?

Sbasuki, here is a brief example of how to render a pie chart:

$this->widget('ext.highcharts.HighchartsWidget',array(
	'options' => array(
		'series' => array(array(
			'type' => 'pie',
			'data' => array(
				array('Firefox', 44.2),
				array('IE7', 26.6),
				array('IE6', 20),
				array('Chrome', 3.1),
				array('Other', 5.4)
			)
		))
	)
));


For more examples and other options, see the Highcharts demo gallery and online documentation.
0

Share this topic:


  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • 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