Index: arms/js/common/chart/eCharts/RadialPolarBarChart.js =================================================================== diff -u -rbb25676959dd44d369d5846ff74d5634dcedc9e1 -r715ee33587aaf85ad4c35369da876f9ed9fbaa43 --- arms/js/common/chart/eCharts/RadialPolarBarChart.js (.../RadialPolarBarChart.js) (revision bb25676959dd44d369d5846ff74d5634dcedc9e1) +++ arms/js/common/chart/eCharts/RadialPolarBarChart.js (.../RadialPolarBarChart.js) (revision 715ee33587aaf85ad4c35369da876f9ed9fbaa43) @@ -82,17 +82,24 @@ "rgba(166,86,40,0.7)" ]; + var colorSet = []; + if (!colorArr || colorArr.length < 1) { + colorSet = defaultColorSet; + } else { + colorSet = colorArr; + } + function calculateTotal(dataArr) { const total = dataArr.reduce((acc, curr) => acc + curr.value, 0); return total; } const totalValue = calculateTotal(dataArr); - console.log ("totalValue => " + totalValue); + var angleAxisArr = [], seriesDataArr=[]; if(dataArr.length > 0) { dataArr.forEach((element, idx) => { angleAxisArr.push(element["name"]); - seriesDataArr.push({value: element["value"], itemStyle: { color: colorArr ? colorArr[idx] : defaultColorSet[idx] }}); + seriesDataArr.push({value: element["value"], itemStyle: { color:colorSet[idx % colorSet.length] }}); }); } @@ -177,7 +184,7 @@ } }, animation: false - } + }; function replaceNaN(value) { if (isNaN(value)) { @@ -196,11 +203,11 @@ const chartFooter = document.createElement("div"); chartFooter.classList.add("chart-footer"); - dataArr.forEach((data,index) => { + dataArr.forEach((data,idx) => { const item = document.createElement("div"); const portion =replaceNaN(+(data.value*100/ +total).toFixed(0)); item.classList.add("footer-item"); - item.style.borderColor = colorArr[index]; + item.style.borderColor = colorSet[idx % colorSet.length]; item.innerHTML = `
${data.name}
${data.value} (${portion}%)
`; chartFooter.appendChild(item); });