Skip to content

Commit

Permalink
Fix: remove success rate label from survey main forecast chart (#2287)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Jun 15, 2023
1 parent 9f81e25 commit 717d0da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
18 changes: 8 additions & 10 deletions assets/js/components/charts/Forecasts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ export default class Forecasts extends Component<Props> {
const { ceil } = this.props
const { width, height, data } = this.state

let surveysData = data.filter((d) => d.label !== "Success rate")

const flatten = Array.prototype.concat(...surveysData.map((d) => [...d.values, ...d.forecast]))
const flatten = Array.prototype.concat(...data.map((d) => [...d.values, ...d.forecast]))

let initialTime, lastTime

Expand Down Expand Up @@ -97,9 +95,9 @@ export default class Forecasts extends Component<Props> {
.classed("forecast-tooltip", true)
.style("visibility", "hidden")

for (var i = 0; i < surveysData.length; i++) {
for (var j = 0; j < surveysData[i].values.length; j++) {
if (y(surveysData[i].values[j].value) != 0 && x(surveysData[i].values[j].time) != 0) {
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].values.length; j++) {
if (y(data[i].values[j].value) != 0 && x(data[i].values[j].time) != 0) {
d3.select(this.refs.circles)
.selectAll("path")
.data([data[i].values[j]])
Expand All @@ -108,8 +106,8 @@ export default class Forecasts extends Component<Props> {
.attr("cx", (d) => x(d.time))
.attr("cy", (d) => y(d.value))
.attr("r", "3px")
.style("fill", surveysData[i].color)
.style("stroke", surveysData[i].color)
.style("fill", data[i].color)
.style("stroke", data[i].color)
.on("mouseover", (d) =>
tooltip
.text(d.value)
Expand All @@ -129,7 +127,7 @@ export default class Forecasts extends Component<Props> {

d3.select(this.refs.values)
.selectAll("path")
.data(surveysData)
.data(data)
.enter()
.append("path")
.merge(d3.select(this.refs.values).selectAll("path"))
Expand All @@ -142,7 +140,7 @@ export default class Forecasts extends Component<Props> {

d3.select(this.refs.forecasts)
.selectAll("path")
.data(surveysData)
.data(data)
.enter()
.append("path")
.merge(d3.select(this.refs.forecasts).selectAll("path"))
Expand Down
7 changes: 5 additions & 2 deletions assets/js/components/surveys/SurveyShow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ class SurveyShow extends Component<any, State> {
}
})

let forecastLines = forecasts.filter((d) => d.label !== "Success rate")
let successRateLines = forecasts.filter((d) => d.label === "Success rate")

return (
<div className="cockpit">
<div className="row">
Expand Down Expand Up @@ -396,8 +399,8 @@ class SurveyShow extends Component<any, State> {
)}
</div>
<Stats data={stats} />
<Forecasts data={forecasts} ceil={100} />
{forecasts.filter((d) => d.id == "successRate").length ? (
<Forecasts data={forecastLines} ceil={100} />
{successRateLines.length ? (
<div>
<div className="header" style={{ marginTop: "40px", marginBottom: "0" }}>
<div className="title">{t("Success Rate")}</div>
Expand Down

0 comments on commit 717d0da

Please sign in to comment.