annotatedtimeline with JSON

90 views
Skip to first unread message

Kamal Ahmed

unread,
Aug 2, 2012, 9:38:02 AM8/2/12
to google-visua...@googlegroups.com
Is there away to populate  https://developers.google.com/chart/interactive/docs/gallery/annotatedtimeline#Example
with data from JSON
e.g. sample:

{"actions":[{},{},{},{},{},{},{},{},{}],"description":"","displayName":"PYGMENTS","displayNameOrNull":null,"name":"PYGMENTS","url":"http://192.168.1.104:8080/job/PYGMENTS/","buildable":true,"builds":[{"number":21,"url":"http://192.168.1.104:8080/job/PYGMENTS/21/"},{"number":16,"url":"http://192.168.1.104:8080/job/PYGMENTS/16/"},{"number":15,"url":"http://192.168.1.104:8080/job/PYGMENTS/15/"},{"number":14,"url":"http://192.168.1.104:8080/job/PYGMENTS/14/"},{"number":13,"url":"http://192.168.1.104:8080/job/PYGMENTS/13/"},{"number":12,"url":"http://192.168.1.104:8080/job/PYGMENTS/12/"},{"number":11,"url":"http://192.168.1.104:8080/job/PYGMENTS/11/"},{"number":10,"url":"http://192.168.1.104:8080/job/PYGMENTS/10/"},{"number":9,"url":"http://192.168.1.104:8080/job/PYGMENTS/9/"},{"number":8,"url":"http://192.168.1.104:8080/job/PYGMENTS/8/"}],"color":"yellow","firstBuild":{"number":8,"url":"http://192.168.1.104:8080/job/PYGMENTS/8/"},"healthReport":[{"descri
ption":"No xml report files found for cpd","iconUrl":"health-00to19.png","score":0},{"description":"Cobertura Coverage: 60% (8885/14925) Lines","iconUrl":"health-60to79.png","score":75},{"description":"Build stability: 1 out of the last 5 builds failed.","iconUrl":"health-60to79.png","score":80},{"description":"Test Result: 0 tests failing out of a total of 768
 tests.","iconUrl":"health-80plus.png","score":100}],"inQueue":false,"keepDependencies":false,"lastBuild":{"number":21,"url":"http://192.168.1.104:8080/job/PYGMENTS/21/"},"lastCompletedBuild":{"number":21,"url":"http://192.168.1.104:8080/job/PYGMENTS/21/"},"lastFailedBuild":{"number":16,"url":"http://192.168.1.104:8080/job/PYGMENTS/16/"},"lastStableBuild":{"number":13,"url":"http://192.168.1.104:8080/job/PYGMENTS/13/"},"lastSuccessfulBuild":{"number":21,"url":"http://192.168.1.104:8080/job/PYGMENTS/21/"},"lastUnstableBuild":{"number":21,"url":"http://192.168.1.104:8080/job/PYGMENTS/21/"},"lastUnsuccessfulBuild":{"number":21,"url":"http://192.168.1.104:8080/job/PYGMENTS/21/"},"nextBuildNumber":22,"property":[{}],"queueItem":null,"concurrentBuild":false,"downstreamProjects":[],"scm":{},"upstreamProjects":[]}


here is a working example:

example:

if we add the following Javascript in the description:
<script>
var xmlhttp = null;
if (window.XMLHttpRequest)
    xmlhttp = new XMLHttpRequest();
else if (window.ActiveXObject) {
    if (new ActiveXObject("Microsoft.XMLHTTP"))
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    else
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
var url = document.location + "/api/xml?xpath=count%28//job[color=%22blue%22]%29div+count%28//job%29"
xmlhttp.open("GET", url, false);//false means synchronous
xmlhttp.send()
var buildSuccessFraction= xmlhttp.responseText
document.write('<img src="http://chart.apis.google.com/chart?chs=320x160&cht=gom&chd=t:' + buildSuccessFraction * 100.0 + '&chxt=x,y&chxl=y|0:||1:|failure|success">')
</script>

asgallant

unread,
Aug 2, 2012, 12:43:16 PM8/2/12
to google-visua...@googlegroups.com
You will have to parse your JSON manually and input it into a DataTable object; there is no support for just plugging in a different style data source.
Reply all
Reply to author
Forward
0 new messages