Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- Fix update axis baseline color #925 
- Update more features images #926
- Fix update minor grid line field #924 
- Add new filter for container attributes #922 
- Fix axis data format issue #920 
- Chart unique title #915 
- Fix block back button issue #930 
- Userguide broken documentation link #918
  • Loading branch information
vytisbulkevicius committed Aug 30, 2022
2 parents 6fa01e7 + 905f7a1 commit 7584e7d
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 319 deletions.
290 changes: 9 additions & 281 deletions classes/Visualizer/Gutenberg/build/block.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion classes/Visualizer/Gutenberg/build/handsontable.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions classes/Visualizer/Gutenberg/build/handsontable.js

Large diffs are not rendered by default.

Expand Up @@ -18,6 +18,8 @@ const {
TextControl
} = wp.components;

import { getColorCode } from '../../utils.js';

class HorizontalAxisSettings extends Component {
constructor() {
super( ...arguments );
Expand Down Expand Up @@ -85,9 +87,9 @@ class HorizontalAxisSettings extends Component {
label={ __( 'Base Line Color' ) }
>
<ColorPalette
value={ settings.hAxis.baselineColor }
value={ settings.vAxis.baselineColor }
onChange={ e => {
settings.hAxis.baselineColor = e;
settings.vAxis.baselineColor = getColorCode( e );
this.props.edit( settings );
} }
/>
Expand All @@ -100,7 +102,7 @@ class HorizontalAxisSettings extends Component {
value={ settings.hAxis.textStyle.color || settings.hAxis.textStyle }
onChange={ e => {
settings.hAxis.textStyle = {};
settings.hAxis.textStyle.color = e;
settings.hAxis.textStyle.color = getColorCode( e );
this.props.edit( settings );
} }
/>
Expand Down Expand Up @@ -128,7 +130,7 @@ class HorizontalAxisSettings extends Component {

<p>
{ __( 'For date axis labels, this is a subset of the date formatting ' ) }
<ExternalLink href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax">
<ExternalLink href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax">
{ __( 'ICU date and time format.' ) }
</ExternalLink>
</p>
Expand Down
Expand Up @@ -56,7 +56,7 @@ class PieSettings extends Component {

<p>
{ __( 'For date axis labels, this is a subset of the date formatting ' ) }
<ExternalLink href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax">
<ExternalLink href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax">
{ __( 'ICU date and time format.' ) }
</ExternalLink>
</p>
Expand Down
Expand Up @@ -175,7 +175,7 @@ class SeriesSettings extends Component {

<p>
{ __( 'This is a subset of the date formatting ' ) }
<ExternalLink href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax">
<ExternalLink href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax">
{ __( 'ICU date and time format.' ) }
</ExternalLink>
</p>
Expand Down
Expand Up @@ -18,6 +18,8 @@ const {
TextControl
} = wp.components;

import { getColorCode } from '../../utils.js';

class VerticalAxisSettings extends Component {
constructor() {
super( ...arguments );
Expand Down Expand Up @@ -85,9 +87,9 @@ class VerticalAxisSettings extends Component {
label={ __( 'Base Line Color' ) }
>
<ColorPalette
value={ settings.vAxis.baselineColor }
value={ settings.hAxis.baselineColor }
onChange={ e => {
settings.vAxis.baselineColor = e;
settings.hAxis.baselineColor = getColorCode( e );
this.props.edit( settings );
} }
/>
Expand All @@ -100,7 +102,7 @@ class VerticalAxisSettings extends Component {
value={ settings.vAxis.textStyle.color || settings.vAxis.textStyle }
onChange={ e => {
settings.vAxis.textStyle = {};
settings.vAxis.textStyle.color = e;
settings.vAxis.textStyle.color = getColorCode( e );
this.props.edit( settings );
} }
/>
Expand Down Expand Up @@ -129,7 +131,7 @@ class VerticalAxisSettings extends Component {

<p>
{ __( 'For date axis labels, this is a subset of the date formatting ' ) }
<ExternalLink href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax">
<ExternalLink href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax">
{ __( 'ICU date and time format.' ) }
</ExternalLink>
</p>
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Gutenberg/src/Editor.js
Expand Up @@ -581,7 +581,7 @@ class Editor extends Component {
} else if ( 'chartSelect' === this.state.route ) {
route = 'showCharts';
}
this.setState({ route });
this.setState({ route, isLoading: false });
this.props.setAttributes({ route });
} }
>
Expand Down
11 changes: 11 additions & 0 deletions classes/Visualizer/Gutenberg/src/utils.js
Expand Up @@ -178,3 +178,14 @@ export const getFormatterForGoogle = ( dataType ) => {
}
return null;
};

export const getColorCode = ( color ) => {
if ( -1 === color.indexOf( '#' ) ) {
let getCssVar = color.match( /\((.*)\)/ ).pop();
if ( getCssVar ) {
let style = getComputedStyle( document.body );
return style.getPropertyValue( getCssVar );
}
}
return color;
};
18 changes: 18 additions & 0 deletions classes/Visualizer/Module.php
Expand Up @@ -67,6 +67,7 @@ public function __construct( Visualizer_Plugin $plugin ) {
$this->_addFilter( Visualizer_Plugin::FILTER_UNDO_REVISIONS, 'undoRevisions', 10, 2 );
$this->_addFilter( Visualizer_Plugin::FILTER_HANDLE_REVISIONS, 'handleExistingRevisions', 10, 2 );
$this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, 'getDataAs', 10, 3 );
$this->_addFilter( Visualizer_Plugin::FILTER_CHART_TITLE, 'filterChartTitle', 10, 2 );
register_shutdown_function( array($this, 'onShutdown') );

}
Expand Down Expand Up @@ -791,4 +792,21 @@ public function _getImage( $chart = null ) {
'csv' => $image,
);
}

/**
* Filter chart title.
*
* @access public
* @param string $post_title Post title.
* @param int $post_id Post ID.
* @return string
*/
public function filterChartTitle( $post_title, $post_id ) {
$post_type = get_post_type( $post_id );
$post_title = trim( $post_title );
if ( 'visualizer' === $post_type && 'Visualization' === $post_title ) {
return sprintf( '%s #%d', $post_title, $post_id );
}
return $post_title;
}
}
5 changes: 3 additions & 2 deletions classes/Visualizer/Module/Chart.php
Expand Up @@ -1245,15 +1245,16 @@ public function cloneChart() {
'vaction' => false,
),
admin_url( 'admin.php' )
)
),
null,
'db'
);
}
}

if ( defined( 'WP_TESTS_DOMAIN' ) ) {
wp_die();
}

wp_redirect( $redirect );
exit;
}
Expand Down
2 changes: 2 additions & 0 deletions classes/Visualizer/Module/Frontend.php
Expand Up @@ -341,6 +341,8 @@ public function renderChart( $atts ) {
$attributes['data-lazy-limit'] = $atts['lazy'];
}

$attributes = apply_filters( 'visualizer_container_attributes', $attributes, $chart->ID );

$chart = apply_filters( 'visualizer_schedule_refresh_chart', $chart, $chart->ID, false );

// Get and update settings.
Expand Down
1 change: 1 addition & 0 deletions classes/Visualizer/Plugin.php
Expand Up @@ -90,6 +90,7 @@ class Visualizer_Plugin {
const FILTER_HANDLE_REVISIONS = 'visualizer-handle-revisions';
const FILTER_GET_CHART_DATA_AS = 'visualizer-get-chart-data-as';
const FILTER_HANDLE_CACHE_EXPIRATION_TIME = 'visualizer-handle-expiration-time';
const FILTER_CHART_TITLE = 'the_title';

const CF_DB_SCHEDULE = 'visualizer-db-schedule';
const CF_DB_QUERY = 'visualizer-db-query';
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Render/Sidebar.php
Expand Up @@ -468,7 +468,7 @@ protected function _renderFormatField( $index = 0 ) {
esc_html__( 'Date Format', 'visualizer' ),
'series[' . $index . '][format]',
isset( $this->series[ $index ]['format'] ) ? $this->series[ $index ]['format'] : '',
sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU date and time format%2$s.', 'visualizer' ), '<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">', '</a>' ),
sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU date and time format%2$s.', 'visualizer' ), '<a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax" target="_blank">', '</a>' ),
'eeee, dd LLLL yyyy'
);
break;
Expand Down
8 changes: 4 additions & 4 deletions classes/Visualizer/Render/Sidebar/Graph.php
Expand Up @@ -242,7 +242,7 @@ protected function _renderHorizontalAxisSettings() {
esc_html__( 'Specify 0 to disable the minor gridlines.', 'visualizer' ),
0,
'number',
array( 'min' => 0, 'max' => 1, 'step' => 1 )
array( 'min' => 0, 'step' => 1 )
);

self::_renderColorPickerItem(
Expand Down Expand Up @@ -358,7 +358,7 @@ protected function _renderVerticalAxisSettings() {
esc_html__( 'Specify 0 to disable the minor gridlines.', 'visualizer' ),
0,
'number',
array( 'min' => 0, 'max' => 1, 'step' => 1 )
array( 'min' => 0, 'step' => 1 )
);

self::_renderColorPickerItem(
Expand Down Expand Up @@ -481,7 +481,7 @@ protected function _renderHorizontalAxisFormatField() {
),
sprintf(
esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
'<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
'<a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax" target="_blank">',
'</a>'
)
)
Expand Down Expand Up @@ -510,7 +510,7 @@ protected function _renderVerticalAxisFormatField() {
),
sprintf(
esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
'<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
'<a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax" target="_blank">',
'</a>'
)
)
Expand Down
4 changes: 2 additions & 2 deletions classes/Visualizer/Render/Sidebar/Type/ChartJS/Linear.php
Expand Up @@ -205,7 +205,7 @@ protected function _renderHorizontalAxisGeneralSettings() {
),
sprintf(
esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
'<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
'<a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax" target="_blank">',
'</a>'
)
)
Expand Down Expand Up @@ -307,7 +307,7 @@ protected function _renderVerticalAxisGeneralSettings() {
),
sprintf(
esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
'<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
'<a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax" target="_blank">',
'</a>'
)
)
Expand Down
Expand Up @@ -72,7 +72,7 @@ protected function _renderPieSettings() {
),
sprintf(
esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
'<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
'<a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax" target="_blank">',
'</a>'
)
)
Expand Down
Binary file modified images/pro/excel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/pro/import.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/pro/more_charts.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/pro/support.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 22 additions & 14 deletions js/render-chartjs.js
Expand Up @@ -65,7 +65,7 @@
for (i = 0; i < data.length; i++) {
row = [];
for (j = 0; j < series.length; j++) {
if (series[j].type === 'date' || series[j].type === 'datetime') {
if (series[j].type === 'date' || series[j].type === 'datetime') {
date = new Date(data[i][j]);
data[i][j] = null;
if (Object.prototype.toString.call(date) === "[object Date]") {
Expand Down Expand Up @@ -349,19 +349,22 @@
// format the axes labels.
if(typeof settings[axis + '_format'] !== 'undefined' && settings[axis + '_format'] !== ''){
var format = settings[axis + '_format'];
switch(axis){
case 'xAxes':
settings.scales.x.ticks.callback = function(value, index, values){
return format_datum(value, format);
};
break;
case 'yAxes':
settings.scales.y.ticks.callback = function(value, index, values){
return format_datum(value, format);
};
break;
}
delete settings[axis + '_format'];
var isDateFormat = moment( moment().format( format ),format, true ).isValid();
if ( ! isDateFormat ) {
switch(axis){
case 'xAxes':
settings.scales.x.ticks.callback = function(value, index, values){
return format_datum(value, format);
};
break;
case 'yAxes':
settings.scales.y.ticks.callback = function(value, index, values){
return format_datum(value, format);
};
break;
}
delete settings[axis + '_format'];
}
}
delete settings[axis];
}
Expand Down Expand Up @@ -445,6 +448,11 @@
function format_data(datum, j, settings, series){
j = j - 1;
var format = typeof settings.series !== 'undefined' && typeof settings.series[j] !== 'undefined' ? settings.series[j].format : '';
if ( '' === format && typeof settings.yAxes_format !== 'undefined' ) {
format = settings.yAxes_format;
} else if ( '' === format && typeof settings.xAxes_format !== 'undefined' ) {
format = settings.xAxes_format;
}
return format_datum(datum, format, series[j + 1].type);
}

Expand Down

0 comments on commit 7584e7d

Please sign in to comment.