Skip to content

Commit 75cfb83

Browse files
Merge pull request #324 from contactashish13/issue-307
New DataTable chart type
2 parents 4dd54f3 + e72ea34 commit 75cfb83

29 files changed

+1450
-366
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@ after_deploy:
7373
- chmod +x bin/deploy.sh
7474
- ". ./bin/deploy.sh"
7575
after_failure:
76-
- cat "logs/phpcs.log"
76+
- cat "logs/phpcs.log"
77+
- cat "logs/jslogs.log"

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

2+
### v3.0.12 - 2018-10-11
3+
**Changes:**
4+
* Added filter to enable users to change schedule of charts.
5+
* Fixed bug with line chart with timeofday column.
6+
* Fixed bug with scheduled charts that sometimes did not show updated data.
7+
* Javascript can be customized on a per user basis that will not be wiped out on update.
8+
29
### v3.0.11 - 2018-08-15
310
**Changes:**
411
* Fixed issue with the Series Settings options for the Table Chart

classes/Visualizer/Module.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,98 @@ protected function get_user_customization_js() {
445445
return $specific;
446446
}
447447

448+
/**
449+
* Load the class for the given chart's chart type so that its assets can be loaded.
450+
*/
451+
protected function load_chart_type( $chart_id ) {
452+
$type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
453+
$name = 'Visualizer_Render_Sidebar_Type_' . ucwords( $type );
454+
$class = null;
455+
if ( class_exists( $name ) ) {
456+
$class = new $name;
457+
} elseif ( true === apply_filters( 'visualizer_load_chart', false, $name ) ) {
458+
$class = new $name;
459+
}
460+
return is_null( $class ) ? null : $class->getLibrary();
461+
}
462+
463+
/**
464+
* Generates the inline CSS to apply to the chart and adds these classes to the settings.
465+
*
466+
* @access public
467+
* @param int $id The id of the chart.
468+
* @param array $settings The settings of the chart.
469+
*/
470+
protected function get_inline_custom_css( $id, $settings ) {
471+
$css = '';
472+
473+
$arguments = array( '', $settings );
474+
if ( ! isset( $settings['customcss'] ) ) {
475+
return $arguments;
476+
}
477+
478+
$classes = array();
479+
$css = '<style type="text/css" name="visualizer-custom-css" id="customcss-' . $id . '">';
480+
foreach ( $settings['customcss'] as $name => $element ) {
481+
$attributes = array();
482+
foreach ( $element as $property => $value ) {
483+
$attributes[] = $this->handle_css_property( $property, $value );
484+
}
485+
$class_name = $id . $name;
486+
$properties = implode( '; ', array_filter( $attributes ) );
487+
if ( ! empty( $properties ) ) {
488+
$css .= '.' . $class_name . ' {' . $properties . ' !important;}';
489+
$classes[ $name ] = $class_name;
490+
}
491+
}
492+
$css .= '</style>';
493+
494+
$settings['cssClassNames'] = $classes;
495+
496+
$arguments = array( $css, $settings );
497+
apply_filters_ref_array( 'visualizer_inline_css', array( &$arguments ) );
498+
499+
return $arguments;
500+
}
501+
502+
/**
503+
* Handles CSS properties that might need special syntax.
504+
*
505+
* @access private
506+
* @param string $property The name of the css property.
507+
* @param string $value The value of the css property.
508+
*/
509+
private function handle_css_property( $property, $value ) {
510+
if ( empty( $property ) || empty( $value ) ) {
511+
return '';
512+
}
513+
514+
switch ( $property ) {
515+
case 'transform':
516+
$value = 'rotate(' . $value . 'deg)';
517+
break;
518+
}
519+
return $property . ': ' . $value;
520+
}
521+
522+
/**
523+
* Determines if charts have been created of the particular chart type.
524+
*/
525+
protected static function hasChartType( $type ) {
526+
$args = array(
527+
'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
528+
'fields' => 'ids',
529+
'post_status' => 'publish',
530+
'meta_query' => array(
531+
array(
532+
'key' => Visualizer_Plugin::CF_CHART_TYPE,
533+
'value' => $type,
534+
),
535+
),
536+
);
537+
538+
$q = new WP_Query( $args );
539+
return $q->found_posts > 0;
540+
}
541+
448542
}

0 commit comments

Comments
 (0)