Skip to content

Instantly share code, notes, and snippets.

@tBaxter
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tBaxter/0f8c44b5bb70d1e4bb70 to your computer and use it in GitHub Desktop.
Save tBaxter/0f8c44b5bb70d1e4bb70 to your computer and use it in GitHub Desktop.
treemap array problem
Could use some input here:
Our current list view allows you to set the visibility on table headers (category)
and cells (individual metrics) for supporting_stat_labels.
When a category has been disabled, an individual cell may attempt to render cells
under a category where a corresponding <TH> does not exist.
The result is a table with a longer row attempting to cover items where a category has been disabled.
Conversely, when a supporting_stat_label has been enabled and a particular cell
has the same supporting_stat_label as disabled the table will render with gaps.
How should this situation be handled?
Should we set a flag per category and check before each individual cell is rendered?
Or should categories be flagged as visible if any containing cell decides to display metrics for that category.
list_view.hamlbars:
= hb 'each supporting_stats' do
= hb 'if visible.list_view' do
%th {{label}}
%tbody
= hb 'each cells' do
%tr{'data-cell-id' => '{{cell_id}}'}
= hb 'each supporting_stats' do
= hb 'if visible.list_view' do
%td {{value}}
treemap.js
if (cell.completedCell) {
supporting_stats: klass.labels.supporting_stats.map(function () {
return { value: '', visible: { list_view: true } };
})
}
else {
supporting_stats: ((d.globals && d.globals.supporting_stats) ||
klass.labels.supporting_stats).map(function (stat, i) {
return $.extend(true,
{ value: I18n.t('treemap.missing_data'), visible: { list_view: true } },
stat,
d.globals && d.globals.supporting_stats && d.globals.supporting_stats[i],
cell[klass.sortKey].supporting_stats && cell[klass.sortKey].supporting_stats[i]
);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment