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
}
Related
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.
I'm using mathjax in a project and I've been trying to change the colors of all math. I am loading the following configuration file:
window.MathJax = {
jax: ['input/TeX', 'output/HTML-CSS'],
extensions: ['tex2jax.js'],
displayAlign: 'center',
TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'AMScd.js'],
Macros: {
e: '{\\textrm{e}}',
R: '{\\mathbb{R}}', // this is working!
Z: '{\\mathbb Z}',
KK: '{\\mathbb{K}}'
}
},
tex2jax: {
inlineMath: [
['$', '$'],
['\\(', '\\)']
],
displayMath: [
['$$', '$$'],
['\\[', '\\]']
],
processEscapes: true
},
'HTML-CSS': {
fonts: ['TeX'],
styles: {
scale: 110,
'.MathJax': { padding: '1em 0.1em', color: 'green ! important' }, //Not working
'.MathJax_Display': { 'text-align': 'center' }
}
},
showProcessingMessages: false,
menuSettings: { zoom: 'Double-Click', mpContext: true, mpMouse: true }
}
Everything is apparently working but the HTML-CCS:styles part is not working. I couldn't find a proper reference for this, and I don't know if this version of MathJax (2.7.8) is using a different format.
In this project I'm using nuxt and vuetify, I don't know if this is the problem, but I turn off vuetify and still the styles are not applied to the math display.
Thanks very much for any help,
Milton.
The scale: 110 parameter is not a CSS declaration, so should not be in the styles block (but rather in the HTML-CSS block directly). I suspect that that may be causing the styles not to be generated properly. Try moving the scale up one level and see if that helps.
Note that the HTML-CSS output jax is the slowest one available. You might consider switching to the CommonHTML output jax instead.
I finally found what was the problem. Apparently the new versions of Mathjax changed the name of the CSS classes. The following configuration now works:
Update: Now I'm facing a different problem...that configuration only works in developing mode, when deploy the mathjax css is not working...in that case I think it is the vuetify css. :-(
Update: Now it is working, also in deployed mode. I was loading Mathjax with a the pre-configuration ?config=TeX-AMS-MML_SVG. When I load it without that pre-configuration it works. I don't know why.
window.MathJax = {
jax: ['input/TeX', 'output/CommonHTML'],
extensions: ['tex2jax.js', 'Safe.js'],
styles: {
'.mjx-chtml': { padding: '0.1em 0.1em' }, //new names of the selectors, working!
'.MJXc-display, .mjx-chtml': { color: 'green' }
},
displayAlign: 'center',
TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'AMScd.js'],
Macros: {
e: '{\\textrm{e}}',
R: '{\\mathbb{R}}',
Z: '{\\mathbb Z}',
KK: '{\\mathbb{K}}'
}
},
tex2jax: {
inlineMath: [
['$', '$'],
['\\(', '\\)']
],
displayMath: [
['$$', '$$'],
['\\[', '\\]']
],
processEscapes: true
},
CommonHTML: {
scale: 105,
linebreaks: { automatic: true }
},
showProcessingMessages: false,
menuSettings: { zoom: 'None', mpContext: true, mpMouse: true }
}
Note that styles are in the core configurations, outside the CommonHTML item.
Thanks for the help!
Milton.
There are multiple CSS formatters out there that will make this:
.classname {
style: value;
style: value;
}
.classname {
style: value;
}
and turn it into this:
.classname { style: value; style: value; }
.classname { style: value; }
The problem is my personal preference doesn't fall in line with a lot of other people's preferences. That's fine because I'm not a common use-case so I don't expect there to be anything. I would like to take the first example, and turn it into this:
.classname {
style: value;
style: value;
}
.classname { style: value; }
Where all classes with multiple styles are on their own lines, but each class with just a single style is compact.
I can settle for some regex I can search in Sublime Text 2 that will let me find each instance of single style classes like that and just edit after the find to be what I want. That's perfectly fine with me and would help when I inherit large stylesheets. As you can probably imagine, I don't normally do it by hand for these large sheets and just have to live with it. I'd prefer to have a simple solution like searching a regex or something in the absence of a plugin.
The basic transform can be done with RegEx replacements. I'd do it this way:
Step 1: \n → NOTHING Remove all newlines
Step 2: [\s\t]{1,} → Change multispace/tab top one space (possibly nice to have)
Step 3: \} → }NEWLINE Break after }
Step 4: \s+(\})|(\{)\s+ → \1\2 Remove single space before & after braces (possibly nice to have)
There is no builtin functionality to create custom keybindings for search and replace, but there's a plugin that is able to do this:
https://github.com/facelessuser/RegReplace
Reg Replace is a plugin for Sublime Text 2 that allows the creating of commands consisting of sequences of find and replace instructions.
A keybinding and RegReplace config might look like this...
RegReplace
{
"replacements": {
"strip_newlines": {
"find": "\\n", "greedy": true, "case": false,
"replace": ""
},
"reduce_multispace": {
"find": "[\\s\\t]{1,}", "greedy": true, "case": false,
"replace": ""
},
"break_after_closecurlybrace": {
"find": "\\}", "greedy": true, "case": false,
"replace": "\\}\n"
},
"strip_space_around_curlybraces": {
"find": "\s+(\})|(\{)\s+", "greedy": true, "case": false,
"replace": "\\1\\2"
}
}
}
Keybindings
{
"caption": "Make my odd formatting",
"command": "reg_replace",
"args": {
"replacements": ["strip_newlines", "reduce_multispace", "break_after_closecurlybrace", "strip_space_around_curlybraces"]
}
}
Both completely untested
I am using a jqGrid that has allot of columns to it.
I added the view option (when clicking on a row and then on the 'view' button, in the bottom left corner of the grid, it opens a model with all the info for that row.
I see that the model has some css style:
overflow-hidden
Therefor if i have allot of columns to show after a certain height that i gave it when creating the grid, they get hidden.
How can i make that dialog box be:
overflow-auto
If possible i want only the inside div to scroll and leave the header of the dialog and the buttons on bottom there all the time.
How can i do this?
myGrid.jqGrid('navGrid', '#pager',
{ edit: false, add: false, del: false, search: false, view: true }, //option
{}, // use default settings for edit
{}, // use default settings for add
{}, // delete instead that del:false we need this
{},
{ height: 250, jqModal: false, closeOnEscape: true} // view options
);
I tried this:
$('#viewmod'+myGridId).css({overflow: 'auto'});
But it didnt work...
You tried the way described here and here.
Found the answer for this.
When declaring the view options add the dataheight option...
{ dataheight: 250, jqModal: false, closeOnEscape: true} // view options
I’m trying to create a Datagrid with editable cells.
As I am using dijits for the editable cells I try to set constraints within the “widgetProps” property of the layout, like this:
widgetProps: {
required: true,
constraints: {
min: 0,
max: 100,
places: '0,2'
}
}
Here required: true works as expected, whereas the constraints property is not working at all.
An example here: http://jsfiddle.net/LjVmJ/ where I've tried to use constraints both in a NumberTextBox and a DateTextBox.
Bug in Dojo or am I missing something?
From Oliver on the dojo mailinglist:
It should be "constraint", and it should be put outside "widgetProps".
Which solves the problem.
I found a ‘dirty’ solution to this issue:
First declare my own NumberTextBox with the required constraints:
dojo.declare(
"my.custom.PercentageNumberTextBox",
[dijit.form.NumberTextBox],
{
postCreate: function(){
this.inherited(arguments);
this.set('constraints', {min:0,max:100, places:'0,2'});
}
});
Then I’m using it as the widgetClass in the grid structure:
{
field: 'employmentPercentage',
name: 'Employment %',
type: dojox.grid.cells._Widget,
widgetProps: { required: true },
widgetClass: my.custom.PercentageNumberTextBox,
editable: true,
width: '150px'
}
This is a workaround for now (full example here: http://jsfiddle.net/LjVmJ/2/),