Round values in category report

Closes #7949
This commit is contained in:
Mike Jolley 2015-04-14 10:51:20 +01:00
parent 809573af41
commit 38f8c5fd0b
1 changed files with 3 additions and 7 deletions

View File

@ -262,7 +262,6 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
$category = get_term( $category, 'product_cat' );
$product_ids = $this->get_products_in_category( $category->term_id );
$category_total = 0;
$category_chart_data = array();
for ( $i = 0; $i <= $this->chart_interval; $i ++ ) {
@ -283,16 +282,12 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
if ( isset( $this->item_sales_and_times[ $time ][ $id ] ) ) {
$interval_total += $this->item_sales_and_times[ $time ][ $id ];
$category_total += $this->item_sales_and_times[ $time ][ $id ];
}
}
$category_chart_data[] = array( $time, $interval_total );
$category_chart_data[] = array( $time, (float) wc_format_decimal( $interval_total, wc_get_price_decimals() ) );
}
//if ( ! $category_total )
// continue;
$chart_data[ $category->term_id ]['category'] = $category->name;
$chart_data[ $category->term_id ]['data'] = $category_chart_data;
@ -315,8 +310,9 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
$width = $this->barwidth / sizeof( $chart_data );
$offset = ( $width * $index );
$series = $data['data'];
foreach ( $series as $key => $series_data )
foreach ( $series as $key => $series_data ) {
$series[ $key ][0] = $series_data[0] + $offset;
}
echo '{
label: "' . esc_js( $data['category'] ) . '",
data: jQuery.parseJSON( "' . json_encode( $series ) . '" ),