Database Connections: ODBC (MySQL) Data Source
NOTE: Before trying to get this example to work, please make sure that the Basic Test worked.
In order for this example to work, you will need to set up the example mysql database included with this demo, as well as setup an ODBC data source for the mysql database
in the Chilisoft Administrator. Follow these instructions: odbc_mysql_instructions.html
<%
' Specify Query
' SQLQuery="select firstname, lastname, weekhours, status FROM employee"
' Build a PCScript String containing the data to send to PopChart Server
dim pcScript
' Transpose the data because it comes in the wrong way
pcScript = "graph.Transposed(true)"
' Set the data categories
pcScript = pcScript & "graph.setCategories(Hours Worked)"
' Set Title of PopChart
pcScript = pcScript & "title.setText(Employee Work Hours\nWeek of August 26)"
' Change Data Label Format
pcScript = pcScript & "graph.setDataLabelFormat(%_CATEGORY_NAME: %_VALUE hrs)"
' Instantiate PopChart Embedder Object
set myPopChart = Server.CreateObject("PopChart.Embedder")
' Set PopChart Server Addresses
myPopChart.externalServerAddress = "http://localhost:2001"
myPopChart.internalCommPortAddress = "http://localhost:2002"
' Set Appearance File
myPopChart.appearanceFile = "examples/apfiles/bar.pcxml"
' Set PopChart Image Size and format
myPopChart.width = 540
myPopChart.height = 330
myPopChart.imageType = "FLASH"
' Set PCScript
myPopChart.pcScript = pcScript
' Use PCXML to add SingleSeriesMultiColor
myPopChart.addPCXML("")
' Make the DBQuery
myPopChart.setDBQuery "graph", "org.gjt.mm.mysql.Driver", "jdbc:mysql:127.0.0.1/devcon", "root", "popchart", SQLQuery
myPopChart.makeFullRequest = true
' Write PopChart image to web page
Response.Write myPopChart.getEmbeddingHTML()
Response.Write "PCScript generated by SQL query:
"
Response.Write myPopChart.pcScript
%>
If you see example data for car rentals in Atlanta and Boston, this worked!