d3.csv promise pending and getting its data
This is my first time to ask StackOverflow - I'm new to D3 and had used v5 for this matter
I have already been searching for days and can't find anything. if there's an existing one please help me directly to an exact answer. thank you so much for the help!
intro: just got a sample data for use:
Wafer,N Rows,Product Yield,Endline Yield,Mid_Yield
7G650,10,91.18%,99.70%,94.27%
7G651,10,88.41%,98.11%,95.54%
7G652,10,92.08%,97.56%,98.58%
7G657,10,87.71%,97.76%,95.77%
first off - before, my code was like below:
<script src="https://d3js.org/d3.v5.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var yield = d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
});
console.log(yield);
});
</script>
and when I checked at the console (chrome) - I can see my data. it's just that it needs a promise implementation
so i searched for some solution and here's my code now:
var yield = d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
console.log(data);
});
I could still see my filtered data from console.log(data),
but when I query from outside d3.csv using the "yield" variable
console.log(yield);
values are now undefined
so sorry for the trouble, my boss is about to kill me.. i will need this filtered data for my trend, and soon will add a pareto chart.. thanks in advance and more power to stackoverflow -
javascript d3.js
add a comment |
This is my first time to ask StackOverflow - I'm new to D3 and had used v5 for this matter
I have already been searching for days and can't find anything. if there's an existing one please help me directly to an exact answer. thank you so much for the help!
intro: just got a sample data for use:
Wafer,N Rows,Product Yield,Endline Yield,Mid_Yield
7G650,10,91.18%,99.70%,94.27%
7G651,10,88.41%,98.11%,95.54%
7G652,10,92.08%,97.56%,98.58%
7G657,10,87.71%,97.76%,95.77%
first off - before, my code was like below:
<script src="https://d3js.org/d3.v5.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var yield = d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
});
console.log(yield);
});
</script>
and when I checked at the console (chrome) - I can see my data. it's just that it needs a promise implementation
so i searched for some solution and here's my code now:
var yield = d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
console.log(data);
});
I could still see my filtered data from console.log(data),
but when I query from outside d3.csv using the "yield" variable
console.log(yield);
values are now undefined
so sorry for the trouble, my boss is about to kill me.. i will need this filtered data for my trend, and soon will add a pareto chart.. thanks in advance and more power to stackoverflow -
javascript d3.js
You cannot useyield
as a variable or property name—it's a keyword.
– altocumulus
Nov 21 '18 at 8:45
thanks @Thilina Nakkawita for including my images directly on my question :)
– K4L37
Nov 22 '18 at 1:56
thanks @altocumulus for this info... i never knew that yield is one of its keywords -
– K4L37
Nov 22 '18 at 1:57
add a comment |
This is my first time to ask StackOverflow - I'm new to D3 and had used v5 for this matter
I have already been searching for days and can't find anything. if there's an existing one please help me directly to an exact answer. thank you so much for the help!
intro: just got a sample data for use:
Wafer,N Rows,Product Yield,Endline Yield,Mid_Yield
7G650,10,91.18%,99.70%,94.27%
7G651,10,88.41%,98.11%,95.54%
7G652,10,92.08%,97.56%,98.58%
7G657,10,87.71%,97.76%,95.77%
first off - before, my code was like below:
<script src="https://d3js.org/d3.v5.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var yield = d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
});
console.log(yield);
});
</script>
and when I checked at the console (chrome) - I can see my data. it's just that it needs a promise implementation
so i searched for some solution and here's my code now:
var yield = d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
console.log(data);
});
I could still see my filtered data from console.log(data),
but when I query from outside d3.csv using the "yield" variable
console.log(yield);
values are now undefined
so sorry for the trouble, my boss is about to kill me.. i will need this filtered data for my trend, and soon will add a pareto chart.. thanks in advance and more power to stackoverflow -
javascript d3.js
This is my first time to ask StackOverflow - I'm new to D3 and had used v5 for this matter
I have already been searching for days and can't find anything. if there's an existing one please help me directly to an exact answer. thank you so much for the help!
intro: just got a sample data for use:
Wafer,N Rows,Product Yield,Endline Yield,Mid_Yield
7G650,10,91.18%,99.70%,94.27%
7G651,10,88.41%,98.11%,95.54%
7G652,10,92.08%,97.56%,98.58%
7G657,10,87.71%,97.76%,95.77%
first off - before, my code was like below:
<script src="https://d3js.org/d3.v5.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var yield = d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
});
console.log(yield);
});
</script>
and when I checked at the console (chrome) - I can see my data. it's just that it needs a promise implementation
so i searched for some solution and here's my code now:
var yield = d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
console.log(data);
});
I could still see my filtered data from console.log(data),
but when I query from outside d3.csv using the "yield" variable
console.log(yield);
values are now undefined
so sorry for the trouble, my boss is about to kill me.. i will need this filtered data for my trend, and soon will add a pareto chart.. thanks in advance and more power to stackoverflow -
javascript d3.js
javascript d3.js
edited Nov 21 '18 at 9:05
Thilina Nakkawita
96411229
96411229
asked Nov 21 '18 at 8:37
K4L37K4L37
62
62
You cannot useyield
as a variable or property name—it's a keyword.
– altocumulus
Nov 21 '18 at 8:45
thanks @Thilina Nakkawita for including my images directly on my question :)
– K4L37
Nov 22 '18 at 1:56
thanks @altocumulus for this info... i never knew that yield is one of its keywords -
– K4L37
Nov 22 '18 at 1:57
add a comment |
You cannot useyield
as a variable or property name—it's a keyword.
– altocumulus
Nov 21 '18 at 8:45
thanks @Thilina Nakkawita for including my images directly on my question :)
– K4L37
Nov 22 '18 at 1:56
thanks @altocumulus for this info... i never knew that yield is one of its keywords -
– K4L37
Nov 22 '18 at 1:57
You cannot use
yield
as a variable or property name—it's a keyword.– altocumulus
Nov 21 '18 at 8:45
You cannot use
yield
as a variable or property name—it's a keyword.– altocumulus
Nov 21 '18 at 8:45
thanks @Thilina Nakkawita for including my images directly on my question :)
– K4L37
Nov 22 '18 at 1:56
thanks @Thilina Nakkawita for including my images directly on my question :)
– K4L37
Nov 22 '18 at 1:56
thanks @altocumulus for this info... i never knew that yield is one of its keywords -
– K4L37
Nov 22 '18 at 1:57
thanks @altocumulus for this info... i never knew that yield is one of its keywords -
– K4L37
Nov 22 '18 at 1:57
add a comment |
1 Answer
1
active
oldest
votes
edit: following @altocumulus 's comment
I believe you may be after:
var resultYield;
d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
resultYield = data;
console.log(resultYield);
})
re: using yield / return as keys for object literals:
const test = {
yield: 'yield',
return : 'return'
}
const getTest = () => ({
yield: 'getYield',
return: 'getReturn'
})
const getTest2 = function(){
return {
yield: 'getYield2',
return: 'getReturn2'
}
}
console.log(test, getTest(), getTest2())
Still there is ayield
in the object literal.
– altocumulus
Nov 21 '18 at 8:50
as a key? I didn't think there was anything wrong with it?
– pandamakes
Nov 21 '18 at 8:55
Good point. Never thought about that since I generally consider using a keyword as an identifier a bad idea. Related: mathiasbynens.be/notes/javascript-properties, "Rules for unquoted JavaScript Object Literal Keys?".
– altocumulus
Nov 21 '18 at 8:59
` ECMAScript 3 didn’t allow the use of unquoted reserved words as property names.` I see your point.
– pandamakes
Nov 21 '18 at 9:02
hi @pandamakes, thanks for your answer, i tried your code & changed all yield keyword except for csv-col-titlevar resultYield; d3.csv("http://localhost:5001/data.csv", function(data, i) { return { waf : data.Wafer, seq : i, yld : +data["SDPT Yield"].replace(/%/g, "") }; }).then(function(data){ resultYield = data; console.log(resultYield); });
resultYield works inside d3.csv, but not outside still- i need to get this kind of data ---resultYield = [{ waf: "7G650", seq: 1, yld: 94.27 }]
– K4L37
Nov 21 '18 at 15:16
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408074%2fd3-csv-promise-pending-and-getting-its-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
edit: following @altocumulus 's comment
I believe you may be after:
var resultYield;
d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
resultYield = data;
console.log(resultYield);
})
re: using yield / return as keys for object literals:
const test = {
yield: 'yield',
return : 'return'
}
const getTest = () => ({
yield: 'getYield',
return: 'getReturn'
})
const getTest2 = function(){
return {
yield: 'getYield2',
return: 'getReturn2'
}
}
console.log(test, getTest(), getTest2())
Still there is ayield
in the object literal.
– altocumulus
Nov 21 '18 at 8:50
as a key? I didn't think there was anything wrong with it?
– pandamakes
Nov 21 '18 at 8:55
Good point. Never thought about that since I generally consider using a keyword as an identifier a bad idea. Related: mathiasbynens.be/notes/javascript-properties, "Rules for unquoted JavaScript Object Literal Keys?".
– altocumulus
Nov 21 '18 at 8:59
` ECMAScript 3 didn’t allow the use of unquoted reserved words as property names.` I see your point.
– pandamakes
Nov 21 '18 at 9:02
hi @pandamakes, thanks for your answer, i tried your code & changed all yield keyword except for csv-col-titlevar resultYield; d3.csv("http://localhost:5001/data.csv", function(data, i) { return { waf : data.Wafer, seq : i, yld : +data["SDPT Yield"].replace(/%/g, "") }; }).then(function(data){ resultYield = data; console.log(resultYield); });
resultYield works inside d3.csv, but not outside still- i need to get this kind of data ---resultYield = [{ waf: "7G650", seq: 1, yld: 94.27 }]
– K4L37
Nov 21 '18 at 15:16
|
show 2 more comments
edit: following @altocumulus 's comment
I believe you may be after:
var resultYield;
d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
resultYield = data;
console.log(resultYield);
})
re: using yield / return as keys for object literals:
const test = {
yield: 'yield',
return : 'return'
}
const getTest = () => ({
yield: 'getYield',
return: 'getReturn'
})
const getTest2 = function(){
return {
yield: 'getYield2',
return: 'getReturn2'
}
}
console.log(test, getTest(), getTest2())
Still there is ayield
in the object literal.
– altocumulus
Nov 21 '18 at 8:50
as a key? I didn't think there was anything wrong with it?
– pandamakes
Nov 21 '18 at 8:55
Good point. Never thought about that since I generally consider using a keyword as an identifier a bad idea. Related: mathiasbynens.be/notes/javascript-properties, "Rules for unquoted JavaScript Object Literal Keys?".
– altocumulus
Nov 21 '18 at 8:59
` ECMAScript 3 didn’t allow the use of unquoted reserved words as property names.` I see your point.
– pandamakes
Nov 21 '18 at 9:02
hi @pandamakes, thanks for your answer, i tried your code & changed all yield keyword except for csv-col-titlevar resultYield; d3.csv("http://localhost:5001/data.csv", function(data, i) { return { waf : data.Wafer, seq : i, yld : +data["SDPT Yield"].replace(/%/g, "") }; }).then(function(data){ resultYield = data; console.log(resultYield); });
resultYield works inside d3.csv, but not outside still- i need to get this kind of data ---resultYield = [{ waf: "7G650", seq: 1, yld: 94.27 }]
– K4L37
Nov 21 '18 at 15:16
|
show 2 more comments
edit: following @altocumulus 's comment
I believe you may be after:
var resultYield;
d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
resultYield = data;
console.log(resultYield);
})
re: using yield / return as keys for object literals:
const test = {
yield: 'yield',
return : 'return'
}
const getTest = () => ({
yield: 'getYield',
return: 'getReturn'
})
const getTest2 = function(){
return {
yield: 'getYield2',
return: 'getReturn2'
}
}
console.log(test, getTest(), getTest2())
edit: following @altocumulus 's comment
I believe you may be after:
var resultYield;
d3.csv("http://server/trend/data.csv",
function(data, i) {
return {
waf : data.Wafer,
seq : i,
yield : +data["Product Yield"].replace(/%/g, "")
};
}).then(function(data){
resultYield = data;
console.log(resultYield);
})
re: using yield / return as keys for object literals:
const test = {
yield: 'yield',
return : 'return'
}
const getTest = () => ({
yield: 'getYield',
return: 'getReturn'
})
const getTest2 = function(){
return {
yield: 'getYield2',
return: 'getReturn2'
}
}
console.log(test, getTest(), getTest2())
const test = {
yield: 'yield',
return : 'return'
}
const getTest = () => ({
yield: 'getYield',
return: 'getReturn'
})
const getTest2 = function(){
return {
yield: 'getYield2',
return: 'getReturn2'
}
}
console.log(test, getTest(), getTest2())
const test = {
yield: 'yield',
return : 'return'
}
const getTest = () => ({
yield: 'getYield',
return: 'getReturn'
})
const getTest2 = function(){
return {
yield: 'getYield2',
return: 'getReturn2'
}
}
console.log(test, getTest(), getTest2())
edited Nov 21 '18 at 9:00
answered Nov 21 '18 at 8:48
pandamakespandamakes
1827
1827
Still there is ayield
in the object literal.
– altocumulus
Nov 21 '18 at 8:50
as a key? I didn't think there was anything wrong with it?
– pandamakes
Nov 21 '18 at 8:55
Good point. Never thought about that since I generally consider using a keyword as an identifier a bad idea. Related: mathiasbynens.be/notes/javascript-properties, "Rules for unquoted JavaScript Object Literal Keys?".
– altocumulus
Nov 21 '18 at 8:59
` ECMAScript 3 didn’t allow the use of unquoted reserved words as property names.` I see your point.
– pandamakes
Nov 21 '18 at 9:02
hi @pandamakes, thanks for your answer, i tried your code & changed all yield keyword except for csv-col-titlevar resultYield; d3.csv("http://localhost:5001/data.csv", function(data, i) { return { waf : data.Wafer, seq : i, yld : +data["SDPT Yield"].replace(/%/g, "") }; }).then(function(data){ resultYield = data; console.log(resultYield); });
resultYield works inside d3.csv, but not outside still- i need to get this kind of data ---resultYield = [{ waf: "7G650", seq: 1, yld: 94.27 }]
– K4L37
Nov 21 '18 at 15:16
|
show 2 more comments
Still there is ayield
in the object literal.
– altocumulus
Nov 21 '18 at 8:50
as a key? I didn't think there was anything wrong with it?
– pandamakes
Nov 21 '18 at 8:55
Good point. Never thought about that since I generally consider using a keyword as an identifier a bad idea. Related: mathiasbynens.be/notes/javascript-properties, "Rules for unquoted JavaScript Object Literal Keys?".
– altocumulus
Nov 21 '18 at 8:59
` ECMAScript 3 didn’t allow the use of unquoted reserved words as property names.` I see your point.
– pandamakes
Nov 21 '18 at 9:02
hi @pandamakes, thanks for your answer, i tried your code & changed all yield keyword except for csv-col-titlevar resultYield; d3.csv("http://localhost:5001/data.csv", function(data, i) { return { waf : data.Wafer, seq : i, yld : +data["SDPT Yield"].replace(/%/g, "") }; }).then(function(data){ resultYield = data; console.log(resultYield); });
resultYield works inside d3.csv, but not outside still- i need to get this kind of data ---resultYield = [{ waf: "7G650", seq: 1, yld: 94.27 }]
– K4L37
Nov 21 '18 at 15:16
Still there is a
yield
in the object literal.– altocumulus
Nov 21 '18 at 8:50
Still there is a
yield
in the object literal.– altocumulus
Nov 21 '18 at 8:50
as a key? I didn't think there was anything wrong with it?
– pandamakes
Nov 21 '18 at 8:55
as a key? I didn't think there was anything wrong with it?
– pandamakes
Nov 21 '18 at 8:55
Good point. Never thought about that since I generally consider using a keyword as an identifier a bad idea. Related: mathiasbynens.be/notes/javascript-properties, "Rules for unquoted JavaScript Object Literal Keys?".
– altocumulus
Nov 21 '18 at 8:59
Good point. Never thought about that since I generally consider using a keyword as an identifier a bad idea. Related: mathiasbynens.be/notes/javascript-properties, "Rules for unquoted JavaScript Object Literal Keys?".
– altocumulus
Nov 21 '18 at 8:59
` ECMAScript 3 didn’t allow the use of unquoted reserved words as property names.` I see your point.
– pandamakes
Nov 21 '18 at 9:02
` ECMAScript 3 didn’t allow the use of unquoted reserved words as property names.` I see your point.
– pandamakes
Nov 21 '18 at 9:02
hi @pandamakes, thanks for your answer, i tried your code & changed all yield keyword except for csv-col-title
var resultYield; d3.csv("http://localhost:5001/data.csv", function(data, i) { return { waf : data.Wafer, seq : i, yld : +data["SDPT Yield"].replace(/%/g, "") }; }).then(function(data){ resultYield = data; console.log(resultYield); });
resultYield works inside d3.csv, but not outside still- i need to get this kind of data --- resultYield = [{ waf: "7G650", seq: 1, yld: 94.27 }]
– K4L37
Nov 21 '18 at 15:16
hi @pandamakes, thanks for your answer, i tried your code & changed all yield keyword except for csv-col-title
var resultYield; d3.csv("http://localhost:5001/data.csv", function(data, i) { return { waf : data.Wafer, seq : i, yld : +data["SDPT Yield"].replace(/%/g, "") }; }).then(function(data){ resultYield = data; console.log(resultYield); });
resultYield works inside d3.csv, but not outside still- i need to get this kind of data --- resultYield = [{ waf: "7G650", seq: 1, yld: 94.27 }]
– K4L37
Nov 21 '18 at 15:16
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408074%2fd3-csv-promise-pending-and-getting-its-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You cannot use
yield
as a variable or property name—it's a keyword.– altocumulus
Nov 21 '18 at 8:45
thanks @Thilina Nakkawita for including my images directly on my question :)
– K4L37
Nov 22 '18 at 1:56
thanks @altocumulus for this info... i never knew that yield is one of its keywords -
– K4L37
Nov 22 '18 at 1:57