How to change direction of existing link in zoomcharts - hyperlink

I'm trying to do it like this
function btnChangeDirClick(){
var fromNode = document.getElementById("linkMenuLinkFrom").value;
var toNode = document.getElementById("linkMenuLinkTo").value;
chart.addData({
links:[{id:document.getElementById("linkMenuLinkid").value,
from:toNode,
to:fromNode
}]
});
}
but my console returns
Changing link from,to not supported
Of course it's possible to delete and recreate, but are there any alternatives?

One alternative is to store a direction flag in data and assign from and to decorations depending on it.
I suggest using delete/recreate for now. Link reconnection support will come.

Finally I ended up implementing is as follows, which works fine:
function btnChangeDirClick(){
var fromNode = document.getElementById("linkMenuLinkFrom").value;
var toNode = document.getElementById("linkMenuLinkTo").value;
chart.removeData({links:[{id:document.getElementById("linkMenuLinkid").value}]});
chart.addData({
links:[{
"id":document.getElementById("linkMenuLinkid").value,
from:toNode,
to:fromNode,
"style":{label:document.getElementById("linkMenuLinklabel").value}
}]
});
nextId += 1;
document.getElementById("linkMenuLinkFrom").value = toNode;
document.getElementById("linkMenuLinkTo").value = fromNode;
}

Related

java Stream how to compare two List then add main object

List = [{fileName:'11',idx:1}]....
List = [{fileName:'11',uplod_idx:''}]....
listss.stream()
.forEach(x->{
b.stream().filter(y->y.getFilename().equals(x.getFilename()))
.map(y->{
y.uplod_idx(x.getIdx());
return y;
});
});
how to fix compare anymatch or someting
I mean. How to change smart then me.

how to disable multi-column sort in ui-grid

I have a client who specifically does not like the numbers next in the headers of the columns when doing a sort. This is rooted in UI-Grid's multi-sort, which gives each column a numbered priority. Is there a way to disable the multi-sort in order to remove those numbers? I still want to keep sorting activated, but only on one column at a time.
Thanks.
I've had this problem myself. If you look carefully in the ui0grid.js code you'll see that there is (at this time) no option to diable it. The writers of ui-grid state that they would welcome a request for such a function in this thread
However, you want a fix, not a promise ;-)
You can spot how many sortColumns have been chosen in the sortChanged method.
Try something like this:
$scope.gridOptions.onRegisterApi = function(gridApi) {
$scope.gridApi = gridApi;
// Register a handler that is fired everytime someone changd the sort params.
$scope.gridApi.core.on.sortChanged($scope, function(grid, sortColumns) {
if (sortColumns.length > 1) {
// We have more than one sort. Kill the first one.
// If this works we'll only ever have 0, 1 or 2 sortColumns,
// and only ever 2 for the lifetime of this method.
var column = null;
for (var j = 0; j < grid.columns.length; j++) {
if (grid.columns[j].name === sortColumns[0].field) {
column = grid.columns[j];
break;
}
}
if (column) {
sortColumns[1].sort.priority = 1; // have to do this otherwise the priority keeps going up.
column.unsort();
}
}
});
};
This is against the 3.0.0 release of ui-grid.
HTH
To prevent sorting on multiple columns, I added these two lines in the Grid.prototype.sortColumn function, ui-grid.js file.
self.resetColumnSorting(column);
column.sort.priority = undefined;
works for me..
I wanted to limit multiple sort columns to a maximum of 2. This is how I did it.
$scope.gridOptions.onRegisterApi = function(gridApi) {
$scope.gridApi = gridApi;
$scope.gridApi.core.on.sortChanged($scope, function(grid, sortColumns) {
if (sortColumns.length == 3) {
//limit multi column sort to max 2 columns
for (var j = 0; j < grid.columns.length; j++) {
if (grid.columns[j].name === sortColumns[2].name) {
grid.columns[j].sort = {};
break;
}
}
return;
});
};
Looks like this is supported now in the HTML element:
[suppressMultiSort]="true"
This in the latest version. No need for tough scripts.

How do I configure the options in Highcharts to allow multiple drilldowns asynchronously?

I'm trying to convert the following options in Highcharts to multiple series with multiple drilldowns. The problem is that I've changed the loop to progress over the points so as to add both drilldown series. However, in the loop I've written, it seems to be the case that after one go through the loop, the points array is overwritten with nulls, which makes the whole thing irrelevant.
I'm a beginner with the options, and after having spent quite a bit of time on it I can't crack it. An explanation and a solution would be an ideal answer to the question: "How do I do the following with multiple drilldowns?" It's all asynchronous requests on datasets.
I'm starting with
options.chart = options.chart || {};
options.chart.events = options.chart.events || {};
var dd = options.chart.events.drilldown || function(e) {};
options.chart.events.drilldown = function(e) {
var chart = this;
chart._drilldowns = chart._drilldowns || {};
var series = chart._drilldowns[e.point.drilldown];
if (series) {
e.seriesOptions = series;
chart.addSeriesAsDrilldown(e.point, series);
dd(e);
}
if (!e.seriesOptions) {
chart.showLoading('Fetching data...');
$.getJSON(
'%(url)s?' + analytics.get_form_data(),
function(drilldowns) {
chart.hideLoading();
chart._drilldowns = drilldowns;
var series = drilldowns[e.point.drilldown];
chart.addSeriesAsDrilldown(e.point, series);
e.seriesOptions = series;
dd(e);
}
);
}
};
''' % {'url': self.get_drilldown_url()}
and I've tried to change the second part to:
...
function(drilldowns) {
chart.hideLoading();
chart._drilldowns = drilldowns;
e.points.forEach(function(value, key){
var series = drilldowns[value.drilldown];
chart.addSeriesAsDrilldown(value, series);
})
e.seriesOptions = series;
dd(e);
}
);
}
};
But I don't get both my series drilling down. I actually get a Property xAxis of null is not allowed error, as when I go through the loop the second time, the set of points has been changed to null.
UPDATE
We eventually fixed (actually a collegue did!) using promises. We engineered it to wait until the first async request for data was retrieved, and then called addSingleSeriesAsDrilldown on each one until we hit the last one (derived off the chart state) at which point we called addSeriesAsDrilldown which does the applyDrilldown as part of the code.
It's not the part of official API, but this way you can get multiple drilldowns: http://jsfiddle.net/p2xw9416/
In the lowest level of AJAX requests (if you have multiple of them), add each series as single object:
chart.hideLoading();
chart.addSingleSeriesAsDrilldown(e.point, series_1);
chart.addSingleSeriesAsDrilldown(e.point, series_2);
chart.applyDrilldown(); // update && animate

Doc Shell Swapping Example

I'm trying to write a simple example to show docshell swapping from one iframe to another.
I wrote this, can run from scratchpad with environment browser:
var doc = gBrowser.contentDocument;
var iframeA = doc.createElement('iframe');
iframeA.setAttribute('id', 'a');
iframeA.setAttribute('src', 'http://www.bing.com');
doc.documentElement.appendChild(iframeA);
var iframeB = doc.createElement('iframe');
iframeB.setAttribute('id', 'b');
iframeB.setAttribute('src', 'data:text/html,swap to here');
doc.documentElement.appendChild(iframeB);
doc.defaultView.setTimeout(function() {
var srcFrame = iframeA;
var targetFrame = iframeB;
doc.defaultView.alert('will swap now');
srcFrame.QueryInterface(Ci.nsIFrameLoaderOwner).swapFrameLoaders(targetFrame)
doc.defaultView.alert('swap done');
}, 5000)
However this throws this error when it tries to swap:
/*
TypeError: Argument 1 of HTMLIFrameElement.swapFrameLoaders does not implement interface XULElement. Scratchpad/1:17
*/
Any ideas on how to fix?
Thanks
Thanks to #mook and #mossop from irc #extdev for the help.
The reason it didnt work was because:
pretty sure it needs to be a
Looks like gBrowser.contentDocument might be a html page? You must be using XUL elements
No idea if it even works in content either - I think it doesn't
and the things to be swapped must either both be type=content or neither can be, or something like that (translation: the type attribute of both source and target must be the same. so if one is content-primary the other must be content-primary as well)
This works:
var doc = document; //gBrowser.contentDocument;
var iframeA = doc.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'browser');
iframeA.setAttribute('id', 'a');
iframeA.setAttribute('src', 'http://www.bing.com');
iframeA.setAttribute('style', 'height:100px;');
doc.documentElement.appendChild(iframeA);
var iframeB = doc.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'browser');
iframeB.setAttribute('id', 'b');
iframeB.setAttribute('src', 'data:text/html,swap to here');
iframeB.setAttribute('style', 'height:100px;');
doc.documentElement.appendChild(iframeB);
doc.defaultView.setTimeout(function() {
var srcFrame = iframeA;
var targetFrame = iframeB;
doc.defaultView.alert('will swap now');
srcFrame.QueryInterface(Ci.nsIFrameLoaderOwner).swapFrameLoaders(targetFrame)
doc.defaultView.alert('swap done');
}, 5000)
so in other words even if you made iframe with xul namespace it would not swap if you put it in an html document. like this example here:
var xulDoc = document;
var doc = gBrowser.contentDocument;
var iframeA = xulDoc.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'iframe');
iframeA.setAttribute('id', 'a');
iframeA.setAttribute('src', 'http://www.bing.com');
iframeA.setAttribute('type', 'content');
iframeA.setAttribute('style', 'height:100px;width:100px;');
doc.documentElement.appendChild(iframeA);
var iframeB = xulDoc.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'iframe');
iframeB.setAttribute('id', 'b');
iframeB.setAttribute('src', 'data:text/html,swap to here');
iframeB.setAttribute('type', 'content');
iframeB.setAttribute('style', 'height:100px;width:100px;');
doc.documentElement.appendChild(iframeB);
doc.defaultView.setTimeout(function() {
var srcFrame = iframeA;
var targetFrame = iframeB;
doc.defaultView.alert('will swap now');
srcFrame.QueryInterface(Ci.nsIFrameLoaderOwner).swapFrameLoaders(targetFrame)
doc.defaultView.alert('swap done');
}, 5000)
It throws:
NS_ERROR_NOT_IMPLEMENTED: Scratchpad/2:21
this line is the swapFrameLoaders line
so its recommended to not use iframe with xul namespace as if you do you wont get the DOMContentLoaded and some other events http://forums.mozillazine.org/viewtopic.php?f=19&t=2809781&hilit=iframe+html+namespace
so its recommended to use element

ActionScript Haxe Evaluate a referenced variable inside a loop in a closure

I've been programming some stuff in ActionScript (Haxe) and arrived this very specific problem.
Here's the code (pseudo :S):
var func:Array = new Array(256);
(A) var i:Int = 0;
for(;i<256;i++) { // OR // for(i in 0...256) {
func[i] = function() { trace(i); }
}
func[0]();
func[127]();
func[256]();
The above code outputs (a):
256
256
256
I want that to be (b):
0
127
256
That doesn't happen, because ActionScript/Haxe is assigning the reference of i to the function, and since i equals 256 at the end of the loop where the functions get evaluated, that's why I get (a).
Does anyone know of a way to avoid that and get the expected results at (b) ?
Thanks to all of you guys and your responses.
I think I've found the answer. If you remove the line marked with (A) it works, if you leave it it doesn't. I'm pretty sure you could all figure out why that happens. Thanks again!
it's not neccessary to use callback, this should work as expected (haxe creates a local var in each loop):
var func = [];
for(i in 0...256)
func[i] = function() trace(i);
func[0]();
func[127]();
The one you show is the expected/desired behavior. To retain the value of "i" you must use "callback":
/* not pseudo code ;) */
var func = [];
for(i in 0...256)
func[i] = callback(function(v) trace(v), i);
func[0]();
func[127]();
func[256]();

Resources