mardi 17 février 2015

How to split data (using php) into multiple series so it can be shown in highchart?


Vote count:

0





Storeid Date myValue
1 2015-01-01 100
1 2015-01-02 110
1 2015-01-03 140
1 2015-01-04 110
1 2015-01-05 130
2 2015-01-01 100
2 2015-01-02 110
2 2015-01-03 140
2 2015-01-04 110
2 2015-01-05 130


Hi guys


I have a small dataset that I'm not sure how to split so it can be displayed in highchart.


In this case the data looks like the table I provided. I'll use php for database connection and getting the data. The xAxis category will be the Date, and the series needs to be split by Storeid. That way the stores can be compared against each other. So on the site I just select a daterange and a list of storeid.


Solution 1 Using for loop through all the storeid and fetch each series individually. It works but seem like a really bad way to do it.


Solution 2 Fetch entire dataset as multi dimensional array, split it into equal parts using array_chunk() based on number of dates. Doesn't feel very robust.


So is there anyway I can split the dataset based on storeid in a more robust and efficient way? Sorry for such a weirdly defined problem, not sure if it should be solved within highchart, php or in the mysql database.



asked 31 secs ago







How to split data (using php) into multiple series so it can be shown in highchart?

Aucun commentaire:

Enregistrer un commentaire