Skip to content

Commit 27c1920

Browse files
Merge pull request #112 from ViderumGlobal/charts-improvements
Charts improvements
2 parents 42091e4 + bb066a7 commit 27c1920

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

ckanext/querytool/fanstatic/javascript/modules/viz-preview.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,12 @@ ckan.module('querytool-viz-preview', function() {
186186
// On horizontal bar the x axis is now actually the y axis
187187
yrotate = x_text_rotate;
188188
}
189-
190189
if(this.options.chart_type === 'bscatter'){
191-
var rs = d3.scale.linear()
192-
.domain([0.01, 100000])
193-
.range([5, 50]);
190+
//workaround for bubble charts, scale log base 10 because of large values
191+
var rs = d3.scale.log().base(10).domain([1,1000]).range([0,10]);
194192
ctype = 'scatter';
195193
options.point = {
196194
r: function(d) {
197-
//workaround for bubble charts, divide by 10 because of large values
198195
var num = d.value;
199196
return rs(num)
200197
},

ckanext/querytool/helpers.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,14 @@ def get_color_scheme():
170170
{'value': '#22758e, #b63b3b, #f9c414, #e3e8e6, #4c4555, '
171171
'#d53c3c, #80add3, #97cfcc, #e4b03d, #c39de0',
172172
'text': 'Orient'},
173-
{'value': '#3b5998, #8b9dc3, #dfe3ee, #f7f7f7, #ffffff, ',
174-
'text': 'Facebook'},
175-
{'value': '#ffb3ba, #ffdfba, #ffffba, #baffc9, #bae1ff, ',
173+
{'value': '#3b5998, #8b9dc3, #dfe3ee, #f7f7f7, #ffffff, '
174+
'#011f4b, #03396c, #005b96, #6497b1, #6497b1',
175+
'text': 'Blue'},
176+
{'value': '#ffb3ba, #ffdfba, #ffffba, #baffc9, #bae1ff, '
177+
'#ee4035, #f37736, #fdf498, #7bc043, #0392cf',
176178
'text': 'Rainbow'},
177-
{'value': '#2e4045, #83adb5, #c7bbc9, #5e3c58, #bfb5b2, ',
179+
{'value': '#2e4045, #83adb5, #c7bbc9, #5e3c58, #bfb5b2, '
180+
'#a69eb0, #efeff2, #f2e2cd, #dadae3, #000000',
178181
'text': 'Muted'}
179182
]
180183

@@ -199,7 +202,8 @@ def get_charts_data_formats():
199202
Get available formats for charts tooltip and axis ticks
200203
:return:
201204
'''
202-
options = [{'text': 'Dolar e.g 2000$', 'value': '$'},
205+
options = [{'text': 'Default', 'value': ''},
206+
{'text': 'Dolar e.g 2000$', 'value': '$'},
203207
{'text': 'Rounded e.g 2k', 'value': 's'},
204208
{'text': 'Percentage (multiply by 100) e.g 200000%',
205209
'value': 'p'},

ckanext/querytool/templates/ajax_snippets/chart_fields.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div class="control-group ">
1414
<label class="control-label" for="chart_field_title_{{ n }}">{{ _('Chart title') }}</label>
1515
<div class="controls ">
16-
<input id="chart_field_title_{{ n }}" name="chart_field_title_{{ n }}" value="{{ chart_title }}" placeholder="{{ _('Chart title') }}" type="text">
16+
<input id="chart_field_title_{{ n }}" name="chart_field_title_{{ n }}" value="{{ chart_title }}" placeholder="Chart title" type="text">
1717
</div>
1818
</div>
1919

@@ -85,7 +85,7 @@
8585
<div class="control-group ">
8686
<label class="control-label" for="chart_field_tooltip_name_{{ n }}">{{ _('Tooltip name') }}</label>
8787
<div class="controls ">
88-
<input id="chart_field_tooltip_name_{{ n }}" type="text" name="chart_field_tooltip_name_{{ n }}" value="{{ tooltip_name }}">
88+
<input id="chart_field_tooltip_name_{{ n }}" type="text" name="chart_field_tooltip_name_{{ n }}" value="{{ tooltip_name }}" placeholder="Tooltip name">
8989
</div>
9090
</div>
9191

@@ -119,7 +119,7 @@
119119
<div class="control-group ">
120120
<label class="control-label" for="chart_field_y_label_{{ n }}">{{ _('Y axis label') }}</label>
121121
<div class="controls ">
122-
<input id="chart_field_y_label_{{ n }}" type="text" name="chart_field_y_label_{{ n }}" value="{{ y_label }}">
122+
<input id="chart_field_y_label_{{ n }}" type="text" name="chart_field_y_label_{{ n }}" value="{{ y_label }}" placeholder="Y axis label">
123123
</div>
124124
</div>
125125

@@ -130,7 +130,7 @@
130130
<div class="control-group ">
131131
<label class="control-label" for="chart_field_padding_top_{{ n }}">{{ _('Padding top') }}</label>
132132
<div class="controls ">
133-
<input id="chart_field_padding_top_{{ n }}" type="text" name="chart_field_padding_top_{{ n }}" value="{{ ptop }}">
133+
<input id="chart_field_padding_top_{{ n }}" type="number" min="0" name="chart_field_padding_top_{{ n }}" value="{{ ptop }}" placeholder="Default 0">
134134
</div>
135135
</div>
136136

@@ -140,7 +140,7 @@
140140
<div class="control-group ">
141141
<label class="control-label" for="chart_field_padding_bottom_{{ n }}">{{ _('Padding bottom') }}</label>
142142
<div class="controls ">
143-
<input id="chart_field_padding_bottom_{{ n }}" type="text" name="chart_field_padding_bottom_{{ n }}" value="{{ pbtm }}">
143+
<input id="chart_field_padding_bottom_{{ n }}" type="number" min="0" name="chart_field_padding_bottom_{{ n }}" value="{{ pbtm }}" placeholder="Default 0">
144144
</div>
145145
</div>
146146

0 commit comments

Comments
 (0)