Skip to content

Commit 571ea53

Browse files
add bubble charts
1 parent f0e7944 commit 571ea53

File tree

7 files changed

+150
-2
lines changed

7 files changed

+150
-2
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darra
391391
'enabled' => true,
392392
'supports' => array( 'Google Charts', 'ChartJS' ),
393393
),
394+
'bubble' => array(
395+
'name' => esc_html__( 'Bubble', 'visualizer' ),
396+
'enabled' => true,
397+
// chartjs' bubble is ugly looking (and it won't work off the default bubble.csv) so it is being excluded for the time being.
398+
'supports' => array( 'Google Charts' ),
399+
),
394400
'scatter' => array(
395401
'name' => esc_html__( 'Scatter', 'visualizer' ),
396402
'enabled' => true,
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
3+
// +----------------------------------------------------------------------+
4+
// | Copyright 2013 Madpixels (email : [email protected]) |
5+
// +----------------------------------------------------------------------+
6+
// | This program is free software; you can redistribute it and/or modify |
7+
// | it under the terms of the GNU General Public License, version 2, as |
8+
// | published by the Free Software Foundation. |
9+
// | |
10+
// | This program is distributed in the hope that it will be useful, |
11+
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12+
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13+
// | GNU General Public License for more details. |
14+
// | |
15+
// | You should have received a copy of the GNU General Public License |
16+
// | along with this program; if not, write to the Free Software |
17+
// | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
18+
// | MA 02110-1301 USA |
19+
// +----------------------------------------------------------------------+
20+
// | Author: Eugene Manuilov <[email protected]> |
21+
// +----------------------------------------------------------------------+
22+
/**
23+
* Class for area chart sidebar settings.
24+
*
25+
* @category Visualizer
26+
* @package Render
27+
* @subpackage Sidebar
28+
*
29+
* @since 1.0.0
30+
*/
31+
class Visualizer_Render_Sidebar_Type_GoogleCharts_Bubble extends Visualizer_Render_Sidebar_Linear {
32+
33+
/**
34+
* Constructor.
35+
*
36+
* @since 1.0.0
37+
*
38+
* @access public
39+
* @param array $data The data what has to be associated with this render.
40+
*/
41+
public function __construct( $data = array() ) {
42+
parent::__construct( $data );
43+
$this->_includeCurveTypes = false;
44+
}
45+
46+
/**
47+
* Renders template.
48+
*
49+
* @since 1.0.0
50+
*
51+
* @access protected
52+
*/
53+
protected function _toHTML() {
54+
$this->_renderGeneralSettings();
55+
$this->_renderAxesSettings();
56+
$this->_renderBubbleSettings();
57+
$this->_renderViewSettings();
58+
$this->_renderAdvancedSettings();
59+
}
60+
61+
/**
62+
* Renders bubble settings items.
63+
*
64+
* @since 3.4.0
65+
*
66+
* @access protected
67+
*/
68+
protected function _renderBubbleSettings() {
69+
self::_renderGroupStart( esc_html__( 'Bubble Settings', 'visualizer' ) );
70+
self::_renderSectionStart();
71+
self::_renderTextItem(
72+
esc_html__( 'Opacity', 'visualizer' ),
73+
'bubble[opacity]',
74+
isset( $this->bubble['opacity'] ) ? $this->bubble['opacity'] : 0.8,
75+
esc_html__( 'The default opacity of the bubbles, where 0.0 is fully transparent and 1.0 is fully opaque.', 'visualizer' ),
76+
0.8,
77+
'number',
78+
array( 'min' => 0.0, 'max' => 1.0, 'step' => 0.1 )
79+
);
80+
81+
self::_renderColorPickerItem(
82+
esc_html__( 'Stroke Color', 'visualizer' ),
83+
'bubble[stroke]',
84+
isset( $this->bubble[ $index ]['stroke'] ) ? $this->bubble[ $index ]['stroke'] : null,
85+
null
86+
);
87+
88+
self::_renderCheckboxItem(
89+
esc_html__( 'Sort Bubbles by Size', 'visualizer' ),
90+
'sortBubblesBySize',
91+
$this->sortBubblesBySize ? 1 : 0,
92+
1,
93+
esc_html__( 'If true, sorts the bubbles by size so the smaller bubbles appear above the larger bubbles. If false, bubbles are sorted according to their order in the DataTable.', 'visualizer' )
94+
);
95+
96+
self::_renderTextItem(
97+
esc_html__( 'Size (max)', 'visualizer' ),
98+
'sizeAxis[maxValue]',
99+
isset( $this->sizeAxis['maxValue'] ) ? $this->sizeAxis['maxValue'] : '',
100+
esc_html__( 'The size value (as appears in the chart data) to be mapped to sizeAxis.maxSize. Larger values will be cropped to this value.', 'visualizer' ),
101+
'',
102+
'number',
103+
array( 'step' => 1 )
104+
);
105+
106+
self::_renderTextItem(
107+
esc_html__( 'Size (min)', 'visualizer' ),
108+
'sizeAxis[minValue]',
109+
isset( $this->sizeAxis['minValue'] ) ? $this->sizeAxis['minValue'] : '',
110+
esc_html__( 'The size value (as appears in the chart data) to be mapped to sizeAxis.minSize. Smaller values will be cropped to this value.', 'visualizer' ),
111+
'',
112+
'number',
113+
array( 'step' => 1 )
114+
);
115+
116+
self::_renderSectionEnd();
117+
self::_renderGroupEnd();
118+
119+
}
120+
121+
122+
}

css/frame.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,14 @@ div.viz-group-content .viz-group-description {
457457
padding: 15px;
458458
border: 1px solid #e0e0e0;
459459
background-color: white;
460-
background-image: url(../images/chart_types_june2019_g.png);
460+
background-image: url(../images/chart_types_v340_g.png);
461461
background-repeat: no-repeat;
462462
background-position: center center;
463463
}
464464

465465
.type-label-selected,
466466
.type-box > .type-label:hover {
467-
background-image: url(../images/chart_types_june2019.png);
467+
background-image: url(../images/chart_types_v340.png);
468468
}
469469

470470
.type-box-area .type-label {
@@ -499,6 +499,10 @@ div.viz-group-content .viz-group-description {
499499
background-position: -300px -225px;
500500
}
501501

502+
.type-box-bubble .type-label {
503+
background-position: -600px -225px;
504+
}
505+
502506
.type-box-column .type-label {
503507
background-position: -600px -225px;
504508
}
File renamed without changes.
File renamed without changes.

js/render-google.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ var __visualizer_chart_images = [];
9797
break;
9898
case 'gauge':
9999
break;
100+
case 'bubble':
101+
settings.sortBubblesBySize = settings.sortBubblesBySize ? settings.sortBubblesBySize == 1 : false; // jshint ignore:line
102+
break;
100103
case 'timeline':
101104
settings['timeline'] = [];
102105
settings['timeline']['groupByRowLabel'] = settings['groupByRowLabel'] ? true : false;
@@ -352,6 +355,7 @@ var __visualizer_chart_images = [];
352355
case 'candlestick':
353356
case 'histogram':
354357
case 'scatter':
358+
case 'bubble':
355359
$type = 'corechart';
356360
break;
357361
case 'geo':

samples/bubble.csv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ID, Life Expectancy, Fertility Rate, Region, Population
2+
string,number,number,string,number
3+
CAN, 80.66, 1.67, North America, 33739900
4+
DEU, 79.84, 1.36, Europe, 81902307
5+
DNK, 78.6, 1.84, Europe, 5523095
6+
RUS, 68.6, 1.54, Europe, 141850000
7+
EGY, 72.73, 2.78, Middle East, 79716203
8+
GBR, 80.05, 2, Europe, 61801570
9+
IRN, 72.49, 1.7, Middle East, 73137148
10+
IRQ, 68.09, 4.77, Middle East, 31090763
11+
ISR, 81.55, 2.96, Middle East, 7485600
12+
USA, 78.09, 2.05, North America, 307007000

0 commit comments

Comments
 (0)