-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
125 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
# CanvasJS Charts for WordPress | ||
# CanvasJS for WordPress | ||
|
||
This plugin allows you to create and add interactive charts to your wordpress page and posts using CanvasJS library. It creates responsive high-performance charts that renders across devices including iPhone, iPad, Android, Mac & PCs. | ||
This plugin allows you to create and add interactive Charts & StockCharts to your wordpress page and posts using CanvasJS library. It creates responsive high-performance Charts & StockCharts that renders across devices including iPhone, iPad, Android, Mac & PCs. | ||
|
||
## CanvasJS | ||
CanvasJS is built from ground up for high performance data visualization and can render millions of data points in a matter of milliseconds. CanvasJS is trusted by 500K+ users in 192 Countries. Customers include Microsoft, NASA, Apple, Intel, Boing, Samsung, BMW, Sony, HP etc | ||
## CanvasJS Library | ||
CanvasJS is built from ground up for high performance data visualization and can render millions of data points in a matter of milliseconds. CanvasJS is trusted by 500K+ users in 192 Countries. Customers include Microsoft, NASA, Apple, Intel, Boing, Samsung, BMW, Sony, HP, Bosch, Motorola, etc. | ||
|
||
Note: | ||
- This plugin requires you to have CanvasJS License. Please visit [CanvasJS](https://canvasjs.com/license/) for more info. | ||
|
||
#### How to add CanvasJS to your WordPress Page / Post? | ||
## CanvasJS Gallery / Demos | ||
[CanvasJS Chart Gallery](https://canvasjs.com/javascript-charts/) | ||
[CanvasJS StockChart Gallery](https://canvasjs.com/javascript-stockcharts/) | ||
|
||
## How to add CanvasJS to your WordPress Page / Post? | ||
#### CanvasJS Chart | ||
- Add shortcode `[canvasjschart]` | ||
- Pass chart-options to the chart as 'options'. | ||
>[canvasjschart options="{title:{text: 'CanvasJS Column Chart'}, data: new Array({dataPoints: new Array({ label: 'apple', y: 10 },{ label: 'orange', y: 15 },{ label: 'banana', y: 25 },{ label: 'mango', y: 30 },{ label: 'grape', y: 28 })})}" style="width:100%;height:300px"] | ||
#### CanvasJS StockChart | ||
- Add shortcode `[canvasjsstockchart]` | ||
- Pass chart-options to the chart as 'options'. | ||
>[canvasjsstockchart options="{title:{text: 'CanvasJS StockChart'}, charts: new Array({data: new Array({dataPoints: new Array({ label: 'apple', y: 10 },{ label: 'orange', y: 15 },{ label: 'banana', y: 25 },{ label: 'mango', y: 30 },{ label: 'grape', y: 28 })})})}" style="width:100%;height:400px"] | ||
Note: | ||
- Don't add space within style. i.e. Use `style="width:100%;height:300px"` and avoid `style="width: 100%; height: 300px"` | ||
|
||
#### Plugin Testing | ||
- Last Tested with: WordPress 5.5 | ||
- Last Tested on: Aug 14, 2020 | ||
|
||
#### License | ||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php // Silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* canvasjsstockchart shortcode | ||
* | ||
* @package WPCanvasJS | ||
* @since 1.2.0 | ||
*/ | ||
|
||
if (!function_exists('canvasjs_stockchart_script')){ | ||
function add_canvasjs_stockchart_script() { | ||
$_url = get_option('canvasjs_stockchart_url'); | ||
wp_register_script('canvasjs_stockchart_script', $_url, array('jquery'),'1.1', true); | ||
wp_enqueue_script('canvasjs_stockchart_script'); | ||
} | ||
add_action('wp_enqueue_scripts', 'add_canvasjs_stockchart_script'); | ||
} | ||
|
||
if (!function_exists('canvasjs_stockchart_shortcode')){ | ||
// Add the action. | ||
add_action('plugins_loaded', function() { | ||
// Add the shortcode. | ||
add_shortcode( 'canvasjsstockchart', 'canvasjs_stockchart_shortcode' ); | ||
}); | ||
|
||
/** | ||
* Shortcode Function | ||
* | ||
* @param Attributes $atts | ||
* @return string | ||
* @since 1.2.0 | ||
*/ | ||
function canvasjs_stockchart_shortcode($atts) { | ||
STATIC $stockChartCount = 0; | ||
$stockChartContainerID = "stockChartContainer".$stockChartCount; | ||
$stockChart = "stockChart".$stockChartCount; | ||
$stockChartCount++; | ||
|
||
$stockChartOptions = $atts['options']; | ||
$divStyle = $atts['style']; | ||
|
||
//Safe in PHP 7.0. | ||
$_stockChart .= '<div id='.$stockChartContainerID.' style='.$divStyle.'></div> | ||
<script> | ||
jQuery(document).ready(function( $ ){ | ||
var '.$stockChart.'= new CanvasJS.StockChart('. $stockChartContainerID .','. $stockChartOptions .');'. | ||
$stockChart.'.render(); | ||
}); | ||
</script>'; | ||
|
||
// Return the data. | ||
return $_stockChart; | ||
} | ||
} // End if(). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters