2

I am developing a web app using AngularJS and FusionCharts

I want to display a graph that is based on monthly sales which I have done built by using this query

SELECT DATE_FORMAT(sales_time, '%b') AS Month, SUM(grand_total) 
                               FROM pos_sales 
                               GROUP BY DATE_FORMAT(sales_time, '%b') 
                               ORDER BY sales_time ASC

Query above will give a result like this

Month | Grand_total
Apr     250.000
May     150.000

I want to use this populated months to be used as a data to generate a daily report based on the month populated.

The question is how can I populate data based on the month clicked? I have tried to use this query

SELECT sales_time, grand_total FROM pos_sales WHERE MONTH(sales_time)

the query above populate daily data but not in monthly order. What I want it to be is like kind of

Month | Item | Total
May     Item1  250.000
May     Item2  150.000

I can create the graph by hardcoded it but it is not what I want. I want it to be a dynamic graph based on my database.

Alvin
  • 529
  • 1
  • 8
  • 19

1 Answers1

0

Firstly, If you need to get data for daily report You will have to query it like this

SELECT sales_time, grand_total FROM pos_sales WHERE MONTH(sales_time) ORDER BY **Date**

This should solve your issue of getting data on selected month in order.

Nextly, to make use of the fetched result set in Fusion charts. You should be writing a parser between the SQL Querying and Rendering Chart. This parser should parses your data by every row and create an .xml / .json file (whichever is convenient for you) and use this created file to render your chart.

I feel this as one of the suggested way.

Princess
  • 36
  • 2