Quafadas / dedav4s

Declarative Data Viz 4 Scala
https://quafadas.github.io/dedav4s/
Apache License 2.0
50 stars 4 forks source link

scalars example does not work #30

Closed pmeheut closed 1 year ago

pmeheut commented 1 year ago

Hi,

I've tried to compile the code from https://quafadas.github.io/dedav4s/ScalaVersions/scalaJS.html#examples but got this error message:

[error]     |            BarChart(List(viz.Utils.fillDiv))(using nodeCtx.thisNode.ref)
[error]     |                                                    ^^^^^^^^^^^^^^^^^^^^
[error]     |           Found:    (nodeCtx.thisNode.ref : org.scalajs.dom.html.Div)
[error]     |           Required: viz.PlotTarget
Quafadas commented 1 year ago

Are you using laminar? The nodeCtx us a ref to the laminar Div. Your example is an extract from the laminar section and won't work outside of the context, of that laminar div.

Can you post up a longer example and a little context of what you're aiming for? At a high level, the idea is to simply cast any div type to html.Div, and then feed it to the plot.

sketch

val aDiv = ??? // from some UI framework
val domDiv = aDiv.asInstanceOf[html.Div] // this should be safe - a div is always a div to the browser

 BarChart(List(viz.Utils.fillDiv))(using domDiv)

Does this help?

As an aside, I'm actually not at all happy with this API, and have the heavy lifting for much better scalaJS integration done.

It's just... not ready... one day I'll have time to finish it properly. This will get easier / better in future.

pmeheut commented 1 year ago

Yes, it helps and the problem was on my side: bad dependency in sbt. Everything works as expected. Sorry for the mistake.

Quafadas commented 1 year ago

Great - I hope you have success with it - please let me know either way around - I'm very open to feedback of any sort... and quite proud that there is someone out there actually giving it a go!