Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created March 16, 2019 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/fb39cf69db5e24ec203fd79fc86655b7 to your computer and use it in GitHub Desktop.
Save NMZivkovic/fb39cf69db5e24ec203fd79fc86655b7 to your computer and use it in GitHub Desktop.
/**
* @desc plots one
* @param array values - array of values
* @param string name - name of the plot
* @param string xoutput - x name
* @param string youtput - y name
*/
function singlePlot(values, name, xoutput, youtput)
{
tfvis.render.scatterplot(
{name: name},
{values},
{
xoutput: xoutput,
youtput: youtput,
height: 300
}
);
}
/**
* @desc plots one
* @param json data - complete json that contains wine quality data
*/
function displayDataFunction(data){
let displayData = data.map(d => ({
x: d.alcohol,
y: d.quality,
}));
singlePlot(displayData, 'Alchocol v Quality', 'Alchocol', 'Quality')
displayData = data.map(d => ({
x: d.chlorides,
y: d.quality,
}));
singlePlot(displayData, 'Chlorides v Quality', 'Chlorides', 'Quality')
displayData = data.map(d => ({
x: d.citric_acid,
y: d.quality,
}));
singlePlot(displayData, 'Citric Acid v Quality', 'Citric Acid', 'Quality')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment