Open jurgenvinju opened 2 years ago
I managed to get a pie chart using the chartServer and the pie chart:
serve(|http://localhost:30000|, chartServer(chartData(toRel(mapWithData)), \type=\pie(), title="Pie Chart", colorMode=\data()), asDaemon = false);
How would I rewrite this to have multiple types of diagrams on the same page?
Well you could change the html to have multiple div's and multiple fetch calls, and then change the server code to handle the different fetch http requests. Every fetch has a different url path. Every reply handler matches that path. The rest is css voodoo
So mostly you can develop the client side as if you're purely programming js or ts and html/css, and you write a server in Rascal to provide the data directly and to respond to interaction like clicks on file locations.
You could even write the html in an html file. It's not necessary to write an html AST. I did that to keep the co-evolving parts of the server and the client in one file.
Would it be too much to ask for an example with the separate client side? I saw in one of the unittest something to read an HTML file and then serve that, but nothing were part of the file is build up dynamically using data.
I would keep with the basic structure of Charts.rsc and just change that step-by-step to your liking. You can read HTML files with lang::html::IO and copy/paste the HTML syntax trees into your code if you want to learn from existing HTML examples. I'm not working on the weekend, so good luck 😁
would it be nice to also have d3js in there somewhere so we can choose what charts we want?
$EDITOR
)all via @DavyLandman , but if there is more please add to this.