Skip to content

Commit

Permalink
Add axes description for remaining people plot
Browse files Browse the repository at this point in the history
  • Loading branch information
v6ak committed Oct 24, 2023
1 parent 1b0dbeb commit 729a9f2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions client/src/main/scala/com/v6ak/zbdb/PlotRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ final class PlotRenderer(participantTable: ParticipantTable):
val data = cummulativeMortality.dropRight(1).zipWithIndex.map{case (cm, i) =>
(participantTable.parts(i), cm, rows.size - cm, i)
}
genericRemainingParticipantsCountPlot(data, "line")(_.toString)
genericRemainingParticipantsCountPlot(data, "line", "lidi")(_.toString)
}

def remainingRelativeCountPlot = showChartInModal() { rows =>
Expand All @@ -146,13 +146,14 @@ final class PlotRenderer(participantTable: ParticipantTable):
val data = cummulativeMortality.dropRight(1).zipWithIndex.map { case (cm, i) =>
(participantTable.parts(i), 100.0 * cm / size, 100.0 * (size - cm) / size, i)
}
genericRemainingParticipantsCountPlot[Double](data, "bar")(num => f"$num%.2f%%")
genericRemainingParticipantsCountPlot[Double](data, "bar", "lidi (%)")(num => f"$num%.2f%%")
}


private def genericRemainingParticipantsCountPlot[T](
data: immutable.IndexedSeq[(Part, T, T, Int)],
chartType: String,
yLabel: String,
)(format: T => String) =
def dataset(name: String, f: ((Part, T, T, Int)) => T): js.Dynamic = literal(
label = name,
Expand Down Expand Up @@ -191,7 +192,17 @@ final class PlotRenderer(participantTable: ParticipantTable):
x = literal(
`type` = "linear",
min = 0,
title = literal(
display = true,
text = "vzdálenost (km)",
),
),
y = literal(
title = literal(
display = true,
text = yLabel,
),
)
),
)
)
Expand Down

0 comments on commit 729a9f2

Please sign in to comment.