Sunburst Chart using Javascript

Okay I am totally new to Xojo but have found it relatively straight forward until now.

I need to create a Sunburst Chart to drill down data using javascript based on https://github.com/vasturiano/sunburst-chart/blob/master/README.md This really is a very nice piece of work.

I understand this means my app has to be a web app and that’s okay but am really at a loss on how to call and use the js function.

The function does use a json file for data which I presume I can provide locally??? The Dev does provide the code for download so not sure if I should include that in my app locally or not? Again, am really at a loss with this and would seriously appreciate any assistance. I have not been able to find any examples that appear to be along the lines of what I am trying to do so hopefully someone can help.

Thanks in advance.

Nik

You can use Javascript in an HtmlViewer in a desktop app. The HtmlViewer has a function called ExecuteJavascript.

Thanks Beatrix.

If I understand correctly, I can achieve this as a desktop app?

Would I need to localise the relevant js files?

Thanks,

Nik

I’ve uploaded an older example for D3. This is from a guy here on the forum. It should show you how to call your sunburst library.

Link is: http://www.mothsoftware.com/downloads/d3example3.zip

Thanks Beatrix. Yes that was spot on.

I actually found that post very early on but the links to the files were broken.

Thanks again.

One of the things I am looking to do is pull some js variables from the HTMLViewer into Xojo. Can this be done?

All of the articles I have found seem to deal with this where the app is a WebApp whereas I am looking for a solution for a Desktop app.

Any thoughts?

[quote=442696:@Beatrix Willius]I’ve uploaded an older example for D3. This is from a guy here on the forum. It should show you how to call your sunburst library.

Link is: http://www.mothsoftware.com/downloads/d3example3.zip[/quote]
@Beatrix Willius : can you please reupload it ? thanks.

@Beatrix Willius the example worked really well and helped me move the development along quickly.However I am stuck now that I am trying to build the app for deployment testing.The issue being the js files called by the html file can’t seem to be found. I note this is not an issue with the example provided that uses OpenDialog to load the HTML but my variation has the GetFolderItem hard coded.

It appears that the HTML file cannot find the js files so I have tried every possible build method to include in the js files in resources, contents folder as well as a dedicated folder without luck.

Is there a specific location that I should store the js files during build so they are in the correct relative position to the HTML file or is there a specific path that I should use in the HTML that points to the js?

[quote=442696:@Beatrix Willius]I’ve uploaded an older example for D3. This is from a guy here on the forum. It should show you how to call your sunburst library.

Link is: http://www.mothsoftware.com/downloads/d3example3.zip[/quote]

Turn on the dev tools in your browser so you can see were it expects to get the file from to start with. Then ensure that your web server is responding to the request.

Not sure how as it’s opening up within a xojo window ie desktop app not web app so no active browser?

Thanks James. I figured that I could recode to force the html to a browser and observe what was going on and found the issue was the data file was not in the same place so the issue was not js file location related after all. Good tip just the same as it led me to the problem and solution.