Skip to content

Commit

Permalink
add support for hidden facets in facetview, plus some minor tweaks to…
Browse files Browse the repository at this point in the history
… reportview
  • Loading branch information
richard-jones committed Sep 10, 2014
1 parent 567324d commit 4565970
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
18 changes: 16 additions & 2 deletions jquery.facetview2.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ function facetList(options) {
* none - no requirements for specific classes and ids
*
* should (not must) respect the following config
*
*
* options.facet[x].hidden - whether the facet should be displayed in the UI or not
* options.render_terms_facet - renders a term facet into the list
* options.render_range_facet - renders a range facet into the list
* options.render_geo_facet - renders a geo distance facet into the list
Expand All @@ -295,6 +296,11 @@ function facetList(options) {
var thefilters = '';
for (var idx = 0; idx < filters.length; idx++) {
var facet = filters[idx]
// if the facet is hidden do not include it in this list
if (facet.hidden) {
continue;
}

var type = facet.type ? facet.type : "terms"
if (type === "terms") {
thefilters += options.render_terms_facet(facet, options)
Expand Down Expand Up @@ -1199,6 +1205,7 @@ function getUrlVars() {
"display" : "<display name>", // display name for the UI
"type": "term|range|geo_distance", // the kind of facet this will be
"open" : true|false, // whether the facet should be open or closed (initially)
"hidden" : true|false // whether the facet should be displayed at all (e.g. you may just want the data for a callback)
// terms facet only
Expand Down Expand Up @@ -1241,6 +1248,7 @@ function getUrlVars() {
// be initialised to the default
"default_facet_type" : "terms",
"default_facet_open" : false,
"default_facet_hidden" : false,
"default_facet_size" : 10,
"default_facet_operator" : "AND", // logic
"default_facet_order" : "count",
Expand Down Expand Up @@ -1503,6 +1511,7 @@ function getUrlVars() {
var facet = provided_options.facets[i]
if (!("type" in facet)) { facet["type"] = provided_options.default_facet_type }
if (!("open" in facet)) { facet["open"] = provided_options.default_facet_open }
if (!("hidden" in facet)) { facet["hiddel"] = provided_options.default_facet_hidden }
if (!("size" in facet)) { facet["size"] = provided_options.default_facet_size }
if (!("logic" in facet)) { facet["logic"] = provided_options.default_facet_operator }
if (!("order" in facet)) { facet["order"] = provided_options.default_facet_order }
Expand Down Expand Up @@ -1551,6 +1560,9 @@ function getUrlVars() {
// for each facet, set the facet size, order and and/or status
for (var i=0; i < options.facets.length; i=i+1) {
var f = options.facets[i]
if (f.hidden) {
continue;
}
setUIFacetSize({facet : f})
setUIFacetSort({facet : f})
setUIFacetAndOr({facet : f})
Expand Down Expand Up @@ -2150,7 +2162,9 @@ function getUrlVars() {
facet["values"] = records.slice(0, size)

// set the results on the page
setUIFacetResults(facet)
if (!facet.hidden) {
setUIFacetResults(facet)
}
}

// set the facet visibility
Expand Down
12 changes: 9 additions & 3 deletions jquery.reportview.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function renderPie(params) {
var transition_duration = options.pie_transition_duration

// set the space up for the new chart
$(selector, context).empty()
//$(selector).empty()

// generate the pie
nv.addGraph(function() {
Expand Down Expand Up @@ -183,12 +183,14 @@ function renderMultiBar(params) {

var y_tick_format = params.multibar_y_tick_format
var transition_duration = params.multibar_transition_duration
var controls = options.multibar_controls

// set the space up for the new chart
$(selector, context).empty()
//$(selector).empty()

nv.addGraph(function() {
var chart = nv.models.multiBarChart()
.showControls(controls)

chart.yAxis
.tickFormat(d3.format(y_tick_format));
Expand Down Expand Up @@ -219,7 +221,10 @@ function renderHorizontalMultiBar(params) {
var controls = options.horizontal_multibar_controls
var y_tick_format = options.horizontal_multibar_y_tick_format
var transition_duration = options.horizontal_multibar_transition_duration


// set the space up for the new chart
//$(selector).empty()

nv.addGraph(function() {
var chart = nv.models.multiBarHorizontalChart()
.x(function(d) { return d.label })
Expand Down Expand Up @@ -272,6 +277,7 @@ function renderHorizontalMultiBar(params) {
"multibar_convert" : convertMultiBar,
"multibar_y_tick_format" : ',.0f',
"multibar_transition_duration" : 500,
"multibar_controls" : false,

// convert/render functions for horizontal bar chart
"horizontal_multibar_render" : renderHorizontalMultiBar,
Expand Down

0 comments on commit 4565970

Please sign in to comment.