Skip to content

Commit

Permalink
Report charts: fix styling for count-based 2dim charts.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed Sep 3, 2015
1 parent 200c378 commit 74f62ec
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
6 changes: 6 additions & 0 deletions app/assets/javascripts/miq_jqplot.js
Expand Up @@ -86,6 +86,12 @@ function jqplot_xaxis_tick_highlight(str, seriesIndex, pointIndex, plot) {
str;
}

function jqplot_yaxis_tick_highlight(str, seriesIndex, pointIndex, plot) {
return plot.options.axes.yaxis.ticks[pointIndex] + ' / ' +
plot.options.series[seriesIndex].label + ': ' +
str;
}

$(document).ready(function(){
$(window).resize(function() {
setTimeout(jqplot_redraw_charts, 500);
Expand Down
56 changes: 41 additions & 15 deletions lib/report_formatter/jqplot.rb
Expand Up @@ -111,22 +111,48 @@ def build_reporting_chart_other
def build_reporting_chart_dim2
counts = super # FIXME: counts are passed for now, should handle this in a better way
default_legend
mri.chart[:options].update(
:stackSeries => true,
:seriesDefaults => {:renderer => 'jQuery.jqplot.BarRenderer'},
:axes => {
:xaxis => {
:renderer => 'jQuery.jqplot.CategoryAxisRenderer',
:ticks => counts.keys,
# FIXME: we only support stacked bars or columns
if mri.graph[:type] =~ /Column/
mri.chart[:options].update(
:stackSeries => true,
:seriesDefaults => {
:rendererOptions => {:barDirection => 'vertical', :barWidth => 5},
:renderer => 'jQuery.jqplot.BarRenderer',
},
},
:highlighter => {
:show => true,
:tooltipAxes => 'y',
:tooltipContentEditor => 'jqplot_xaxis_tick_highlight',
:tooltipLocation => 'n'
}
)
:axes => {
:xaxis => {
:renderer => 'jQuery.jqplot.CategoryAxisRenderer',
:ticks => counts.keys,
},
},
:highlighter => {
:show => true,
:tooltipAxes => 'y',
:tooltipContentEditor => 'jqplot_xaxis_tick_highlight',
:tooltipLocation => 'n'
}
)
else # Bar
mri.chart[:options].update(
:stackSeries => true,
:seriesDefaults => {
:renderer => 'jQuery.jqplot.BarRenderer',
:rendererOptions => {:barDirection => 'horizontal', :barWidth => 5},
},
:axes => {
:yaxis => {
:renderer => 'jQuery.jqplot.CategoryAxisRenderer',
:ticks => counts.keys,
},
},
:highlighter => {
:show => true,
:tooltipAxes => 'x',
:tooltipContentEditor => 'jqplot_yaxis_tick_highlight',
:tooltipLocation => 'n'
}
)
end
end

def build_planning_chart(maxcols, divider)
Expand Down

0 comments on commit 74f62ec

Please sign in to comment.