I needed a bar graph for my game… I looked at google but decided to roll my own.
As SGS shows, you can roll your own bar and line charts.
As for pie charts, you can use this feature in SSK:
https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/misc/#createpiechart
Looks very nice. I bow to your awesomeness.
L
I have tried the Google_charts code on 2 windows machines and both failed to return the image in mine format as a url. However, I just tried it on a Mac and it worked perfectly. What could be the difference? Is Corona on Windows when it runs webView calling the local browser for anything? This must be a settings problem but I don’t know where to start looking because I don’t know how webView actually works.
L
If you can open the link in a browser it should work in simulator. After all the simulator just uses IE anyway.
Do you have a link we can test with?
If you download the google-charts .zip here https://github.com/develephant/google-charts-corona/archive/master.zip
And then run the demo in the demo folder using the Corona simulator (not on device yet), does an image of a Google chart show up?
replace main.lua with this
local webView = native.newWebView( display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight ) webView:request( "charts/pie\_3d.html", system.ResourceDirectory )
the code is expecting the URL to included a png but this seems to fail on windows.
I think we all agree webview works. it is the link between the html listener and the lua listener that is suspect on Windows.
Hi,
I’ll boot up a Windows machine and see what might be happening. Thanks for the info, I appreciate it.
-dev
The SVG plugin seems to do the job for me. Perhaps can help someone else too.
local nanosvg = require( "plugin.nanosvg" ) local slices = { { percent = .15, color = "#FF0000" }, { percent = .75, color = "#00FF00" }, { percent = .1, color = "#0000FF" }, } local cumulativePercent = 0 for i = 1, #slices do local percent = slices[i].percent local color = slices[i].color local startX = math.cos( 2 \* math.pi \* cumulativePercent) local startY = math.sin(2 \* math.pi \* cumulativePercent) cumulativePercent = cumulativePercent + percent local endX = math.cos( 2 \* math.pi \* cumulativePercent) local endY = math.sin( 2 \* math.pi \* cumulativePercent) if percent \>= .5 then largeArcFlag = 1 else largeArcFlag = 0 end local pathData = "M "..startX.." "..startY.." A 1 1 0 "..largeArcFlag.." 1 "..endX.." "..endY.." L 0 0" local pathline = "\<svg width='400' height='400' viewBox='-1 -1 2 2' style='transform: rotate(-90deg)'\>\<path d = '"..pathData.."' fill='"..color.."' /\>\</svg\>" local circle = nanosvg.newImage( { data = pathline, x = display.contentCenterX, y = display.contentCenterY, }) end