esc_html_e('Units', 'm-chart');
?>
</label><br />
			<select name='<?php 
echo esc_attr($this->get_field_name('x_units'));
?>
' id="<?php 
echo esc_attr($this->get_field_id('x-units'));
?>
" class='select'>
				<option value=""><?php 
esc_html_e('N/A', 'm-chart');
?>
</option>
				<?php 
foreach (m_chart()->get_unit_terms() as $parent => $units) {
    ?>
					<option value="" disabled="disabled">
						<?php 
    echo esc_html($parent);
    ?>
					</option>
					<?php 
    foreach ($units as $unit) {
        ?>
						<option value="<?php 
        echo esc_attr($unit->name);
        ?>
"<?php 
        selected($unit->name, $post_meta['x_units']);
        ?>
 /**
  * Return a name spaced field id
  *
  * @param string the field id we want to name space
  *
  * @param string a name spaced field id
  */
 public function get_field_id($field_name)
 {
     return m_chart()->slug . '-' . $field_name;
 }
Exemple #3
0
 public function test_validate_post_meta()
 {
     $validated_post_meta = m_chart()->validate_post_meta($this->bad_post_meta);
     $this->assertEquals(0, m_chart_test_helpers()->array_diff_assoc_recursive($validated_post_meta, $this->validated_bad_post_meta));
 }
<script type="text/javascript" charset="utf-8">
	var hands_on_table_data = <?php 
echo json_encode($sheet_data);
?>
;
</script>
<div id="hands-on-table-sheet-<?php 
echo absint($post->ID);
?>
" class="hands-on-table-sheet"></div>
<textarea name="<?php 
echo esc_attr($this->get_field_name('data'));
?>
" rows="8" cols="40" class="data hide"></textarea>
<?php 
wp_nonce_field(m_chart()->slug . '-save-post', $this->get_field_name('nonce'));
Exemple #5
0
<?php

/*
Plugin Name: M Chart
Version: 1.1.5
Plugin URI: http://github.com/methnen/m-charts
Description: Manage data sets and display them as charts in WordPress.
Author: Jamie Poitra
Author URI: http://methnen.com
Tags: highcharts, graphs, charts, data, wordpress
License: MIT
*/
require_once __DIR__ . '/components/class-m-chart.php';
m_chart();
 /**
  * Handle adding data sets (series in Highcharts terminology) to the chart args
  *
  * @param array the current array of chart args
  *
  * @return array the chart args array with data sets added to it
  */
 public function add_data_sets($chart_args)
 {
     // When Highcharts encounters an empty data value it stops so we set them to NULL
     $data_array = array_map(array($this, 'fix_null_values'), m_chart()->parse()->set_data);
     if ('pie' != $this->post_meta['type'] && 'both' == m_chart()->parse()->value_labels_position) {
         $set_data = array();
         $label_key = $this->post_meta['parse_in'] == 'rows' ? 'first_column' : 'first_row';
         foreach ($data_array as $key => $data_chunk) {
             $set_data[$key] = array('name' => m_chart()->parse()->value_labels[$label_key][$key], 'data' => array());
             foreach ($data_chunk as $data) {
                 $set_data[$key]['data'][] = $data;
             }
         }
         $chart_args['series'] = $set_data;
     } else {
         $new_data_array = array();
         foreach ($chart_args['xAxis']['categories'] as $key => $label) {
             $new_data_array[$key] = array($label, $data_array[$key]);
         }
         if ('pie' == $this->post_meta['type']) {
             // Don't need these anymore for pie charts
             unset($chart_args['xAxis']['categories']);
         }
         $chart_args['series'] = array(array('type' => $this->post_meta['type'], 'showInLegend' => true, 'data' => $new_data_array));
         $chart_args['tooltip'] = array('pointFormat' => '<b>{point.y}</b>');
     }
     return $chart_args;
 }
 public function test_rows_data()
 {
     $data = unserialize($this->rows_data);
     m_chart()->parse()->parse_data($data, 'rows');
     // Test value labels position
     $this->assertEquals('both', m_chart()->parse()->value_labels_position);
     // Test value labels
     $this->assertEquals(0, m_chart_test_helpers()->array_diff_assoc_recursive(array('first_column' => array('Revenue'), 'first_row' => array('Q1 10', 'Q2 10', 'Q3 10', 'Q4 10', 'Q1 11', 'Q2 11', 'Q3 11', 'Q4 11', 'Q1 12', 'Q2 12', 'Q3 12', 'Q4 12', 'Q1 13', 'Q2 13', 'Q3 13', 'Q4 13', 'Q1 14', 'Q2 14', 'Q3 14', 'Q4 14', 'Q1 15')), m_chart()->parse()->value_labels));
     // Test set data
     $this->assertEquals(0, m_chart_test_helpers()->array_diff_assoc_recursive(array(array(15683000000, 13499000000, 15700000000, 20343000000, 26741000000, 24667000000, 28571000000, 28270000000, 46333000000, 39186000000, 35023000000, 35966000000, 54512000000, 43603000000, 35323000000, 37472000000, 57594000000, 45646000000, 37432000000, 42123000000, 74599000000)), m_chart()->parse()->set_data));
     // Test data suffix/prefix
     $this->assertEquals('', m_chart()->parse()->data_suffix);
     $this->assertEquals('', m_chart()->parse()->data_prefix);
 }