Right now I want to load in data from multiple different queries. The issue is I’m not quite sure how to code this up. My code works if only using 1 query however I’m unsure on how to adapt the code to handle multiple queries. This can be seen below as I get the following error:
// Iterate over each section in the series (0 and 1)
for (let i = 0; i <= 1; i++) {
const test = data.series[i]; // Establishing path as 'data' is a JSON object
if (test) {
// For the first query
if (i === 0) { // Checking the first query which is labelled as '0'
const dayOfWeekField = test.fields.find((f) => f.name === "day_of_week");
const dataVolumeField = test.fields.find((f) => f.name === "total_data_volume_gb");
if (dayOfWeekField && dataVolumeField) {
day_of_week = dayOfWeekField.values;
total_data_volume_gb = dataVolumeField.values;
}
}
// For the second query-> Can copy + paste for additional queries as it follows this exact format
if (i === 1) { // Checking second query which is labelled as '1'
const totalDataVolume1Field = test.fields.find((f) => f.name === "total_data_volume_gb1");
if (totalDataVolume1Field) {
total_data_volume_gb1 = totalDataVolume1Field.values; // Doesn't need y axis values as it should share the same as the first query
}
}
}
}