# m-chart/1.3.1/components/templates/highcharts-chart.php

M Chart, version 1.3.1. 55 lines.

- Page: https://pluginprobe.com/plugins/m-chart/1.3.1/code/components/templates/highcharts-chart.php
- Raw: https://pluginprobe.com/plugins/m-chart/1.3.1/raw/components/templates/highcharts-chart.php
- Modified: 2015-05-22T23:32:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/m-chart/1.3.1/code/components/templates/highcharts-chart.php#L10-L20`.

```php
<?php
// If there's multiple instances of a chart on the page we don't want to redeclare this
// @TODO if the embeds end up being done via iframes this conditional won't be necessary anymore
if ( ! $this->options_set ) {
	?>
	<script type="text/javascript">
	(function( $ ) {
		$( function() {
			Highcharts.setOptions( <?php echo $this->unicode_aware_stripslashes( json_encode( $this->highcharts()->get_chart_options() ) ); ?>);
		} );
	})( jQuery );
	</script>
	<?php
	$this->options_set = true;
}
?>
<div id="m-chart-container-<?php echo absint( $post_id ); ?>" class="m-chart-container">
	<div id="m-chart-<?php echo absint( $post_id ); ?>" class="m-chart"></div>
</div>
<script type="text/javascript">
	var m_chart_highcharts_<?php echo absint( $post_id ); ?> = {
		chart_args: <?php echo $this->unicode_aware_stripslashes( json_encode( $this->highcharts()->get_chart_args( $post_id, $args ) ) ); ?>,
		post_id: <?php echo absint( $post_id ); ?>
	};

	(function( $ ) {
		m_chart_highcharts_<?php echo absint( $post_id ); ?>.render_chart = function( ) {
			$( '.m-chart' ).trigger({
				type:    'render_start',
				post_id: this.post_id
			});

			$( '#m-chart-' + this.post_id ).highcharts(
				this.chart_args,
				function( chart ) {
					// Stuff to do after the chart has rendered goes here
					<?php do_action( 'm_chart_post_render_javascript', $post_id, $args ); ?>

				}
			);

			this.chart = $( '#m-chart-' + this.post_id ).highcharts();

			$( '.m-chart' ).trigger({
				type:    'render_done',
				chart:   this.chart,
				post_id: this.post_id
			});
		};

		$( function() {
			m_chart_highcharts_<?php echo absint( $post_id ); ?>.render_chart();
		} );
	})( jQuery );
</script>
```
