我正在使用 OOP 原則來(lái)創(chuàng)建一堆圖表。除了文本值的設(shè)置之外,一切正常。我需要設(shè)置每個(gè)圖表的標(biāo)題,但我得到的是空白值。我的代碼:控制器文件,即main.js通過(guò)調(diào)用構(gòu)造函數(shù)(存儲(chǔ)在 中mainSlopeGraph.js)以及包含idof<h6>元素和填充文本的參數(shù)來(lái)執(zhí)行所有數(shù)據(jù)操作并創(chuàng)建新圖形。相關(guān)代碼:<div class="col-sm-4 descGraph"> <h6 id="provinceNameBaloch"></h6> <h6 id="provinceNameICT"></h6> <h6 id="provinceNamePunjab"></h6> <h6 id="provinceNameSindh"></h6> <h6 id="provinceNameKPK"></h6> <p>Add some words talking about the trend.</p> </div>main.js:slopeGraphKPK = new SlopeGraph( "#chart1", updatedKPKData, dataKPKDomain, "#provNameKPK", provNameKPK ); slopeGraphPunjab = new SlopeGraph( "#chart2", updatedPunjabData, dataPunjabDomain, "#provNamePunjab", provNamePunjab ); slopeGraphICT = new SlopeGraph( "#chart3", updatedICTData, dataICTDomain, "#provNameICT", provNameICT ); slopeGraphSindh = new SlopeGraph( "#chart4", updatedSindhData, dataSindhDomain, "#provNameSindh", provNameSindh ); slopeGraphBaloch = new SlopeGraph( "#chart5", updatedBalochData, dataBalochDomain, "#provNameBaloch", provNameBaloch );mainSlopeGraph.js: SlopeGraph = function( _parentElement, _someData, _someDomain, _provNamePlaceholder, _provName) { this.parentElement = _parentElement; this.provData = _someData; this.scaleDomain = _someDomain; this.provNamePlaceholder = _provNamePlaceholder; this.provName = _provName; this.initVis();};SlopeGraph.prototype.initVis = function() { let vis = this; console.log(vis.provNamePlaceholder); console.log(vis.provName); $(vis.provNamePlaceholder).text(vis.provName); // $("#provinceName").textContent = vis.provName; // $("#provinceName").innerText = vis.provName; // $("#provinceName").innerHTML = vis.provName;...}以防萬(wàn)一,這里是所有代碼:https://github.com/SabahatPK/Data4Pakistan_SlopeGraphs 這是輸出: https: //data-driven-pakistan-data-stories.netlify.com/
為什么構(gòu)造函數(shù)沒(méi)有正確設(shè)置 <h6> 文本?
三國(guó)紛爭(zhēng)
2023-09-18 10:33:57