Skip to content

Commit

Permalink
Make color pattern to be configurable per view
Browse files Browse the repository at this point in the history
  • Loading branch information
polarp committed Jun 20, 2017
1 parent 6b2d4a5 commit 598dc97
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ckanext/c3charts/fanstatic/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ this.ckan.views.c3charts = this.ckan.views.c3charts || {};
}

var colorPattern = ['#00A58D', '#09505D', '#00587C', '#00A6BC', '#9FCD91', '#293A4C', '#83CCD8', '#A0C1C2'];
if (resourceView.color_pattern){
colorPattern = resourceView.color_pattern.split(',')
}
if (resourceView.sql_expression) {
data = resourceView.sql_data;
if (resourceView.use_sql_keys)
Expand Down
3 changes: 2 additions & 1 deletion ckanext/c3charts/fanstatic/charts.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ckanext/c3charts/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def info(self):
'sql_expression': [ignore_missing],
'use_sql_keys': [ignore_missing],
'y_label_position': [ignore_missing],
'x_label_position': [ignore_missing]
'x_label_position': [ignore_missing],
'color_pattern': [ignore_missing]
}
map(lambda s: schema.update({'{0}_padding'.format(s): [ignore_missing]}), ('r', 'l', 't', 'b'))

Expand Down
1 change: 1 addition & 0 deletions ckanext/c3charts/templates/charts_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ <h2 class="panel-title">{{_('Chart Options')}}</h2>
{{ form.select('remap_key', label=_('Remap'), options=remap_keys, selected=resource_view['remap_key'], is_required=False)
}}
</div>
{{ form.input('color_pattern', label=_('Color pattern (comma separated list of hex colors)'), value=resource_view['color_pattern']) }}
</div>
</div>

Expand Down

0 comments on commit 598dc97

Please sign in to comment.