Skip to content

Commit a840cf5

Browse files
add support for annotation and other roles
1 parent 3d4323b commit a840cf5

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

classes/Visualizer/Render/Sidebar/Google.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,29 @@ public static function enqueue_assets( $deps = array() ) {
8383
return 'visualizer-render-google-lib';
8484
}
8585

86-
86+
/**
87+
* Renders the role field.
88+
*
89+
* @since 3.4.0
90+
*
91+
* @access protected
92+
*/
93+
protected function _renderRoleField( $index ) {
94+
self::_renderSelectItem(
95+
esc_html__( 'Special Role', 'visualizer' ),
96+
'series[' . $index . '][role]',
97+
isset( $this->series[ $index ]['role'] ) ? $this->series[ $index ]['role'] : '',
98+
array(
99+
'' => esc_html__( 'Default (Data)', 'visualizer' ),
100+
'annotation' => esc_html__( 'Annotation', 'visualizer' ),
101+
'annotationText' => esc_html__( 'Annotation Text', 'visualizer' ),
102+
'certainty' => esc_html__( 'Certainty', 'visualizer' ),
103+
'emphasis' => esc_html__( 'Emphasis', 'visualizer' ),
104+
'scope' => esc_html__( 'Scope', 'visualizer' ),
105+
'style' => esc_html__( 'Style', 'visualizer' ),
106+
'tooltip' => esc_html__( 'Tooltip', 'visualizer' ),
107+
),
108+
sprintf( esc_html__( 'Determines whether the series has to be used for a special role as mentioned in %1$shere%2$s.', 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/roles#what-roles-are-available" target="_blank">', '</a>' )
109+
);
110+
}
87111
}

classes/Visualizer/Render/Sidebar/Graph.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ protected function _renderSeries( $index ) {
422422
isset( $this->series[ $index ]['color'] ) ? $this->series[ $index ]['color'] : null,
423423
null
424424
);
425+
426+
$this->_renderRoleField( $index );
427+
425428
}
426429

427430
/**

classes/Visualizer/Render/Sidebar/Linear.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ protected function _renderSeries( $index ) {
289289
isset( $this->series[ $index ]['color'] ) ? $this->series[ $index ]['color'] : null,
290290
null
291291
);
292+
293+
$this->_renderRoleField( $index );
294+
292295
}
293296

294297
}

js/render-google.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ var __visualizer_chart_images = [];
207207
if (!series[i + 1]) {
208208
continue;
209209
}
210+
if(typeof settings.series[i].role !== 'undefined' && settings.series[i].role !== ''){
211+
table.setColumnProperty(i + 1, 'role', settings.series[i].role);
212+
}
210213
format_data(id, table, series[i + 1].type, settings.series[i].format, i + 1);
211214
}
212215
break;

0 commit comments

Comments
 (0)