In first API call I'm getting an array of IDs to be able to make another API call to grab revenue key/value pairs, then push it back to the main object(as it doesn't have it by default).
const mainURL =
"https://api.themoviedb.org/3/discover/movie?api_key=2339027b84839948cd9be5de8b2b36da&language=en-US&sort_by=revenue.desc&include_adult=false&include_video=false&page=";
const movieBaseURL =
"https://api.themoviedb.org/3/movie/335?api_key=2339027b84839948cd9be5de8b2b36da&language=en-US";
const apiKey = "2339027b84839948cd9be5de8b2b36da";
let getRevenueByID,revenue, data, response, obj;
let Each_ID_Array = [],
All_ID_Array = [],
All_ID_Array_merged = [],
pages_Array = [1, 2],
keyValueArr = [],
allKeyValueArr = [],
objectArr = [];
responses = []; …Run Code Online (Sandbox Code Playgroud) 我正在尝试用面积图形状将线上的点拟合,但是不适合。我认为这是由于.curve使用d3.curveBasis。
data = [
{
"login_date": "2017-09-24",
"unique_user_count": 2,
"total_login_count": 2
},
{
"login_date": "2017-09-25",
"unique_user_count": 25,
"total_login_count": 46
},
{
"login_date": "2017-09-26",
"unique_user_count": 31,
"total_login_count": 74
},
{
"login_date": "2017-09-27",
"unique_user_count": 29,
"total_login_count": 58
},
{
"login_date": "2017-09-28",
"unique_user_count": 29,
"total_login_count": 60
},
{
"login_date": "2017-09-29",
"unique_user_count": 31,
"total_login_count": 71
},
{
"login_date": "2017-09-30",
"unique_user_count": 1,
"total_login_count": 1
},
{
"login_date": "2017-10-01",
"unique_user_count": 1,
"total_login_count": 1
},
{
"login_date": "2017-10-02",
"unique_user_count": 41,
"total_login_count": 71
},
{
"login_date": …Run Code Online (Sandbox Code Playgroud)我正在使用d3-fetch库以能够使用异步/等待,但是出现以下错误:fetch.json不是一个函数。
它确实与d3.json()一起工作。
我在这里做错了什么?
async function fetchAllData() {
try {
let data = await fetch.json('https://api.myjson.com/bins/1cpi9w');
return data;
console.log("Initial data: ", data);
console.log("type of n: ", indicateType(data[0].n));
let format = d3.timeFormat("%Y");
//Nesting data by category
let updatedData = d3.nest()
.key(d => d.category)
.sortValues((a, b) => a.year - b.year)
.entries(data);
//Define xScale domain (min,max assume it has been sorted by year)
xScale.domain([
d3.min(updatedData, function(s) { return s.values[0].year; }),
d3.max(updatedData, function(s) { return s.values[s.values.length - 1].year })
]);
console.log("Nested data: ", updatedData); …Run Code Online (Sandbox Code Playgroud)