Solved

Cfgraph, Coldfusion and MySQL getting started

Posted on 2007-11-14
3
559 Views
Last Modified: 2008-02-01
Hi,

I need to display the hits, and visits of our site in a bar chart using Coldfusion. An example of the SQL data is like so....

daily_id, date, hits, visits
1, 11/13/2007, 20000, 400000
2. 11/12/2007, 20000, 400000

but I would like to have a drop down menu for months and show a bar chart of the daily hits throughout the month. This is what I've got started...

<cfquery name="get_general_stats" datasource="#dsn#">
        SELECT *, COUNT(visits) as "visits"
        FROM stats_daily
        ????
         WHERE month of the date =  '#form.date#'
</cfquery>


<CFCHART
             backgroundcolor="F2ECEC"
               CHARTWIDTH="950"
               CHARTHEIGHT="180"
         ROTATED="no"
               showlegend="yes"
              showmarkers="yes"
             SHOW3D="yes"
         XOFFSET=".01"
         YOFFSET=".02"
               FONTSIZE="10"
         FONTBOLD="Yes"
               DATABACKGROUNDCOLOR="DDDDDD"
             SCALETO="100"
         GRIDLINES="5"
         SHOWXGRIDLINES="no"
         SHOWYGRIDLINES="yes">
            
            <CFCHARTSERIES
           TYPE="bar"
         QUERY="query_name"
           ITEMCOLUMN="date"
           VALUECOLUMN="visits"
           SERIESLABEL="Visits"
           SERIESCOLOR="F94A4A">
             
            </cfchart>

Thanks,

B
0
Comment
Question by:brihol44
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
bayesianmind earned 500 total points
ID: 20284750
Have you tried this? Count(field) counts the number of records that match a query, which is probably not what you wanted.

<cfquery name="get_general_stats" datasource="#dsn#">
        SELECT *
        FROM stats_daily
        ????
         WHERE month of the date =  '#form.date#'
</cfquery>

That should populate the required fields and get you going.
0
 

Author Comment

by:brihol44
ID: 20291270
Nice! Thank you, I got it! However how would I loop over all the daily values in bar chart? So if I selected the month of October 2007 I would get all 31 days for the month with a bar value representing each day.

I get the value and the bar chart with the correct value with adding the two variables below. I just need some hints to figure out out to display all the days for each month/year selected.



<cfset month = "11">
	<cfset day = "08">
 
	<cfquery name="get_visits" datasource="#dsn#">
	  SELECT *
	  FROM stats_daily
	  WHERE EXTRACT(MONTH FROM date) = '#month#' AND
	  EXTRACT(DAY FROM date) = '#day#' 
	</cfquery>
 
    <CFCHART
		 backgroundcolor="F2ECEC"
  		 CHARTWIDTH="950"
  		 CHARTHEIGHT="180"
         ROTATED="no"
  		 showlegend="yes"
 		 showmarkers="yes"
		 SHOW3D="yes"
         XOFFSET=".01"
         YOFFSET=".02"
  		 FONTSIZE="10"
         FONTBOLD="Yes"
  		 DATABACKGROUNDCOLOR="DDDDDD"
		 SCALETO="100"
         GRIDLINES="5"
         SHOWXGRIDLINES="no"
         SHOWYGRIDLINES="yes"> 
		
		<CFCHARTSERIES 
    	 TYPE="bar" 
         QUERY="get_visits"
    	 ITEMCOLUMN="Visits"
    	 VALUECOLUMN="visits"
    	 SERIESLABEL="Visits"
    	 SERIESCOLOR="F94A4A">
		 
		</cfchart>

Open in new window

0
 
LVL 3

Expert Comment

by:bayesianmind
ID: 20292005
Isn't that what the first code you posted does? Or are you looking to have multiple months selectable and displayed?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create a Select Query and Populate a Table 3 51
configure dependency in POM for new database 3 34
REGEX HELP 11 48
ColdFusion 9 CF Administrator and Request Filtering 3 26
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question