Cannot call method 'instance' of undefined - protovis

When using the following code;
var pvChart = new pv.Panel();
pvChart.width(200);
pvChart.height(200);
var pvBar = pvChart.add(pv.Bar);
pvBar.data([1,2,3]);
console.log(pvBar.fillStyle());
I get the error;
Cannot call method 'instance' of
undefined
It refers to the pvBar.fillStyle(). Using this I want to retrieve the bars fillStyle for later use. Can anyone tell me the reason of this error and how to solve this?

SOLVED
it was because I was requesting the fillStyle before the bar has been drawn..
Correct code;
var pvChart = new pv.Panel();
pvChart.width(200);
pvChart.height(200);
var pvBar = pvChart.add(pv.Bar);
pvBar.data([1,2,3]);
pvChart.render();
console.log(pvBar.fillStyle());

Related

Getting error 'Insight.Database.FastExpando' does not contain a definition for 'Set1'

The following code is giving the above error, and I cannot figure out why:
var x = _sqlConn.Connection().QueryResults<Results>("MyDb.dbo.get_records", new { id = theId });
int retVal = x.Outputs.Return_Value;
if (retVal == 0) // ...meaning result set was also returned...fine to this point.
{
var list = x.Outputs.Set1; // exception thrown here with above error
var temp = list.FirstOrDefault();
I have been using other features of Insight.Database for a number of years, but have not had to retrieve a SQL RETURN value at the same time as a recordset. The SQL itself works correctly in SSMS, returning a result set and the RETURN value of 0, as expected. This is happening in VS2019, .NET 4 and .NET 4.5.2; Insight.Database 5.2.7 and 5.2.8.
I got this code from the following page:
https://github.com/jonwagner/Insight.Database/wiki/Specifying-Result-Structures
where it shows this:
var results = connection.QueryResults<Beer, Glass>("GetAllBeersAndAllGlasses");
IList<Beer> beers = results.Set1;
which I combined with the following code from here:
https://github.com/jonwagner/Insight.Database/wiki/Output-Parameters
var results = connection.QueryResults<Results>("MyProc", inputParameters);
var p = results.Outputs.p;
That part works. It's accessing .Set1 that is failing, and I am not sure how to track down why.
I do not have experience with the FastExpando class, but Jon promised magic, and I want to believe. Thanks for any help.
I haven’t tried results+dynamic objects in a while…
I think it is because you are doing:
QueryResults<Results> and Results is an Insight type
You probably want:
QueryResults<MyType>
And then you get back a Results<MyType>
Which contains the return val and Set1
If not, post a ticket over on github and we will help you out.

Google Apps Script error: Cannot read property 'appendRow' of null [duplicate]

This question already has an answer here:
How to fix 'TypeError: Cannot call method "getRange" of null' in Google Apps Script
(1 answer)
Closed 4 months ago.
Google Apps Script keeps giving me the error:
TypeError: Cannot read property 'appendRow' of null
AddRecord # Code.gs:4
The code:
function AddRecord() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var mainSheet = ss.getSheetByName("MAIN");
mainSheet.appendRow(["purple", new Date()]);
}
How to fix it?
The following function will avoid unwanted active spreadsheet, and potential error :
//replace:
var ss = SpreadsheetApp.getActiveSpreadsheet();
//by:
var ss = SpreadsheetApp.openById('xxxxx');
// you will find the ID in the URL of the sheet, between "spreadsheets/d/" and "/edit"
If still have some issue, the problem must come from the sheet name as #Cooper already told you ;)
According to the document:
getSheetByName(name) returns null if there is no sheet with the given name and Sheet if the sheet name is found in the Spreadsheet.
There are 2 possible reasons for having a null value:
The sheet named MAIN does not exists.
There is a typographical error in the sheet name.
You can fix that by adding a sheet named MAIN or renaming your sheet to MAIN to remove any extra characters.
References:
Sheet
getSheetByName(name)
The sheet is probably not called MAIN in the file you are using.
I had a similar problem. If you have not edited the sheet prior try this:
var mainSheet = ss.getSheetByName("Sheet1");
to replace this:
var mainSheet = ss.getSheetByName("MAIN");
This will reference the specific sheet in the file, and it should execute just fine then.
i had the Problem too!
There is how I fixed that:
function AddRecord() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var mainSheet = ss.getSheetName();
var mainSheet1 = ss.getSheetByName(mainSheet);
mainSheet1.appendRow(["purple", new Date()]);
}

Can not read property 'position' undefined, get Coordinates - CustomTile - Openseadragon

I am trying to get the coordinates with below code : If i am clicking on the canvas to grab the X and Y position : showing me console error : Uncaught TypeError: Cannot read property 'position' of undefined
screenshot : http://screencast.com/t/0LHAae5AicRz
viewer.addHandler('canvas-click', function (target, info) {
var viewportPoint = viewer.viewport.pointFromPixel(info.position);
var imagePoint = viewer.viewport.viewportToImageCoordinates(viewportPoint.x, viewportPoint.y);
console.log(imagePoint.x, imagePoint.y);
});
The info parameter is probably not what you think it is.
Do console.log(info) to see what the variable is in the console.
Perhaps the variable you are looking for is another parameter.
Also log all the arguments that get passed to the function. Write this inside the function:
console.log(arguments)
This way you will be able to inspect the variables and find the data you need.
This way, I can remove the canvas-click related - position of undefined error : Take a look at here for the answer : https://github.com/openseadragon/openseadragon/issues/318
For the //! OpenSeadragon 1.1.1, please updated the code as per below.
viewer.addHandler('canvas-click', function (event)
{
console.log(event);
var viewportPoint = viewer.viewport.pointFromPixel(event.position);
var imagePoint = viewer.viewport.viewportToImageCoordinates(viewportPoint.x, viewportPoint.y);
console.log(imagePoint.x, imagePoint.y);
});

What am I doing wrong with this Python class? AttributeError: 'NoneType' object has no attribute 'usernames'

Hey there I am trying to make my first class my code is as follows:
class Twitt:
def __init__(self):
self.usernames = []
self.names = []
self.tweet = []
self.imageurl = []
def twitter_lookup(self, coordinents, radius):
twitter = Twitter(auth=auth)
coordinents = coordinents + "," + radius
print coordinents
query = twitter.search.tweets(q="", geocode='33.520661,-86.80249,50mi', rpp=10)
print query
for result in query["statuses"]:
self.usernames.append(result["user"]["screen_name"])
self.names.append(result['user']["name"])
self.tweet.append(h.unescape(result["text"]))
self.imageurl.append(result['user']["profile_image_url_https"])
What I am trying to be able to do is then use my class like so:
test = Twitt()
hello = test.twitter_lookup("38.5815720,-121.4944000","1m")
print hello.usernames
This does not work and I keep getting: "AttributeError: 'NoneType' object has no attribute 'usernames'"
Maybe I just misunderstood the tutorial or am trying to use this wrong. Any help would be appreciated thanks.
I see the error is test.twitter_lookup("38.5815720,-121.4944000","1m") return nothing. If you want the usernames, you need to do
test = Twitt()
test.twitter_lookup("38.5815720,-121.4944000","1m")
test.usernames
Your function twitter_lookup is modifying the Twitt object in-place. You didn't make it return any kind of value, so when you call hello = test.twitter_lookup(), there's no return value to assign to hello, and it ends up as None. Try test.usernames instead.
Alternatively, have the twitter_lookup function put its results in some new object (perhaps a dictionary?) and return it. This is probably the more sensible solution.
Also, the function accepts a coordinents (it's 'coordinates') argument, but then throws it away and uses a hard-coded value instead.

Why my WPF window did not show ToList<> property while writing MongoDB(c#) query?

I am using Mongodb(c#) in my WPF App.
I wrote query as
var server = MongoServer.Create(this.connectionString);
var db = server.GetDatabase(DATABASE);
var loadRiskAlertTypeSettings = db.GetCollection(RISKALERTSETTINGS_TBL);
var qry = Query.EQ("UserName", ConsoleMain.lblUname.Content.ToString());
List<RiskAlertTypeSettings> userResult = loadRiskAlertTypeSettings.FindAs<RiskAlertTypeSettings>(qry).ToList<RiskAlertTypeSettings>();
But it did not showing ToList<> property in my current working window.
I used above query in my App several times in different windows.
But in my present window it did not showing?
I traced.But i did not find any solution.
Can any one guide me in that?
I've tested your code and I don't see any problem for doing this:
var userResult = loadRiskAlertTypeSettings
.FindAs<RiskAlertTypeSettings>(qry)
.ToList();
The method ToList() is in System.Linq namespace, so check if you imports have included it.
using System.Linq;