d3.csv promise pending and getting its data












1















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



enter image description here



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),



enter image description here



but when I query from outside d3.csv using the "yield" variable



console.log(yield);


values are now undefined



enter image description here



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 -










share|improve this question

























  • 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
















1















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



enter image description here



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),



enter image description here



but when I query from outside d3.csv using the "yield" variable



console.log(yield);


values are now undefined



enter image description here



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 -










share|improve this question

























  • 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














1












1








1








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



enter image description here



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),



enter image description here



but when I query from outside d3.csv using the "yield" variable



console.log(yield);


values are now undefined



enter image description here



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 -










share|improve this question
















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



enter image description here



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),



enter image description here



but when I query from outside d3.csv using the "yield" variable



console.log(yield);


values are now undefined



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 9:05









Thilina Nakkawita

96411229




96411229










asked Nov 21 '18 at 8:37









K4L37K4L37

62




62













  • 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



















  • 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

















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












1 Answer
1






active

oldest

votes


















-1














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())








share|improve this answer


























  • 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











  • 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-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













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
});


}
});














draft saved

draft discarded


















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









-1














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())








share|improve this answer


























  • 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











  • 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-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


















-1














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())








share|improve this answer


























  • 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











  • 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-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
















-1












-1








-1







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())








share|improve this answer















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())






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 '18 at 9:00

























answered Nov 21 '18 at 8:48









pandamakespandamakes

1827




1827













  • 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











  • 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-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





















  • 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











  • 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-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



















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






















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)