I am building an application for a coffee shop where their products will organized on categories and some of them in sub-categories.
We consider these two options but I do not really know if there are good alternatives.
Option 1 - Category and subcategory collection
This one looks like a good solution, but we still want to be sure if there are no better options. Also with this alternative we are locked with only two levels (collection and subcollection) that is something ok for now (unless requirements change).
How to store category and subcategory in flutter Firestore
Option 2 - Big map structure
One solution was to create a big map structure, this one has the benefit to allow more subcollections, take for example this:
{
"drinks_" (category): [
{
"category" (sub-category): "Frappes",
"drinks": [
{
"Moka": {
"extraSugar": false,
"extras": false,
"whipped_cream": true
},
"Vainilla": {
"extraSugar": false,
"extras": false,
"whipped_cream": true
},
"Oreo": {
"extraSugar": false,
"extras": false,
"whipped_cream": true
}
}
]
},
{
"category" (sub-category): "Hot",
"drinks": [
{
"Americano": {
"extraSugar": true,
"extras": true,
"whipped_cream": false
},
"Cappucino": {
"extraSugar": true,
"extras": true,
"whipped_cream": false
},
"Latte": {
"extraSugar": true,
"extras": true,
"whipped_cream": false
}
}
]
},
]
}
I am new with firestore so I do not know how easy will be to work with a big map structure like seen on solution #2.
I will appreciate any feedback on these two solutions or any other ideas.
Related
I'm using vis.js to display nodes, not all nodes are connected to each other, but they are overlapping as shown in the picture, is there a way with the option to avoid this, I went through the configure options but could not find.
There is an attribute avoidOverlap=[0,1] in some physics like BarnesHut
http://visjs.org/docs/network/physics.html?#
You can try it here at the bottom under physics http://visjs.org/examples/network/other/configuration.html
like adding this attribute into your physics option
var options = {
... "physics": {
"barnesHut": {
"avoidOverlap": 1
},
}
}
I managed to get it working by using the configure option:
configure: {
enabled: true,
showButton: true
}
This shows you a modal to configure all the options until the graph looks nice.
In my case with hierarchical view, I had to disable physics and set the layout like this:
layout: {
hierarchical: {
enabled: true,
nodeSpacing: 425,
blockShifting: false,
edgeMinimization: false,
sortMethod: "directed"
}
}
I would recommend using manual configuration for physics and layout:
configure: {
enabled: true,
filter: 'physics, layout',
showButton: true
}
and try to play with
nodeDistance and nodeSpacing.
I tried a lot of options on this and figured out that it actually it depends on the physics configuration:
if your physics configuration is like this
physics: false, then you can use just this
layout: {
hierarchical: {
levelSeparation: 150,
treeSpacing: 200,
blockShifting: true,
edgeMinimization: true,
parentCentralization: true,
direction: 'UD',
nodeSpacing: 300,
sortMethod: "directed" //directed,hubsize
}
},
Where nodeSpacing is the key for you and sord method will define the structure for you
This make up a network like this:
otherwise use manual configuration:
configure: {
enabled: true,
filter: 'physics, layout',
showButton: true
}
I want to display only 4 columns, but when I bind the grdOptions.Data=entity,
then all fields in entity are converted into a column. Can we prevent it from autogenerating all the columns?
As per the first page of documentation:
... if you wanted to configure the core ui-grid, you might choose to set some options and columns on your grid (the documentation for these is found in gridOptions and columnDef.
And here's the first example:
$scope.gridOptions = {
enableSorting: true,
columnDefs: [
{ name: 'field1', enableSorting: false },
{ name: 'field2' },
{ name: 'field3', visible: false }
]
};
Okay so I'm new to meteor and have a somewhat complex data structure setup.
Assuming I'm forced to keep the structure what do my templates need to look like in order to display this? Am I doing something wrong? I can't seem to get my current code to work. Any help or advice is greatly appreciated! -Thanks
Here's my data structure:
Tournament: {
round1:{
match1:[
{ToqeLokbLAs9mALd3: {win: true, gamertag: 'gbachik'}},
{scH8Zb3XMa5ALZNsL: {win: false, gamertag: 'test'}}
],
match2:[
{c4LQoXGEo6dA8ZtNT: {win: false, gamertag: 'test2'}},
{TDrZa3QY3AinxXw5D: {win: true, gamertag: 'test3'}}
]
},
round2:{
match3: [
{ToqeLokbLAs9mALd3: {win: true, gamertag: 'gbachik'}},
{TDrZa3QY3AinxXw5D: {win: false, gamertag: 'test3'}}
]
},
consolation:{
match1: [
{scH8Zb3XMa5ALZNsL: {win: null, gamertag: 'test'}},
{c4LQoXGEo6dA8ZtNT: {win: null, gamertag: 'test2'}}
]
}
}
My Helper:
Template.index.helpers({
round: function(){
return Tournaments.findOne({});
}
});
my Route:
Router.route('/', function() {
this.subscribe('tournaments').wait();
this.render('index');
});
my static view(jade):
.tournament
ul.round1.of3
li
.participant.winner
a(href='#')
span.participant-title= this
span.participant-number 2
.participant
a(href='#')
span.participant-title asdasd loser
span.participant-number 3
Look into the {{#each}} {{/each}} spacebars. It should get you at least outputting a list. http://meteorcapture.com/spacebars/.
Just a suggestion for how to format your object, make it much more general. Rather than naming it round1 and round2 make a general object that is round and then have a name or number parameter inside the object. If you care about order, consider using a list as the container.
I am trying to build an array of data returned from a third party API, and display it using the Highcharts map module.
I've done so with the charts module, using line and pie charts both with not much difficulty. Now that I've moved onto maps, I seem to be running into a bit of difficulty. It was quite clear from the examples provided how the data should be structured to be properly read by Highcharts.
When it comes to the maps module, the data structure is not clear at all. How would I structure my data to pass into my Highcharts map???
[ 'US' , 'United States' , 32 ] , [ 'CA' , 'Canada' , 100 ]
If I use the provided :
jQuery.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=world-population-density.json&callback=?', function (data) {
console.log(data);
// Initiate the chart
jQuery('#geo_map').highcharts('Map', {
title : {
text : 'Campaign Link Clicks Around The World'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 1,
max: 1000,
type: 'logarithmic'
},
series : [{
data : data,
mapData: Highcharts.maps['custom/world'],
joinBy: ['iso-a2', 'code'],
name: 'Population density',
states: {
hover: {
color: '#BADA55'
}
},
tooltip: {
valueSuffix: '/kmĀ²'
},
}],
credits: {
enabled: false
},
});
});
});
It works. But I can't seem to figure out how to pass in my data. I thought it was as simple as
[ 'Abbreviation' , 'Name' , Value ] , [ 'Abbreviation' , 'Name' , Value ]
but clearly not. The documentation isn't very clear on data structure.
Thanks.
Anyone know how to attach a renderer to a grid grouping header in ExtJS4? In ExtJS3 I have the following working code, which returns 'Past' if an event has been completed ('Y'), or 'Upcoming' if not completed:
function fmt_group_heading(groupVal) {
if (groupVal === 'Y') {
return 'Past';
} else {
return 'Upcoming';
}
}
// create the Grid
var fitGrid = new Ext.grid.GridPanel({
store: fitGroupingStore,
columns: [
{header: "ID", dataIndex: 'id', hidden: true },
{header: 'Event', width:320, dataIndex: 'event',
renderer:fmt_event_description},
{header: 'Events', dataIndex: 'completed', hidden: true,
renderer: fmt_group_heading }
],
stripeRows: true,
// config options for stateful behavior
stateful: true,
stateId: 'grid',
hideHeaders: true,
view: new Ext.grid.GroupingView({
groupRenderer: 'completed',
forceFit: true
})
});
ExtJS4 provides grid grouping but I'm not understanding how to change the output of the group text. The 'groupHeaderTpl' attribute of Ext.grid.feature.Grouping seems to only take the raw field value as read from the store.
this.groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
groupHeaderTpl: 'Group: {completed}'
});
// create the Grid
this.fitnessGrid = new Ext.grid.Panel({
store: this.fitnessEventStore,
features: [this.groupingFeature],
// etc.......
try smth like this:
groupHeaderTpl:
'{[fmt_group_heading(values.name)]}
({rows.length}
Item{[values.rows.length > 1 ? "s" :
""]})'
The groupHeaderTpl requires you to use {name} when composing the template. It will only use the value provided by the groupField.
See the Docs.
Try this:
groupHeaderTpl: '{[values.rows[0].completed]}'