Skip to content

Commit

Permalink
Merge pull request #6 from p2m2/gridDiv
Browse files Browse the repository at this point in the history
Grid div
  • Loading branch information
ofilangi authored Feb 8, 2023
2 parents e86cf32 + 0bac8c8 commit a086ed2
Show file tree
Hide file tree
Showing 6 changed files with 782 additions and 767 deletions.
5 changes: 5 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
text-align: center;
width: 350px;
}
.gridCanvas {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 10px;
}
</style>
</head>
<body>
Expand Down
1,509 changes: 754 additions & 755 deletions docs/main.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/main.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
text-align: center;
width: 350px;
}
.gridCanvas {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 10px;
}
</style>
</head>
<body>
Expand Down
2 changes: 0 additions & 2 deletions js/src/main/scala/fr/inrae/p2m2/webapp/Chart.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class Chart(ctx:dom.Element,obj:js.Dynamic) extends js.Object

case object Chart {
def buildDataset(labels: Seq[String], values: Seq[Double], backgroundColor: Seq[String]): js.Dynamic = {
println(labels)
println(values)

js.Dynamic.literal(
`type` = "bar",
Expand Down
20 changes: 14 additions & 6 deletions js/src/main/scala/fr/inrae/p2m2/webapp/PositionalCarbonMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ object PositionalCarbonMain {
canvas(id := idBarPlot)


def appendCanvas(idDiv:String,idCanvas:String, title:String) =
def appendCanvas(idDivSample:String,idDiv:String,idCanvas:String, title:String) =
dom
.document
.getElementById(idMainDiv)
.getElementById(idDivSample)
.append(
div( id:=idDiv , `class` := "canvasChart", h2(title), buildCanvasBarPlot(idCanvas) )
div( id:=idDiv ,
`class` := "canvasChart",
h2(title),
buildCanvasBarPlot(idCanvas) )
.render)

def updateHtmlPage(content : String) = {
Expand All @@ -38,10 +41,16 @@ object PositionalCarbonMain {
.groupBy(_._1._1)
.foreach {
case ((sample, listV)) =>
val idDivSample = s"div_$sample"
dom
.document
.getElementById(idMainDiv)
.append(h1(sample).render)
.append(
div(
h1(sample),
div(id:=idDivSample, `class`:="gridCanvas")
).render
)

listV.foreach {
case ((sample, metabolite), data) if data.nonEmpty =>
Expand All @@ -57,10 +66,9 @@ object PositionalCarbonMain {
case (_, _, false) => "rgba(255, 99, 132, 0.2)"
}

appendCanvas(idDiv, idCanvas, title)
appendCanvas(idDivSample,idDiv, idCanvas, title)

val ctx = dom.document.getElementById(idCanvas)
println(ctx)
new Chart(ctx, Chart.buildDataset(labels, values, backgroundColor))
case _ => println("ok")
}
Expand Down

0 comments on commit a086ed2

Please sign in to comment.