The document contains code for a Spotify data visualization project. It defines variables to store track names, positions, artists, and images from a Spotify dataset. It includes functions to randomly select and display an album cover, choose a new top track, and update the display. It also includes event handlers for buttons to navigate between screens and a dropdown to select and display a song's artist and image.
The document contains code for a Spotify data visualization project. It defines variables to store track names, positions, artists, and images from a Spotify dataset. It includes functions to randomly select and display an album cover, choose a new top track, and update the display. It also includes event handlers for buttons to navigate between screens and a dropdown to select and display a song's artist and image.
var tracks = getColumn("Top 50 Worldwide", "Track Name");
var positions = getColumn("Top 50 Worldwide", "Position"); var artists = getColumn("Top 50 Worldwide", "Artist"); var images = getColumn("Top 50 Worldwide 1", "Images"); var songChoice = "21 savage"; //Filtered List var nextTracks = []; var nextPositions = []; var nextArtists = []; var nextImages = [];
//Brandley and Ethan worked on the on event buttons
//Will bring user from screen 1 to screen 2 onEvent("nextButton", "click", function( ) { setScreen("screen2"); });
//Will take the user from the third screen to the home screen onEvent("homeButton", "click", function() { setScreen("screen1"); });
//Will take user from screen 2 to the home screen
onEvent("homeButton2", "click", function() { setScreen("screen1"); }); //Brandley and Diego worked on the updateScreen function //Function for the filtering and randomizing of the data function updateScreen() { var index = randomNumber(0, tracks.length - 1); setText("text_input1", tracks[index]); setText("text_input2", positions[index]); setText("text_input3", artists[index]); setProperty("imageOutput", "image", images[index]); }
//Khoa and Ethan worked on the getNextAlbum function
//Will choose a new album cover and display it function getNextAlbum() { for (var i = 0; i < tracks.length; i++) { //List of the cities, temps, and condition/icons. if (positions[i] == 1) { appendItem(nextTracks, tracks[i]); appendItem(nextPositions, positions[i]); appendItem(nextArtists, artists[i]); appendItem(nextImages, images[i]); } } }
//Ethan, Diego and Brandley worked on the dropdown
//Khoa worked on getting the images into the data set //The dropdown will allow the user to choose a song title and then display the //image and display the artists name who made the track onEvent("dropdown1", "click", function( ) { var index = 0; songChoice = getText("dropdown1"); for (var i = 0; i < tracks.length; i++) { if (songChoice == tracks[i]) { index = i; setText("artistNameOutput", artists[i]); setProperty("image7", "image", images[i]); } } });