Skip to content

Commit 8cd384d

Browse files
authored
ui: add support for filtering out zeros in info page (#4806)
Turn it on by defualt as it's far more useful. Note not using Datagrid etc here was a very intentional choice. I don't need 99.99% of the complexity of datagrid, I just need something which works 100% of the time and doesn't have too many bells and whistles and also don't want to risk breaking antying Fixes: #3615
1 parent 654aa2a commit 8cd384d

File tree

1 file changed

+15
-1
lines changed
  • ui/src/plugins/dev.perfetto.TraceInfoPage/tabs

1 file changed

+15
-1
lines changed

ui/src/plugins/dev.perfetto.TraceInfoPage/tabs/stats.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import m from 'mithril';
1515
import {Engine} from '../../../trace_processor/engine';
1616
import {NUM_NULL, UNKNOWN} from '../../../trace_processor/query_result';
17+
import {Button} from '../../../widgets/button';
1718
import {Section} from '../../../widgets/section';
1819
import {Icon} from '../../../widgets/icon';
1920
import {Tooltip} from '../../../widgets/tooltip';
@@ -227,13 +228,19 @@ interface StatsSectionAttrs {
227228
}
228229

229230
class StatsSection implements m.ClassComponent<StatsSectionAttrs> {
231+
private hideZeroValues = true;
232+
230233
view({attrs}: m.CVnode<StatsSectionAttrs>) {
231234
const data = attrs.data;
232235
if (data === undefined || data.length === 0) {
233236
return m('');
234237
}
235238

236-
const tableRows = data.map((row) => {
239+
const filtered = this.hideZeroValues
240+
? data.filter((row) => row.value !== 0 && row.value !== null)
241+
: data;
242+
243+
const tableRows = filtered.map((row) => {
237244
const help = [];
238245
if (Boolean(row.description)) {
239246
help.push(
@@ -267,6 +274,13 @@ class StatsSection implements m.ClassComponent<StatsSectionAttrs> {
267274

268275
return m(
269276
'section.pf-trace-info-page__stats-section',
277+
m(Button, {
278+
label: this.hideZeroValues ? 'Show zero values' : 'Hide zero values',
279+
icon: this.hideZeroValues ? 'visibility' : 'visibility_off',
280+
onclick: () => {
281+
this.hideZeroValues = !this.hideZeroValues;
282+
},
283+
}),
270284
m(
271285
'table.pf-trace-info-page__stats-table',
272286
m(

0 commit comments

Comments
 (0)