Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the barchart show term2 value in list samples if there is overlay #2364

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions client/plots/barchart.events.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { newpane, export_data } from '../src/client'
import { filterJoin, getFilterItemByTag, getNormalRoot, findItemByTermId, normalizeProps } from '#filter'
import { rgb } from 'd3-color'
import { roundValueAuto } from '#shared/roundValue.js'

import { isNumericTerm } from '#shared/terms.js'
export default function getHandlers(self) {
const tip = new Menu({ padding: '5px' })
self.dom.tip = tip
Expand Down Expand Up @@ -74,7 +74,7 @@ export default function getHandlers(self) {

//mouse-over p-value and 2x2 table
if (t2) {
const pvalue = d.groupPvalues.term2tests.find(x => x.term2id === d.dataId).pvalue
const pvalue = d.groupPvalues?.term2tests?.find(x => x.term2id === d.dataId).pvalue
const term1Label = d.groupPvalues.term1Label
const term2Label = d.groupPvalues.term2tests.find(x => x.term2id === d.dataId).term2Label
const tableValues = d.groupPvalues.term2tests.find(x => x.term2id === d.dataId).tableValues
Expand Down Expand Up @@ -496,19 +496,34 @@ async function listSamples(event, self, seriesId, dataId, chartId) {
}
const data = await self.app.vocabApi.getAnnotatedSampleData(opts)
const rows = []
const termIsNumeric = isNumericTerm(self.config.term.term)
const term2isNumeric = self.config.term2 ? isNumericTerm(self.config.term2.term) : false

for (const sample of data.lst) {
const value = data.refs.bySampleId[Number(sample.sample)].label
rows.push([{ value }])
const sampleName = data.refs.bySampleId[Number(sample.sample)].label
const row = [{ value: sampleName }]
if (termIsNumeric) {
const value = sample[self.config.term.$id]?.value
row.push({ value: roundValueAuto(value) })
}
if (self.config.term2) {
let value = sample[self.config.term2.$id]
const label = self.config.term2.term.values?.[value.key]?.label
value = term2isNumeric ? roundValueAuto(value.value) : label || value.value
row.push({ value })
}
rows.push(row)
}
const columns = [{ label: 'Sample' }]
if (termIsNumeric) columns.push({ label: self.config.term.term.name })
if (self.config.term2) columns.push({ label: self.config.term2.term.name })
const menu = new Menu({ padding: '5px' })
const div = menu.d.append('div')
renderTable({
rows,
columns,
div,
showLines: true,
maxWidth: '27vw',
maxHeight: '40vh',
resize: true
})
Expand All @@ -523,7 +538,7 @@ async function listSamples(event, self, seriesId, dataId, chartId) {
values: [{ key: value }]
}
}
if (term.term.type == 'integer' || term.term.type == 'float') {
if (isNumericTerm(term.term)) {
const bins = self.bins[termIndex]
tvs.tvs.ranges = [bins.find(bin => bin.label == value)]
}
Expand Down
Loading