Skip to content

Commit

Permalink
Don't slice using negative indexes to filter undefined data from bar …
Browse files Browse the repository at this point in the history
…charts (#496)
  • Loading branch information
jamie256 committed Mar 29, 2022
1 parent b72131b commit 324ec87
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,12 @@ <h1 class="no-responsive__title">Hold on! :)</h1>

const findAndDeleteUndefined = (axisData) => {
const undefinedAxisIndex = axisData.findIndex((axis) => axis === undefined)
return [...axisData.slice(0, undefinedAxisIndex), ...axisData.slice(undefinedAxisIndex + 1)]
if (undefinedAxisIndex == -1) {
return axisData;
}

const result = [...axisData.slice(0, undefinedAxisIndex), ...axisData.slice(undefinedAxisIndex + 1)]
return result
}

const filterAndSortChartData = (overlappedHistogramData, histogramData) => {
Expand Down Expand Up @@ -330,6 +335,7 @@ <h1 class="no-responsive__title">Hold on! :)</h1>

svgEl.append("g")
.attr("transform", `translate(${MARGIN.LEFT}, 0)`)
.attr("id", "g1")
.call(yAxis)
.call(g => g.select(".domain").remove())
.call(g => g.selectAll(".tick line")
Expand Down Expand Up @@ -362,6 +368,7 @@ <h1 class="no-responsive__title">Hold on! :)</h1>

svgEl.append("g")
.attr("transform", `translate(0,${SVG_HEIGHT - MARGIN.BOTTOM})`)
.attr("id", "g2")
.call(xAxis)
.call(g => g.select(".domain").remove())
.call(g => g.selectAll(".tick line").remove())
Expand All @@ -380,11 +387,13 @@ <h1 class="no-responsive__title">Hold on! :)</h1>
.range(rectColors)

svgEl.append("g")
.attr("id", "g3")
.selectAll("g")
.data(data)
.enter()
.append("g")
.attr("transform", function(d) { return "translate(" + xScale(d?.group) + ",0)"; })
.attr("id", "g4")
.selectAll("rect")
.data(function(d) { return subgroups.map(function(key) { return {key: key, value: d && d[key]}; }); })
.enter().append("rect")
Expand All @@ -399,6 +408,7 @@ <h1 class="no-responsive__title">Hold on! :)</h1>
return svgEl._groups[0][0].outerHTML;
}


const profileFromCSVfile = {{{reference_profile_from_whylogs}}}

Handlebars.registerHelper("getDoubleHistogramChart",(column,key) => {
Expand Down

0 comments on commit 324ec87

Please sign in to comment.