Skip to content

Commit

Permalink
fix HTML display for mismatching number of frequent items between pro…
Browse files Browse the repository at this point in the history
…files (#536)

- Iterate based on min. number of frequentItems
- frequentItem Strings loaded w/ empty string when trying to access not-existing index
  • Loading branch information
FelipeAdachi committed Apr 11, 2022
1 parent 79039ca commit 04f3c31
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/whylogs/viewer/templates/index-hbs-cdn-all-in.html
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,10 @@ <h1 class="no-responsive__title">Hold on! :)</h1>
return svgEl._groups[0][0].outerHTML;
}

function range_arr(size, startAt = 0) {
return [...Array(size).keys()].map(i => i + startAt);
}

function generateBarChart(currentWidth, key, datas, referenceData) {
let histogramData = [],
overlappedHistogramData = [];
Expand All @@ -1786,10 +1790,13 @@ <h1 class="no-responsive__title">Hold on! :)</h1>
}
let yFormat,
xFormat;
const data = histogramData.map((profile, index) => {


minArray = range_arr(Math.min(histogramData.length,overlappedHistogramData.length))
const data = minArray.map((profile, index) => {
return {
group: index,
profile: profile.axisY,
profile: histogramData[index].axisY,
reference_profile: overlappedHistogramData[index].axisY
}
}).slice(0, 20)
Expand Down Expand Up @@ -1885,10 +1892,13 @@ <h1 class="no-responsive__title">Hold on! :)</h1>
histogramData = chartData(datas)
overlappedHistogramData = chartData(referenceData.columns[key.data.key])
}
const data = histogramData.map((value, index) => {
const difference = value.axisY - overlappedHistogramData[index].axisY

minArray = range_arr(Math.min(histogramData.length,overlappedHistogramData.length))

const data = minArray.map((value, index) => {
const difference = histogramData[index].axisY - overlappedHistogramData[index].axisY
const negativeValues = difference < 0 ? difference : 0
return [+value.axisY, negativeValues]
return [+histogramData[index].axisY, negativeValues]
}).slice(0, 20).flat()

let yFormat,
Expand Down Expand Up @@ -2666,7 +2676,7 @@ <h1 class="no-responsive__title">Hold on! :)</h1>
${frequentItemBoxElement('',chipElementTableData(items[item].value))}
`
referenceFrequentItemString += `
${frequentItemBoxElement('',chipElementTableData(referenceItems[item].value))}
${frequentItemBoxElement('',chipElementTableData(referenceItems[item]?.value ?? ''))}
`
}
);
Expand Down

0 comments on commit 04f3c31

Please sign in to comment.