I am using the following script to get data from an api endpoint to populate my charts and everything works fine.
Now I would not only like to populate my charts with the data but also print out the data directly in my html script and use something like the document.write() function.
bit if I write for example document.write(DE10YB_EUR_price) it does not display anything.
Can someone tell me how to print the DE10YB_EUR_price as plain text in html?
Thanks a lot and kind regards
{% block jquery%}
var endpoint = '/technicalAnalalysis/api/data/'
var chartData = []
var chartLabels = []
$.ajax({
method: "GET",
url: endpoint,
success: function(data){
DE10YB_EUR_price = data.DE10YB_EUR_closeBid
DE10YB_EUR_dateData = data.DE10YB_EUR_dates
DE10YB_EUR_upperBand = data.DE10YB_EUR_upperband
DE10YB_EUR_middleBand = data.DE10YB_EUR_middleband
DE10YB_EUR_lowerBand = data.DE10YB_EUR_lowerband
DE10YB_EUR_rsi = data.DE10YB_EUR_RSI
DE10YB_EUR_minusDI = data.DE10YB_EUR_ADX_Minus
DE10YB_EUR_plusDI = data.DE10YB_EUR_ADX_Plus
DE10YB_EUR_adx = data.DE10YB_EUR_ADX
DE10YB_EUR_macd = data.DE10YB_EUR_macd
DE10YB_EUR_macdsignal = data.DE10YB_EUR_macdsignal
DE10YB_EUR_macdhist = data.DE10YB_EUR_macdhist
setChart()
},
error: function(error_data){
console.log("error")
console.log(error_data)
}
})
function setChart(){
var ctx = document.getElementById('DE10YB_EUR_priceData').getContext('2d');
var chart = new Chart(ctx, {
type: 'line',
data: {
labels: DE10YB_EUR_dateData,
datasets: [{
label: 'DE10YB_EUR',
data: DE10YB_EUR_price,
backgroundColor: "rgba(0,0,0,0)",
borderColor: 'rgba(0, 0, 0, 1)',
borderWidth: 2,
} ]
},
options:{
elements: {
point:{
radius: 0
}
},
scales: {
yAxes: [{
ticks: {
beginAtZero:false
}
}],
xAxes: [{
display: false
}]
}
}
});
text(). Usingdocument.writeis like killing a mosquito with a grenade.