Cov txheej txheem:

IoT Guru Huab - Piv Piv Piv Txwv: 4 Kauj Ruam
IoT Guru Huab - Piv Piv Piv Txwv: 4 Kauj Ruam

Video: IoT Guru Huab - Piv Piv Piv Txwv: 4 Kauj Ruam

Video: IoT Guru Huab - Piv Piv Piv Txwv: 4 Kauj Ruam
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Hlis ntuj nqeg
Anonim
IoT Guru Huab - Piv Piv Piv Txwv
IoT Guru Huab - Piv Piv Piv Txwv

IoT Guru Cloud tau muab cov kev pabcuam backend los ntawm REST API thiab koj tuaj yeem sib sau cov REST hu rau koj lub vev xaib yooj yim. Nrog Highcharts, koj tuaj yeem tso tawm kab kos ntawm koj qhov kev ntsuas yooj yim nrog AJAX hu.

Kauj ruam 1: Tsim nplooj ntawv HTML

Koj yuav tsum tsim cov ntaub ntawv HTML khoob nrog koj tus kws kho mob nyiam:

IoT Guru Cloud - Piv txwv daim ntawv yooj yim

Txuag nws: yooj yim -chart.html IoT Guru Huab - Piv txwv daim ntawv yooj yim

Kauj Ruam 2: AJAX Thauj Cov Ntaub Ntawv Cov Ntaub Ntawv

Koj yuav tsum tau ntxiv JQuery thiab hu rau AJAX rau hauv HTML cov ntaub ntawv, nws yuav raug thauj cov ntaub ntawv ntawm cov lus qhia tshwj xeeb thiab lub npe: IoT Guru Cloud - Piv txwv daim ntawv yooj yim

IoT Guru Cloud - Daim duab piv txwv piv txwv yooj yim ua haujlwm loadData (phiaj, npe npe, xAxisText, yAxisText, nodeId, fieldName, granulation) {rov $.ajax ({yam: "GET", url: 'https://api.iotguru.cloud/) ntsuas/loadByNodeId/' + nodeId +'/' + fieldName +'/' + granulation, dataType: "json", kev ua tiav: ua haujlwm (cov ntaub ntawv) {displayChart (lub hom phiaj, titleText, xAxisText, yAxisText, granulation, cov ntaub ntawv);}}); } muaj nuj nqi displayChart (phiaj, npe npe, xAxisText, yAxisText, granulation, cov ntaub ntawv) {} $ (ntawv). npaj txhij (muaj nuj nqi () {loadData ('graphAverage', 'Nruab nrab ncua ntawm cov tsheb ciav hlau (24 teev)', 'Hnub tim thiab sijhawm ',' min ',' ef39d670-70d9-11e9-be02-27e5a8e884a7 ',' nruab nrab ',' HNUB/288 ');}

Kauj Ruam 3: Teem Kab Lus

Ntxiv cov ntawv Highcharts JavaScript rau hauv HTML cov ntawv tom qab JQuery cov ntaub ntawv:

Ua kom tiav lub cev ntawm daim duab qhia ua haujlwm rau teeb tsa daim duab:

muaj nuj nqi displayChart (lub hom phiaj, titleText, xAxisText, yAxisText, granulation, data) {var options = {title: {text: titleText}, chart: {type: 'spline', renderTo: target,}, xAxis: {type: 'datetime ', title: {text: xAxisText}, gridLineWidth: 1, tickInterval: 3600 * 1000}, yAxis: {title: {text: yAxisText}}, series: [{}]}; rau (var i = 0; kuv <data.length; i ++) {options.series = {data: {}, name: {}}; options.series .name = data ["name"]; options.series .data = data ["data"]; } var chart = tshiab Highcharts. Chart (xaiv); }

Kauj ruam 4: Nws yog! Ua tiav

Koj ua tiav, thauj koj cov HTML hauv koj tus browser thiab tshawb xyuas daim duab!

Yog tias koj xav xa kev ntsuas, thov mus saib peb Tutorials nplooj ntawv lossis peb Lub Rooj Sib Tham Zej Zog!:)

Cov piv txwv tag nrho: GitHub - daim ntawv yooj yim

Pom zoo: