Firstly, thanks to both @numtel and @dandv for putting me onto your respective entries / news on Github.
I’ll try to explain this the best I can, being a newbie
I have a Mysql database that I need to report on, and Webix looks really good for what I need.
However, using @numtel (Ben’s) mysql package, I had to do this to set the data: parameter of the webix piechart:
ubr = collection of the users_by_region table, set by:
ubr = new MysqlSubscription(“ubr”);
which is:
Meteor.publish('ubr', function(){
return liveDb.select(
"SELECT * from users_by_region order by the_count desc limit 0,5",
[ { table: 'users_by_region' } ]
);
});
And then I have this in Meteor.dashboard.onRendered
ubr.depend();
ubrJson = "";
ubr.forEach( function( item ) {
// console.log(JSON.stringify(item));
if ( ubrJson.length > 0) {
ubrJson += ',';
}
ubrJson += JSON.stringify(item);
});
ubrJson = "[" + ubrJson + "]";
console.log(ubrJson);
And the ubrJson variable seems to work ok when I do:
var piechart = {
view: 'chart',
type: 'pie',
value: '#the_count#',
label: '#region_code#',
// data: [{region_code:"KZ",the_count:10},{region_code:"RU",the_count:5}],
data: ubrJson
}
And then, I use the piechart object here:
webixContainer = webix.ui({
container: 'webix-container',
view: 'layout',
rows: [
{
cols: [ piechart ]
}
]
});
And this works - sometimes…
If I set the data: to the ubrJson object, my pie chart is blank, most of the time.
Sometimes it works, but not all the time.
If I set the data: to the string:
[{region_code:“KZ”,the_count:10},{region_code:“RU”,the_count:5}]
the webix chart component renders every time.
@numtel - is it possible to update your mysql package to return the same result set as a normal MongoDB collection? One of the params to the Webix piechart is this:
url: webix.proxy(‘meteor’,ubr)
which takes a normal Meteor MongoDB collection (in my case, the “ubr” collection)
I’ve not yet tried to replicate this with a MongoDB collection, but I will do that tomorrow and reply back here with my findings.
Sorry if this seems an odd post, but I’m at a loss as to how to get this working, every single time. I see the chart sometimes (< oh, 5%).
And while I can do:
{{#each ubr}}
<span>{{region_code}} - {{the_count}}</span></br>
{{/each}}
in my template (which shows me that the ubr collection is definitely filled with data) why does the ubr collection, when I want to reference it to populate the Webix piechart, have nothing in it?
My apologies to the community for singling out one (or two) developers, but I would really like to get this resolved.
Thanks, and apologies in advance for my newbie-ness.