quafadas / dedav4s Goto Github PK
View Code? Open in Web Editor NEWDeclarative Data Viz 4 Scala
Home Page: https://quafadas.github.io/dedav4s/
License: Apache License 2.0
Declarative Data Viz 4 Scala
Home Page: https://quafadas.github.io/dedav4s/
License: Apache License 2.0
e.g. breeze
It does not appear to be easy to have en enum, which encodes certain strings:
enum Bah:
case valid
case values
case wait
values & wait will give compile errors.
The DSL, is incomplete, as these are commented out in a few places. To the best of my knowledge, they Arne't "crucial" and will therefore likely be left this way.
add extension method to the top level specs
/**
* Defines how date-time values should be binned.
*/
type TimeUnit =
"date" |
"day" |
"dayhours" |
"dayhoursminutes" |
"dayhoursminutesseconds" | "dayofyear" | "hours" | "hoursminutes" | "hoursminutesseconds" | "milliseconds" |
"minutes" | "minutesseconds" | "month" | "monthdate" | "monthdatehours" | "monthdatehoursminutes" | "monthdatehoursminutesseconds" | "quarter" | "quartermonth" | "seconds" | "secondsmilliseconds" |
//"utcdate" | "utcday" | "utcdayhours" | "utcdayhoursminutes" | "utcdayhoursminutesseconds" | "utcdayofyear" | "utchours" | "utchoursminutes" | "utchoursminutesseconds" | "utcmilliseconds" | "utcminutes" |
//"utcminutesseconds" | "utcmonth" | "utcmonthdate" | "utcmonthdatehours" | "utcmonthdatehoursminutes" | "utcmonthdatehoursminutesseconds" | "utcquarter" | "utcquartermonth" | "utcseconds" |
//"utcsecondsmilliseconds" | "utcweek" | "utcweekday" | "utcweekdayhoursminutes" | "utcweekdayhoursminutesseconds" | "utcweeksdayhours" | "utcyear" | "utcyeardayofyear" | "utcyearmonth" | "utcyearmonthdate" |
//"utcyearmonthdatehours" | "utcyearmonthdatehoursminutes" | "utcyearmonthdatehoursminutesseconds" | "utcyearquarter" | "utcyearquartermonth" | "utcyearweek" | "utcyearweekday" | "utcyearweekdayhours" |
//"utcyearweekdayhoursminutes" | "utcyearweekdayhoursminutesseconds" |
"week" | "weekday" | "weekdayhoursminutes" | "weekdayhoursminutesseconds" | "weeksdayhours" | "year" | "yeardayofyear" | "yearmonth" |
"yearmonthdate" | "yearmonthdatehours" | "yearmonthdatehoursminutes" | "yearmonthdatehoursminutesseconds" | "yearquarter" | "yearquartermonth" |
"yearweek" |
"yearweekday" |
"yearweekdayhours" |
"yearweekdayhoursminutes" |
"yearweekdayhoursminutesseconds"
// type TimeUnit = "date" | "day" // Short string unions work...
/**
* Time unit for the field to be tested.
*
* Time unit (e.g., `year`, `yearmonth`, `month`, `hours`) for a temporal field. or [a
* temporal field that gets casted as
* ordinal](https://vega.github.io/vega-lite/docs/type.html#cast).
*
* __Default value:__ `undefined` (None)
*
* __See also:__ [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html)
* documentation.
*
* The timeUnit.
*/
type TimeUnitUnion = TimeUnit | TimeUnitParams
given Decoder[TimeUnitUnion] = {
List[Decoder[TimeUnitUnion]](
Decoder[TimeUnit].widen,
Decoder[TimeUnitParams].widen,
).reduceLeft(_ or _)
}
given Encoder[TimeUnitUnion] = Encoder.instance {
case enc0 : TimeUnit => Encoder.encodeString(enc0)
case enc1 : TimeUnitParams => Encoder.AsObject[TimeUnitParams].apply(enc1)
}
case class TimeUnitParams (
/**
* If no `unit` is specified, maxbins is used to infer time units.
*/
val maxbins : Option[Double] = None,
/**
* The number of steps between bins, in terms of the least significant unit provided.
*/
val step : Option[Double] = None,
/**
* Defines how date-time values should be binned.
*/
val unit : Option[TimeUnit] = None,
/**
* True to use UTC timezone. Equivalent to using a `utc` prefixed `TimeUnit`.
*/
val utc : Option[Boolean] = None
) derives Encoder.AsObject, Decoder
We got a lot of free commentary from the code gen... check how to generate and publish scaladoc.
Surprisingly, this might actually be tractable.
Scalably typed already does this in JS land. So it would be perfectly possible to have a typesafe DSL in scala JS.
However, the implementations dead end at js.native calls. Point is, that we don't need those. Vega is declarative, so we only need to be able to serialise the object and properties to JSON. We can discard it's actual implementation!
Solution sketch :
And then we'd generate the entire DSL automagically!
No tab competition
Consider moving to enums when Circe releases support???
I think we would need to wait for this;
almond-sh/almond#718
This is the solution sketch
Quafadas/almond@2441c22
To leave behind a good comment when changing a spec
change to dedav_laminar etc
Consider integrating the companion micorservice into the project so that web socket updating works "out the box".
https://github.com/Quafadas/viz-websockets
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
This actually shouldn't be too difficult. SBT type level already supports cross publishing.
Need another library for http requests in JS land.
How to display?
import viz.PlotTargets.desktopBrowser
import viz.vega.plots._
val barchart = SpecUrl.BarChart.toDsl() // it decoded successfully!
//val barchart:
// Either[io.circe.Error, viz.dsl.vegaLite.VegaLiteDsl | viz.dsl.vega.VegaDsl] = Right(VegaDsl(
barchart.map(_.plot) // need a map right now as it's an either...
Doesn't plot right now, because mark / encode is a blank case class.
Think the codegen fails because;
vega/vega#3491
See discussion,
Vscode needs to fix stuff, then test again
Workaround: set div Id manually.
check this and fix
On simple iterables...
Iterable[Numeric] - pie chart
Iterable[Numeric] -line chart
Iterable[Numeric] -dot plot
Iterable[(Numeric, Numeric)] - scatterplot
Iterable[(Numeric, Numeric)] - regression
Iterable[(Numeric, Numeric)] - quantile quantile
etc
The problem is here:
BROWSE is not supported under some Linux distributions and the Desktop.getDesktop().browse
call throws an exception java.lang.UnsupportedOperationException: The BROWSE action is not supported on the current platform!
. This link has some suggestions for cross-platform implementations; more or less you do runtime.exec("xdg-open " + url)
on X11-based systems (I'm not sure how to do this under Wayland).
It would be cool, to not leave VSCode context, when using worksheets, for example.
Can this be done?
Do something more comprehensive than the readme?
Mdoc?
https://scalameta.org/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.