I'm new to Bokeh, and am trying to create a web-app. I'm having issues where when I run the server, and navigate to the specified web URL, nothing shows beyond a small "link to this" in the upper left hand corner. For reference, I'm using python 2.7, via Anaconda, on Windows7.
I first created a simple example, modeled off of the stock applet. I noticed that in the class Dashboard(VBox), there were, in addition, declarations of extra_generated_classes, and jsmodel. When I omitted these two lines, nothing would show.
I read through some of the bokeh code, but I'm still not quite understanding what the two lines do, and how to set them properly. In my new example, my formatting looks like this
self.children = [self.filterrow, self.lineplot1]
self.filterrow.children = [self.filter_box, self.input_box]
self.filter_box.children = [self.ticker_select, self.date_select]
self.input_box.children = [self.value_select, self.value1_select]
where
lineplot1 = Instance(Plot)
filterrow = Instance(HBox)
ticker_select = Instance(Select)
date_select = Instance(Select)
value = String(default = '')
value1 = String(default = '')
and in my def create(cls)
obj = cls()
obj.filterrow = HBox()
obj.filter_box = VBoxForm()
obj.input_box = VBoxForm()
I've compared my working applet side by side with my non-showing applet, and can't find any significant format differences. Learning by replications, I have
class Dashboard(VBox):
extra_generated_classes = [["Dashboard", "Dashboard", "VBox"]]
jsmodel = "VBox"
in the non-functioning code. Is this correct? How should these two lines be set? Do I need both? Am I missing something? After repeated examination and comparison of the code, I still don't understand why one visualizes properly and the other doesn't.
If this isn't the issue, what is the best way for me to debug the visualization portion of the applet? Any assistance would be greatly appreciated. Thanks!
Related
I am working with an IBM product called Presto. It converts green screens to browser based pages. To do this it does strange things. I am dealing with text fields that randomly popup in different places. I am using the following code for each object to overcome:
document.getElementById("C0816").style.position = "absolute";
document.getElementById("C0816").style.left = "190px";
document.getElementById("C0816").style.top = "216px";
This has worked well until now. I am dealing with a page that will remove objects (text fields) & replace with different objects. This causes an error when it can't find the missing Id.
How can I suppress this error? I have tried several examples on this board but I am new to JavaScript & I am obviously placing it in the code wrong. Any help would be great, thank you.
Just check if the element exists before accessing properties.
const elem = document.getElementById("C0816");
if(elem) {
elem.style.position = 'absolute';
...
}
I'd like to remove my user created label called "Add-to-Spendee-2", from a collection of emails. I've pretty much followed Google's removeLabel() Documentation to the dot on this, but I keep getting an "Invalid argument: label" error.
Here's the code:
function removeLabel()
{
var myLabel = GmailApp.getUserLabelByName('test-add-to-spendee-2');
var threads = GmailApp.search("label:test-add-to-spendee-2 AND from:swiggy AND subject:(Your receipt for Swiggy order)");
for (var x in threads)
{
var thread = threads[x]
thread.removeLabel(myLabel)
}
}
Note: If I substitute the removeLabel(myLabel) with any other function like markUnread(), the code works perfectly.
I think your code will work but I think all you need to do is:
var lbl=GmailApp.getUserLabelByName('Q0/Subject/Name');
var threads=GmailApp.search('label:Q0/Subject/Name');//exactly as you created it
lbl.removeFromThreads(threads);
Try using the debugger and make sure that threads is getting an array of GmailThread objects.
This is what the label look like in the Gmail search window:
They changed the slashes to dashes and used lower case and that's not really what the label looks like.
As I said above in my comment:
I just did that recently and I found that the description of the label in the gmail search window did not agree with how I actually created the label. It displayed a label like this q0-subject-name and I had it created as Q0/Subject/Name when I used q0-subject-name I couldn't find the label and when I used Q0/Subject/Name I found it.
Given this Node-red flow:
I am unfortunately unsure about how I should implement it in function.
I have 3 options in both dropdowns, one displaying meattype the other doneness. Whenever I choose a combination of the dropdowns, I should have the proper temperature given in the text output.
I have tried using If, but I still have problems with getting it to work.
I only have very basic knowledge of Javascript language, so I hope someone could help and at least lead me in the right direction.
Thank you
EDIT:
In the If code in my function node I had "A conditional expression" present, though I got this fixed by changing If from:
if(msg.payload = "")
to
if(msg.payload == "")
This fixed my code and gave me the expected results.
var payload = msg.payload
if(msg.payload == "KalvRoed"){
msg.temperature = "53-57 grader"}
I had "A conditional expression" which means I had to change my code, so that "if" was written with "==" rather than "=". If "if" had been written with "=" the function node would think that I was creating a variable, while I was trying to have it do something if was true.
var payload = msg.payload
if(msg.payload == "KalvRoed"){
msg.temperature = "53-57 grader"}
Hope that makes sense
I am using Eclipse JSDT and the default formatting settings change something like
var a = 1,
b = 2;
to be on one ugly line.
The style before formatting is recommended by JSLint, so I am wondering can Eclipse be set to format it this way? The existing formatter settings does not offer controls over the comma statement it seems.
Following JavaScript Beautifier plug-in is available for Eclipse.
https://github.com/atlanto/eclipse-javascript-formatter
It can be used to span single statement - multiple variable declarations into multiple lines.
More information about using the above plug-in is given in the README.md file.
Its a little late I guess, but I do this:
var container = require('../core/container'),
/**/uuid = require('node-uuid'),
/**/validations = require('../util/validations');
Or I do this:
var container = require('../core/container'), //
uuid = require('node-uuid'), //
validations = require('../util/validations');
The second one shifts the variables to the beginning of the line, but that's a trade off you'll have to live with.
On one page of my website the user has the ability to choose and remove up to 2000 items through selecting multiple string representations of them in a dropdown list.
On page load, the objects are loaded onto the page from a previous session into 7 different drop-down lists.
In the window.onload event, the function looping through the items in the drop-downs makes an internal collection of the objects by adding them to a global array - This makes the page ridiculously slow to load, so, I'm fairly certain probably doing it wrong!
How else am I supposed to store these variables?
This is their internal representation:
function Permission(PName, DCID, ID) {
this.PName = PName;
this.DCID = DCID;
this.ID = ID;
}
where: PName is string. DCID is int. ID is int.
EDIT:
Thanks for the quick replies! I appreciate the help, I'm not great with JS! Here is more information:
'selectChangeEvent' is added to the Change and Click event of the Drop down list.
function selectChangeEvent(e) {
//...
addListItem(id);
//...
}
'addListItem(id)' sets up the visual representation of the objects and then calls :
function addListObject(x, idOfCaller) {
var arIDOfCaller = idOfCaller.toString().split('-');
if (arIDOfCaller[0] == "selLocs") {
var loc = new AccessLocation(x, arIDOfCaller[1]);
arrayLocations[GlobalIndexLocations] = loc;
GlobalIndexLocations++;
totalLocations++;
}
else {
var perm = new Permission(x, arIDOfCaller[1], arIDOfCaller[2]);
arrayPermissions[GlobalIndexPermissions] = perm;
GlobalIndexPermissions++;
totalPermissions++;
}
}
Still not enough to go on, but there are some small improvements I can see.
Instead of this pattern:
var loc = new AccessLocation(x, arIDOfCaller[1]);
arrayLocations[GlobalIndexLocations] = loc;
GlobalIndexLocations++;
totalLocations++;
which seems to involve redundant counters and has surplus assignment operations, try:
arrayLocations[arrayLocations.length] = new AccessLocation(x, arIDOfCaller[1]);
and just use arrayLocations.length where you would refer to GlobalIndexLocations or totalLocations (which fromt he code above would seem to always be the same value).
That should gain you a little boost, but this is not your main problem. I suggest you add some debugging Date objects to work out where the bottleneck is.
You may want to consider a design change to support the load. Some sort of paged result set or similar, to cut down on the number of concurrent records being modified.
As much as we desperately want them to be, browsers aren't quite there yet in terms of script execution speed that allow us to do certain types of heavy lifting on the client.
While I haven't tested this idea, I figured I'd throw it out there - might it be faster to return a JSON string from the server side, where your array is fully calculated on that side?
From that point, I'd wager that eval()'ing it (as evil as this may be) might be fast enough to where you could then write the contents onto the page, and your array setup would already be taken care of.
Then again, I suppose the amount of work it'd take the browser to construct the 2k new objects and inject them into the DOM wouldn't necessarily help the speed side of things in the end. At the end of the day, a design change is probably necessary, but sometimes we're stuck with what we've got, eh?