| @@ -83,8 +83,24 @@ | ||
| 83 | 83 | */ |
| 84 | 84 | protected $_alignments; |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | + * Whether this chart supports animation or not. | |
| 88 | + * | |
| 89 | + * @access protected | |
| 90 | + * @var bool | |
| 91 | + */ | |
| 92 | + protected $_supportsAnimation = true; | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * Which library does this this chart implement? | |
| 96 | + * | |
| 97 | + * @access protected | |
| 98 | + * @var string | |
| 99 | + */ | |
| 100 | + protected $_library = null; | |
| 101 | + | |
| 102 | + /** | |
| 87 | 103 | * Constructor. |
| 88 | 104 | * |
| 89 | 105 | * @since 1.0.0 |
| 90 | 106 | * |
| @@ -115,8 +131,10 @@ | ||
| 115 | 131 | '' => '', |
| 116 | 132 | '1' => esc_html__( 'Yes', 'visualizer' ), |
| 117 | 133 | '0' => esc_html__( 'No', 'visualizer' ), |
| 118 | 134 | ); |
| 135 | + | |
| 136 | + $this->hooks(); | |
| 119 | 137 | } |
| 120 | 138 | |
| 121 | 139 | /** |
| 122 | 140 | * Renders chart title settings. |
| @@ -156,9 +174,9 @@ | ||
| 156 | 174 | self::_renderGroupEnd(); |
| 157 | 175 | |
| 158 | 176 | self::_renderGroupStart( esc_html__( 'Manual Configuration', 'visualizer' ) ); |
| 159 | 177 | self::_renderSectionStart(); |
| 160 | - self::_renderSectionDescription( __( 'Configure the graph by providing configuration variables right from the', 'visualizer' ) . ' <a href="https://developers.google.com/chart/interactive/docs/reference" target="_blank">Google Visualization</a> API.' ); | |
| 178 | + self::_renderSectionDescription( '<span class="viz-gvlink">' . sprintf( __( 'Configure the graph by providing configuration variables right from the %1$sGoogle Visualization API%2$s', 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/gallery/?#configuration-options" target="_blank">', '</a>' ) . '</span>' ); | |
| 161 | 179 | |
| 162 | 180 | $example = ' |
| 163 | 181 | { |
| 164 | 182 | "vAxis": { |
| @@ -174,9 +192,10 @@ | ||
| 174 | 192 | esc_html__( 'Configuration', 'visualizer' ), |
| 175 | 193 | 'manual', |
| 176 | 194 | $this->manual, |
| 177 | 195 | sprintf( |
| 178 | - esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ), '<br><code>' . $example . '</code>' | |
| 196 | + esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ), | |
| 197 | + '<br><code>' . $example . '</code>' | |
| 179 | 198 | ), |
| 180 | 199 | '', |
| 181 | 200 | array( 'rows' => 5 ) |
| 182 | 201 | ); |
| @@ -310,12 +329,61 @@ | ||
| 310 | 329 | |
| 311 | 330 | self::_renderSectionStart( esc_html__( 'Tooltip', 'visualizer' ), false ); |
| 312 | 331 | $this->_renderTooltipSettigns(); |
| 313 | 332 | self::_renderSectionEnd(); |
| 333 | + | |
| 334 | + $this->_renderAnimationSettings(); | |
| 335 | + | |
| 314 | 336 | self::_renderGroupEnd(); |
| 315 | 337 | } |
| 316 | 338 | |
| 317 | 339 | /** |
| 340 | + * Renders animation settings section. | |
| 341 | + * | |
| 342 | + * @access protected | |
| 343 | + */ | |
| 344 | + protected function _renderAnimationSettings() { | |
| 345 | + if ( ! $this->_supportsAnimation ) { | |
| 346 | + return; | |
| 347 | + } | |
| 348 | + | |
| 349 | + self::_renderSectionStart( esc_html__( 'Animation', 'visualizer' ), false ); | |
| 350 | + | |
| 351 | + self::_renderCheckboxItem( | |
| 352 | + esc_html__( 'Animate on startup', 'visualizer' ), | |
| 353 | + 'animation[startup]', | |
| 354 | + $this->animation['startup'], | |
| 355 | + true, | |
| 356 | + esc_html__( 'Determines if the chart will animate on the initial draw.', 'visualizer' ) | |
| 357 | + ); | |
| 358 | + | |
| 359 | + self::_renderTextItem( | |
| 360 | + esc_html__( 'Duration', 'visualizer' ), | |
| 361 | + 'animation[duration]', | |
| 362 | + isset( $this->animation['duration'] ) ? $this->animation['duration'] : 0, | |
| 363 | + esc_html__( 'The duration of the animation, in milliseconds', 'visualizer' ), | |
| 364 | + 0, | |
| 365 | + 'number' | |
| 366 | + ); | |
| 367 | + | |
| 368 | + self::_renderSelectItem( | |
| 369 | + esc_html__( 'Easing', 'visualizer' ), | |
| 370 | + 'animation[easing]', | |
| 371 | + isset( $this->animation['easing'] ) ? $this->animation['easing'] : null, | |
| 372 | + array( | |
| 373 | + 'linear' => esc_html__( 'Constant speed', 'visualizer' ), | |
| 374 | + 'in' => esc_html__( 'Start slow and speed up', 'visualizer' ), | |
| 375 | + 'out' => esc_html__( 'Start fast and slow down', 'visualizer' ), | |
| 376 | + 'inAndOut' => esc_html__( 'Start slow, speed up, then slow down', 'visualizer' ), | |
| 377 | + ), | |
| 378 | + esc_html__( 'The easing function applied to the animation.', 'visualizer' ) | |
| 379 | + ); | |
| 380 | + | |
| 381 | + self::_renderSectionEnd(); | |
| 382 | + | |
| 383 | + } | |
| 384 | + | |
| 385 | + /** | |
| 318 | 386 | * Renders tooltip settings section. |
| 319 | 387 | * |
| 320 | 388 | * @since 1.4.0 |
| 321 | 389 | * |
| @@ -688,7 +756,14 @@ | ||
| 688 | 756 | echo '<b>', $title, '</b>'; |
| 689 | 757 | echo '<textarea class="control-text" ', $attributes, ' name="', $name, '" placeholder="', $placeholder, '">', $value, '</textarea>'; |
| 690 | 758 | echo '<p class="viz-section-description">', $desc, '</p>'; |
| 691 | 759 | echo '</div>'; |
| 760 | + } | |
| 761 | + | |
| 762 | + /** | |
| 763 | + * Returns the library this chart implements. | |
| 764 | + */ | |
| 765 | + public function getLibrary() { | |
| 766 | + return $this->_library; | |
| 692 | 767 | } |
| 693 | 768 | |
| 694 | 769 | } |