score:1
you mean like a second argument, analog to getapi_data
?
function call_some_api(getdata){
request('https://someurl..........',{json:true},(err,res,data) => {
if (err) {
console.log(err);
}
if (res.statuscode === 200){
var dataset = [];
// btw this can be better/cleaner done with `.map` ;)
data.foreach((value, key)=>{
dataset.push(value.close);
});
getdata(data, dataset);
}
});
};
and in your render/http endpoint
app.get('/chart',function(req,res){
call_some_api(function(getapi_data, dataset){
res.render('chart',{
datachart: getapi_data,
dataset
});
});
});
note: code not tested, inline edited.
Source: stackoverflow.com
Related Query
- Can I add some variables to my chart.js in page know that variables?
- How can I add some text in the middle of a half doughnut chart in Chart.JS?
- chart.js add second line in a Line chart that starts from end of first line
- How can I add a euro sign (€) to all tooltips in my chart js line chart
- how can i use chart.js to create a chart that has one time series line and one linear line on it at the same time?
- How can I build a double doughnut chart that spins when triggered
- How I can add some horizontal padding to x-axis tick values in Chart.js?
- How can I add background color of length bars in chart (chartJS)?
- How can I create a stacked bar chart with Charts.JS that displays relative rather than absolute values?
- Can chart.js display text associated with each point on a line chart that is permanently visible?
- How can I create a bar chart that has multiple yAxes scales?
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- How can I add new data points to an existing chart with chart.js?
- How to set the data of chart in angular which is taken from the backend nodejs api that is store in mongodb and showing on the html page
- How can I add functionality to Chartjs Doughnut chart custom legend
- How can I build some chart with Chart.js and ng2-charts using an array of revenus & budgets per month date as Data source?
- How to add text inside the doughnut chart using Chart.js?
- How to clear a chart from a canvas so that hover events cannot be triggered?
- How can labels/legends be added for all chart types in chart.js (chartjs.org)?
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- How can I make two of my lines in Chart JS thicker
- How to modify chartjs tooltip so i can add customized strings in tooltips
- How to add an on click event to my Line chart using Chart.js
- How can I make a stepline or stepped chart in chart.js or D3?
- Add DataSet Bar Chart - Chart.JS
- How to add an offset to a dataset in Chart js
- ChartJS add tooltip to a grouped bar chart
- How to add second Y-axis for Bar and Line chart in Chart.js?
- How to add text in centre of the doughnut chart using Chart.js?
- chart js tooltip how to control the data that show
More Query from same tag
- How to have chart.js automatically build x-axis labels based on x,y dataset?
- Align a data label below a point on a bubble graph (Chart.JS)
- How to fix a stacked logarithmic bar chart values to fit the grid
- Double Y Axis + Bar chart combo
- How to make react-chartjs-2 responsive on mobile?
- zooming/blowup and panning option in chart.js on category scales
- ReactChart2 - Line is not a registered Element
- Javascript How to give color using conditional statement based on json array state value
- Getting access to already created Chart.js chart
- Chart.js 3.6.2, Angular 10: Logarithmic Line chart Y-Axis problems. How to set and keep Y-Axis properties, even when data changes?
- How to plot multiple value for one X-axis chart.js
- Stacked Mixed Horizontal Bar Chart in Charts.Js Axes Positioning
- Exclude value if under a certain percentage
- How to hide the legend display for a specific chart?
- How to plot a line chart which has both the start and points outside the canvas area using Chart.js
- How do I increase the space between the Legend and the Chart when using angular-chart.js?
- Format chart.js x-axis labels to specific timezone
- trying to get minIndex and maxIndex from x-axis-0
- chart-options not registering scaleStartValue
- interactive Button doesn't hide the chart as I intended
- ChartJS 2.7.0 updating and exporting as png
- Chartjs: display value in html element when hovering a bar
- Cleart Chart data upon ajax call
- How to create a line on a chart using chartjs-plugin-annotation
- How to push array multidimesional in javascript
- Updating Chartjs Line chart from database
- Filter a legend Item with Chartjs.org V2.7
- Problems hovering over ChartJS bar chart after being redrawn
- How to pass data for stacked chart in vue-chartkick
- Highlight date in Chart.js line graph