Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dashboard Creation Mapping SQL queries to Google Chart Images.

Similar presentations


Presentation on theme: "Dashboard Creation Mapping SQL queries to Google Chart Images."— Presentation transcript:

1 Dashboard Creation Mapping SQL queries to Google Chart Images

2 SQL – to – Visualization Mappings Idea: – Automatic mapping of SQL queries to visualization scripts – Enable easy creation of dashboards based on SQL queries – Enable drill-down and other interactive features – Provide a pedagogical tool for teaching practical data visualization techniques

3 Data-to-Visualization Mapping Algorithms Data Source Visualiza tion Object User-generated SQL queries SQL Query results Data –to- Visualization Mappings

4 Google Charts Images generated via parameterized URL strings (REST queries) Google Charts Developer’s Guide: http://code.google.com/apis/chart/image/docs/making_chart s.html http://code.google.com/apis/chart/image/docs/making_chart s.html Parameters include chart type, chart properties, data, legends, chart sizes and colors, etc. Google returns a PNG file with the graphic for the request

5 Example Google Charts REST String http://chart.apis.google.com/chart ?cht=p3 &chd=t:100,90,80,45,42.5,15 &chl=First|Second|Third|Fourth|Fifth|Sixth &chs=500x200 &chtt=My Chart &chco=FF0000,00FF00,0000FF,000000,FFFFFF,FF00FF,00FF00,00FFFF,DDDD DD,AAAAAA,555555 Type = 3D Pie Data Labels Size Title Colors (per slice) Resulting Image

6 Types of Google Charts

7 SQL Aggregate Queries SQL Aggregate queries provide summary results (sums, averages, counts) with grouping SELECT, FROM GROUP BY Ideal for these visualizations: bar, line, and pie charts

8 Mapping Aggregate SQL Queries to Google Charts Aggregate query From query’s result set, generate the URL parameter values for: – chl (from grouping column) – chd (from aggregate column) – NOTE: for Google Charts, data range is 0-100. So original data must be normalized before being sent. Other parameters are set based on user preferences

9 Sample Aggregate Query From AdventureWorks database: SELECT Production.ProductCategory.Name, COUNT(*) FROM Production.ProductCategory FULL OUTER JOIN Production.ProductSubcategory ON Production.ProductCategory.ProductCategoryID = Production.ProductSubcategory.ProductCategoryID FULL OUTER JOIN Production.Product ON Production.ProductSubcategory.ProductSubcategoryID = Production.Product.ProductSubcategoryID GROUP BY Production.ProductCategory.Name order by count(*) desc

10 Sample AggregateQuery From AdventureWorks database: SELECT Production.ProductCategory.Name, COUNT(*) FROM Production.ProductCategory FULL OUTER JOIN Production.ProductSubcategory ON Production.ProductCategory.ProductCategoryID = Production.ProductSubcategory.ProductCategoryID FULL OUTER JOIN Production.Product ON Production.ProductSubcategory.ProductSubcategoryID = Production.Product.ProductSubcategoryID GROUP BY Production.ProductCategory.Name order by count(*) desc Grouping column, aggregate column Grouping clause

11 Result Set (from AdventureWorks database) Mapped to Google Chart URL String http://chart.apis.google.com/chart?cht=bhs &chd=t:100,64.1148325358852,46.4114832535885,16.7464114832536,13.8755980861244 &chxt=x,y&chxl=0:|0|209|1:|Accessories|Clothing|Bikes|Components|NULL &chs=310x150 &chtt=Product Category Counts &chma=30,30,30,30&chco=FF0000,00FF00,0000FF,000000,FFFFFF,FF00FF,00

12 Result Set (from AdventureWorks database) Mapped to Google Chart URL String http://chart.apis.google.com/chart?cht=bhs &chd=t:100,64.1148325358852,46.4114832535885,16.7464114832536,13.8755980861244 &chxt=x,y&chxl=0:|0|209|1:|Accessories|Clothing|Bikes|Components|NULL &chs=310x150 &chtt=Product Category Counts &chma=30,30,30,30&chco=FF0000,00FF00,0000FF,000000,FFFFFF,FF00FF,00 Aggregate data are normalized, then become the data values in the GoogleCharts URL.

13 Result Set (from AdventureWorks database) Mapped to Google Chart URL String http://chart.apis.google.com/chart?cht=bhs &chd=t:100,64.1148325358852,46.4114832535885,16.7464114832536,13.8755980861244 &chxt=x,y&chxl=0:|0|209|1:|Accessories|Clothing|Bikes|Components|NULL &chs=310x150 &chtt=Product Category Counts &chma=30,30,30,30&chco=FF0000,00FF00,0000FF,000000,FFFFFF,FF00FF,00 Grouping field results become the label values in the GoogleCharts URL.

14 URL String Returns Image http://chart.apis.google.com/chart?cht=bhs &chd=t:100,64.1148325358852,46.4114832535885,16.7464114832536,13.8755980861244 &chxt=x,y&chxl=0:|0|209|1:|Accessories|Clothing|Bikes|Components|NULL &chs=310x150 &chtt=Product Category Counts

15 Visualizing Geographic Data The Google Charts API includes map charts in which you can adjust colors of a map’s regions using numeric data. Good for use on aggregate queries where the group attributes are geographic units (e.g. states of the US, countries of Europe, etc.)

16 Result Set (from AdventureWorks database) Mapped to Google Chart URL String Grouping field in result set (state abbrev) is associated with the states of the chart (cht=t indicates a map, chtm=usa indicates US map) http://chart.apis.google.com/chart?cht=t&chtm=usa&chd=t:100,51.4060742407199,24.139 4825646794,0.134983127109111,0.0899887514060742,0.0899887514060742 &chld=CAWAORILOHTX&chs=250x150&chtt=Tot Customers by State&chma=30,30,30,30&chco=FFFFFF,EEEEEE,0000FF,FF0000&chf=bg,s,EAF7FE C C

17 URL String Returns Image http://chart.apis.google.com/chart?cht=t&chtm=usa&chd=t:100,51.4060742407199,24.139 4825646794,0.134983127109111,0.0899887514060742,0.0899887514060742&chld=CAWA ORILOHTX&chs=250x150&chtt=Tot Customers by State&chma=30,30,30,30&chco=FFFFFF,EEEEEE,0000FF,FF0000&chf=bg,s,EAF7FE

18 Drill-Down From aggregate, get sub-aggregates for each group For a given query, you can specify a sequence of drill-down fields, which are used for each subsequent drill-down request

19 Example Drill-Down SELECT Production.ProductCategory.Name, COUNT(*) FROM Production.ProductCategory FULL OUTER JOIN Production.ProductSubcategory ON Production.ProductCategory.ProductCategoryID = Production.ProductSubcategory.ProductCategoryID FULL OUTER JOIN Production.Product ON Production.ProductSubcategory.ProductSubcategoryID = Production.Product.ProductSubcategoryID GROUP BY Production.ProductCategory.Name order by count(*) desc SELECT Production.ProductSubcategory.Name, COUNT(*) FROM Production.ProductCategory FULL OUTER JOIN Production.ProductSubcategory ON Production.ProductCategory.ProductCategoryID = Production.ProductSubcategory.ProductCategoryID FULL OUTER JOIN Production.Product ON Production.ProductSubcategory.ProductSubcategoryID = Production.Product.ProductSubcategoryID WHERE Production.ProductCategory.Name = 'Accessories' GROUP BY Production.ProductSubcategory.Name ORDER BY count(*) desc Production.ProductSubcategory.Name Modified query (sub-aggregate) Original query (aggregate) Drill-down field

20 Example Drill-Down


Download ppt "Dashboard Creation Mapping SQL queries to Google Chart Images."

Similar presentations


Ads by Google