Skip to content

Commit c612a55

Browse files
support for non-english series
1 parent cf246cb commit c612a55

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

classes/Visualizer/Source.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ protected function _normalizeData( $data ) {
222222
}
223223
break;
224224
case 'string':
225-
if ( ! function_exists( 'mb_detect_encoding' ) || mb_detect_encoding( $data[ $i ] ) !== 'ASCII' ) {
226-
$data[ $i ] = \ForceUTF8\Encoding::toUTF8( $data[ $i ] );
227-
}
225+
$data[ $i ] = $this->toUTF8( $data[ $i ] );
228226
break;
229227
}
230228
}
@@ -233,4 +231,21 @@ protected function _normalizeData( $data ) {
233231
return $data;
234232
}
235233

234+
235+
/**
236+
* Converts values to UTF8, if required.
237+
*
238+
* @access protected
239+
*
240+
* @param string $datum The data to convert.
241+
*
242+
* @return string The converted data.
243+
*/
244+
protected final function toUTF8( $datum ) {
245+
if ( ! function_exists( 'mb_detect_encoding' ) || mb_detect_encoding( $datum ) !== 'ASCII' ) {
246+
$datum = \ForceUTF8\Encoding::toUTF8( $datum );
247+
}
248+
return $datum;
249+
}
250+
236251
}

classes/Visualizer/Source/Csv.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ private function _fetchSeries( &$handle ) {
8383

8484
for ( $i = 0, $len = count( $labels ); $i < $len; $i++ ) {
8585
$default_type = $i == 0 ? 'string' : 'number';
86+
87+
$labels[ $i ] = $this->toUTF8( $labels[ $i ] );
88+
8689
$this->_series[] = array(
8790
'label' => $labels[ $i ],
8891
'type' => isset( $types[ $i ] ) ? $types[ $i ] : $default_type,

0 commit comments

Comments
 (0)