#1153: Use translations properly, add missing labels, fix bugs and add links to charts

This commit is contained in:
Jyri-Petteri Paloposki 2019-05-19 16:40:00 +03:00
parent 0a106aac5e
commit 0b326e17d8
4 changed files with 160 additions and 75 deletions

View file

@ -2,13 +2,15 @@
<% data = {
datasets: [{
data: Array.new
data: Array.new,
}],
labels: Array.new
labels: Array.new,
ids: Array.new,
}
Stats::TopContextsQuery.new(current_user).result.map { |context|
data[:datasets][0][:data].append(context.total)
data[:labels].append(context.name)
data[:ids].append(context.id)
}
options = {
width: "400px",
@ -17,25 +19,33 @@ options = {
responsive: false,
plugins: {
colorschemes: {
scheme: 'brewer.Paired12'
}
}
scheme: 'brewer.Paired12',
},
},
}
%>
<%= pie_chart data, options.merge({'title': {'display': true, 'text': 'Spread of actions for all contexts'}}) %>
<% #TODO: Move data handling to model. Show value as percentage %>
<%= pie_chart data, options.merge({
'title': {'display': true, 'text': t('stats.spread_of_actions_for_all_context')},
'onClick': 'function(event, array) { console.log(array); window.location.href = "' + url_for(:controller => 'contexts', :action => 'show', :id => -1).gsub('-1', '') + '" + array[0]._chart.chart.data.ids[array[0]._index]; }'
}) %>
<% data = {
datasets: [{
data: Array.new
data: Array.new,
}],
labels: Array.new
}
labels: Array.new,
ids: Array.new,
}
Stats::TopContextsQuery.new(current_user, :running => true).result.map { |context|
data[:datasets][0][:data].append(context.total)
data[:labels].append(context.name)
data[:ids].append(context.id)
}
%>
<%= pie_chart data, options.merge({'title': {'display': true, 'text': 'Spread of actions for visible contexts'}}) %>
<%= pie_chart data, options.merge({
'onClick': 'function(event, array) { console.log(array); window.location.href = "' + url_for(:controller => 'contexts', :action => 'show', :id => -1).gsub('-1', '') + '" + array[0]._chart.chart.data.ids[array[0]._index]; }',
'title': {'display': true, 'text': t('stats.spread_of_running_actions_for_visible_contexts')}}) %>
<br style="clear:both">