This topic is locked

Trying to build a line chart like this

10/9/2010 9:21:27 PM
PHPRunner General questions
M
mcdonald36 author

Hi, I'm trying to build a line chart.

I have a database for my school and within this DB I have a table of students language skills such as Grammar, listening etc.

The data in the Skills table looks like this:

Report Date: Student: Skill: Score:

2010/08/5 Hiroshi Grammar 33

2010/08/5 Hiroshi Speaking 40

2010/08/5 Hiroshi Listening 58

2010/08/5 Hiroshi Vocabulary 62

2010/08/12 Hiroshi Grammar 35

2010/08/12 Hiroshi Speaking 41

2010/08/12 Hiroshi Listening 56

2010/08/12 Hiroshi Vocabulary 60

2010/09/09 Hiroshi Grammar 40

2010/09/09 Hiroshi Speaking 45

2010/09/09 Hiroshi Listening 67

2010/09/09 Hiroshi Vocabulary 61

2010/09/23 Hiroshi Grammar 42

2010/09/23 Hiroshi Speaking 46

2010/09/23 Hiroshi Listening 66

2010/09/23 Hiroshi Vocabulary 67


The table is called: Skills
And the mysql looks like this:

SELECT Student,

ReportDate,

TeachersNotes,

ID,

Skill,

Grade

FROM Skills


Then I created a line chart with the sql like this:

select

Skill,

month(ReportDate) AS m,

SUM(Grade),

Student

FROM Skills

GROUP BY Skill, month(ReportDate)

ORDER BY Skill, month(ReportDate)


But only one line can be shown but I need as many lines as there are Skills so If I have 4 skills representing: Grammar, Listening, Speaking, Vocabulary etc then all lines will be shown. How can this be done??
The purpose of doing this is to allow the teacher to simply input student's scores for each of their language skills after each lesson taken by student and have the data automatically populate the chart grouped by Student and grouped by month showing the student how each skill is gradually progressing month after month.
Some times the teacher is adding scores for the same skills type more than ones per month but I just need the totals for each skill for each month per student.
When I select the Data Series I am selecting just one which is 'SUM(Grade)' then when I select Label field I select 'm'
Also I need to have the chart show a different description when user mouse over's the chart line rather than: 'SUM(Grade)'

Thanks and look forward to learning how to do this.
MC

Sergey Kornilov admin 10/10/2010

You can try using subqueries. I don't have a working example here, just an idea.

select

Skill,

month(ReportDate) AS m,

(select SUM(Grade) from skills where skill='Grammar' group by Skill, month(ReportDate)) as sGrammar,

(select SUM(Grade) from skills where skill='Speaking' group by Skill, month(ReportDate)) as sSpeaking,

...

Student

FROM Skills

GROUP BY Skill, month(ReportDate)

ORDER BY Skill, month(ReportDate)


Again, this not a proper syntax, just an idea of what you can experiment with.

M
mcdonald36 author 10/10/2010

That's great! Thanks! It seems to work although I can't see the flash chart in my firefox browser because I'm having problems installing the flash plugin on firefox but your code has taught me new ideas thanks!!
> this not a proper syntax, just an idea of what you can experiment with



I just had to change the table name of skills to Skills to upper case 'S' to work with my project:

select

Skill,

month(ReportDate) AS m,

(select SUM(Grade) from Skills where skill='Grammar' group by Skill, month(ReportDate)) as sGrammar,

(select SUM(Grade) from Skills where skill='Speaking' group by Skill, month(ReportDate)) as sSpeaking,

Student

FROM Skills

GROUP BY Skill, month(ReportDate)

ORDER BY Skill, month(ReportDate)
M
mcdonald36 author 10/10/2010

Just got these errors but can't fix them. Sorry

  1. When I'm in the Query editor it all works fine browsing from one tab to the next but when I click on Results from within the Query tab I get this error:


2. I get another error when viewing the flash chart on the web page like this:


Sorry I don't know how to fix them or what they mean.
MC

Sergey Kornilov admin 10/11/2010

This error means your SQL Query is incorrect. My suggestion is to test this SQL Query outside of PHPRunner i.e. using Navicat or phpMyAdmin. Once you have it running paste this query to PHPRunner SQL Query screen and build your project.

J
Jane 10/13/2010

Hi,
this error means that query is no correct.

You can test it manually and correct it in any MySQL administrative tool and then use this query in PHPRunner.