Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createDashboard4() {
- var json_results = getData('http://localhost:9999/countcarbytype')
- data_results = []
- var Header = ['car Type', 'count', 'region',{'type': 'string', 'role': 'tooltip', 'p': {'html': true}}];
- data_results.push(Header)
- for (var i = 0; i < json_results.length; i++) {
- var value = json_results[i];
- var URL = ""+value["imageURL"][0]
- data_results.push([value["_id"]["title"], value["countofcars"], value["_id"]["region"]],createCustomHTMLContent(URL,value["_id"]["title"], value["countofcars"], value["_id"]["region"]))
- }
- console.log(data_results)
- var data = google.visualization.arrayToDataTable(data_results);
- // Define a StringFilter control for the 'Name' column
- var stringFilter = new google.visualization.ControlWrapper({
- 'controlType': 'StringFilter',
- 'containerId': 'control4',
- 'options': {
- 'filterColumnLabel': 'region'
- }
- });
- // Define a table visualization
- var table = new google.visualization.ChartWrapper({
- 'chartType': 'BarChart',
- 'containerId': 'chart4',
- 'options': { 'height': 400, 'width': 500, 'title': 'Count of cars by Model Type', 'legend': 'none','tooltip': { isHtml: true } },
- 'view': { 'columns': [0, 1] }
- });
- // Create the dashboard.
- var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard')).
- // Configure the string filter to affect the table contents
- bind(stringFilter, table).
- // Draw the dashboard
- draw(data);
- return stringFilter;
- }
- google.setOnLoadCallback(drawVisualization);
- function createCustomHTMLContent(imageURL, title, totalCount, region) {
- return '<div style="padding:5px 5px 5px 5px;">' +
- '<img src="' + imageURL + '" style="width:75px;height:50px"><br/>' +
- '<table class="medals_layout">' + '<tr>' +
- '<td><img src="https://upload.wikimedia.org/wikipedia/commons/1/15/Gold_medal.svg" style="width:25px;height:25px"/></td>' +
- '<td><b>' + title + '</b></td>' + '</tr>' + '<tr>' +
- '<td><img src="https://upload.wikimedia.org/wikipedia/commons/1/15/Gold_medal.svg" style="width:25px;height:25px"/></td>' +
- '<td><b>' + totalCount + '</b></td>' + '</tr>' + '<tr>' +
- '<td><img src="https://upload.wikimedia.org/wikipedia/commons/5/52/Bronze_medal.svg" style="width:25px;height:25px"/></td>' +
- '<td><b>' + region + '</b></td>' + '</tr>' + '</table>' + '</div>';
- }
Add Comment
Please, Sign In to add comment