jhuenges / highcharts-demo

Examples for the Meteor-Highcharts package by MaazAli
21 stars 6 forks source link

get data from mongodb #4

Open aligos opened 8 years ago

aligos commented 8 years ago

please help, i want to create charts with package meteor add maazalik:highcharts, using columnDemo https://github.com/jhuenges/highcharts-demo/blob/master/client/demos/columnDemo.js but i did'nt know how to get data from databes to this charts, i am using meteor example todos. https://github.com/aligos/pomodoro/blob/master/client/templates/chart.js

jhuenges commented 8 years ago

I updated the code https://gist.github.com/jhuenges/814b60d80c96db014e045f2207fc1814 Can you tell me what the console.log in line 89 says?

VeilleurTrytoFix commented 8 years ago

doingwrong

jhuenges commented 8 years ago

You need to change Template.template.onRendered

VeilleurTrytoFix commented 8 years ago

sorry I do not have pay attention to this detail

doingwrong

doingwrong

jhuenges commented 8 years ago

I ll take a look at it in a couple of hours.

jhuenges commented 8 years ago

This should (hopefully) work now: https://gist.github.com/jhuenges/814b60d80c96db014e045f2207fc1814 (rename the template names ;) )

VeilleurTrytoFix commented 8 years ago

I do not know what to say, this does not seem works :$

doingwrong

VeilleurTrytoFix commented 8 years ago

ok, changed div id my bad return to me "no data to display"

doingwrong

jhuenges commented 8 years ago

Is there data in the collection? Add console.log(buyhistoryMin, buyhistoryMax, sellhistoryMin, sellhistoryMax) here and tell me what is in the array

VeilleurTrytoFix commented 8 years ago

array return is good, and collection is not empty

doingwrong

jhuenges commented 8 years ago

Okay, found the problem. For some reason you store the values of min, max, avg and so on as an array of strings and here. That is why the code doesnt work. I would suggest to change the server code because storing simple numbers should be much easier and makes a lot more sense. You would need something like

var typebuymax = parseFloat(typebuy[0].max[0]);
...
VeilleurTrytoFix commented 8 years ago

I changed as you have advised me (I emptied the previous entry), I have no data to display again doingwrong

jhuenges commented 8 years ago

Hm, that NaN shouldnt be there. Is this in every array?

jhuenges commented 8 years ago

Okay ... :D Change

new Date(obj.date).getTime()

to

new Date(obj.createdAt).getTime()

here and here

VeilleurTrytoFix commented 8 years ago

thanks so much it works ! :) I will study your code to understand the proceedings, really nice thanks again :)

You know the difference between " meteor add maazalik:highcharts" and "meteor add highcharts:highcharts-meteor" ?