- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我用 Angular 制作了一个森伯斯特 Highcharts 。对于第一级,我直接计算所有其他级别的总和,对于第三级,我使用了 point.value
,它也是 passAssetCnt/totalAssetCnt * 100
但对于第二级,这样就不行了。
这是我的格式化函数。我的目标是计算百分比,如果它们具有相同的 reqnum
,则为 passAssetCnt/totalAssetCnt * 100
。
一切都很好,直到我做出将绘制百分比的返回声明而且一切都归零。
我尝试在格式化程序函数中调用一个单独的函数,该函数将完成所有这些操作,但也没有被调用。
var data = [{"id":"CSA-CCM","parent":"","name":"CSA-CCM"},{"id":"Application & Interface Security","parent":"CSA-CCM","name":"Application & Interface Security","complianceId":4,"inclusionId":1,"passAssetCnt":821,"totalAssetCnt":1198,"layer":"second","reqnum":1},{"id":"Audit Assurance & Compliance\r\n","parent":"CSA-CCM","name":"Audit Assurance & Compliance\r\n","complianceId":4,"inclusionId":13,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":2},{"id":"Business Continuity & Operational Resilience","parent":"CSA-CCM","name":"Business Continuity & Operational Resilience","complianceId":4,"inclusionId":1,"passAssetCnt":2,"totalAssetCnt":279,"layer":"second","reqnum":3},{"id":"Change Control & Configuration Management\r\n","parent":"CSA-CCM","name":"Change Control & Configuration Management\r\n","complianceId":4,"inclusionId":1,"passAssetCnt":7,"totalAssetCnt":10,"layer":"second","reqnum":4},{"id":"Data Security & Information Lifecycle ","parent":"CSA-CCM","name":"Data Security & Information Lifecycle ","complianceId":4,"inclusionId":13,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":5},{"id":"Datacenter Security","parent":"CSA-CCM","name":"Datacenter Security","complianceId":4,"inclusionId":13,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":6},{"id":"Encryption & Key Management","parent":"CSA-CCM","name":"Encryption & Key Management","complianceId":4,"inclusionId":1,"passAssetCnt":9,"totalAssetCnt":36,"layer":"second","reqnum":7},{"id":"Governance and Risk Management\r\n","parent":"CSA-CCM","name":"Governance and Risk Management\r\n","complianceId":4,"inclusionId":13,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":8},{"id":"Human Resources","parent":"CSA-CCM","name":"Human Resources","complianceId":4,"inclusionId":1,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":9},{"id":"Identity & Access Management\r\n","parent":"CSA-CCM","name":"Identity & Access Management\r\n","complianceId":4,"inclusionId":1,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":10},{"id":"Infrastructure & Virtualization Security","parent":"CSA-CCM","name":"Infrastructure & Virtualization Security","complianceId":4,"inclusionId":13,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":11},{"id":"Supply Chain Management, Transparency, and Accountability\r\n","parent":"CSA-CCM","name":"Supply Chain Management, Transparency, and Accountability\r\n","complianceId":4,"inclusionId":1,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":14},{"id":"Threat and Vulnerability Management","parent":"CSA-CCM","name":"Threat and Vulnerability Management","complianceId":4,"inclusionId":3,"passAssetCnt":0,"totalAssetCnt":1,"layer":"second","reqnum":15},{"id":"AIS-01","parent":"Application & Interface Security","name":"AIS-01","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":1},{"id":"AIS-02","parent":"Application & Interface Security","name":"AIS-02","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":1},{"id":"AIS-03","parent":"Application & Interface Security","name":"AIS-03","value":28,"passAssetCnt":37,"totalAssetCnt":130,"layer":"third","reqnum":1},{"id":"AIS-04","parent":"Application & Interface Security","name":"AIS-04","value":69,"passAssetCnt":821,"totalAssetCnt":1198,"layer":"third","reqnum":1},{"id":"AAC-01","parent":"Audit Assurance & Compliance\r\n","name":"AAC-01","value":100,"passAssetCnt":1,"totalAssetCnt":1,"layer":"third","reqnum":2},{"id":"AAC-02","parent":"Audit Assurance & Compliance\r\n","name":"AAC-02","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":2},{"id":"AAC-03","parent":"Audit Assurance & Compliance\r\n","name":"AAC-03","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":2},{"id":"BCR-07","parent":"Business Continuity & Operational Resilience","name":"BCR-07","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":3},{"id":"BCR-09","parent":"Business Continuity & Operational Resilience","name":"BCR-09","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":3},{"id":"BCR-11","parent":"Business Continuity & Operational Resilience","name":"BCR-11","value":1,"passAssetCnt":2,"totalAssetCnt":279,"layer":"third","reqnum":3},{"id":"CCC-04","parent":"Change Control & Configuration Management\r\n","name":"CCC-04","value":70,"passAssetCnt":7,"totalAssetCnt":10,"layer":"third","reqnum":4},{"id":"DSI-01","parent":"Data Security & Information Lifecycle ","name":"DSI-01","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":5},{"id":"DSI-03","parent":"Data Security & Information Lifecycle ","name":"DSI-03","value":0,"passAssetCnt":0,"totalAssetCnt":4,"layer":"third","reqnum":5},{"id":"DSI-05","parent":"Data Security & Information Lifecycle ","name":"DSI-05","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":5},{"id":"DSI-06","parent":"Data Security & Information Lifecycle ","name":"DSI-06","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":5},{"id":"DSI-07","parent":"Data Security & Information Lifecycle ","name":"DSI-07","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":5},{"id":"DCS-01","parent":"Datacenter Security","name":"DCS-01","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"DCS-02","parent":"Datacenter Security","name":"DCS-02","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"DCS-03","parent":"Datacenter Security","name":"DCS-03","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"DCS-04","parent":"Datacenter Security","name":"DCS-04","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"DCS-05","parent":"Datacenter Security","name":"DCS-05","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"DCS-06","parent":"Datacenter Security","name":"DCS-06","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"DCS-07","parent":"Datacenter Security","name":"DCS-07","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"DCS-08","parent":"Datacenter Security","name":"DCS-08","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"DCS-09","parent":"Datacenter Security","name":"DCS-09","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":6},{"id":"EKM-01","parent":"Encryption & Key Management","name":"EKM-01","value":51,"passAssetCnt":34,"totalAssetCnt":67,"layer":"third","reqnum":7},{"id":"EKM-02","parent":"Encryption & Key Management","name":"EKM-02","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":7},{"id":"EKM-03","parent":"Encryption & Key Management","name":"EKM-03","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":7},{"id":"EKM-04","parent":"Encryption & Key Management","name":"EKM-04","value":25,"passAssetCnt":9,"totalAssetCnt":36,"layer":"third","reqnum":7},{"id":"GRM-03","parent":"Governance and Risk Management\r\n","name":"GRM-03","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":8},{"id":"GRM-04","parent":"Governance and Risk Management\r\n","name":"GRM-04","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":8},{"id":"GRM-05","parent":"Governance and Risk Management\r\n","name":"GRM-05","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":8},{"id":"GRM-07","parent":"Governance and Risk Management\r\n","name":"GRM-07","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":8},{"id":"GRM-08","parent":"Governance and Risk Management\r\n","name":"GRM-08","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":8},{"id":"GRM-09","parent":"Governance and Risk Management\r\n","name":"GRM-09","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":8},{"id":"GRM-10","parent":"Governance and Risk Management\r\n","name":"GRM-10","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":8},{"id":"HRS-01","parent":"Human Resources","name":"HRS-01","value":55,"passAssetCnt":40,"totalAssetCnt":73,"layer":"third","reqnum":9},{"id":"HRS-07","parent":"Human Resources","name":"HRS-07","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":9},{"id":"HRS-08","parent":"Human Resources","name":"HRS-08","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":9},{"id":"HRS-11","parent":"Human Resources","name":"HRS-11","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":9},{"id":"IAM-01","parent":"Identity & Access Management\r\n","name":"IAM-01","value":41,"passAssetCnt":14,"totalAssetCnt":34,"layer":"third","reqnum":10},{"id":"IAM-02","parent":"Identity & Access Management\r\n","name":"IAM-02","value":63,"passAssetCnt":24,"totalAssetCnt":38,"layer":"third","reqnum":10},{"id":"IAM-03","parent":"Identity & Access Management\r\n","name":"IAM-03","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":10},{"id":"IAM-04","parent":"Identity & Access Management\r\n","name":"IAM-04","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":10},{"id":"IAM-05","parent":"Identity & Access Management\r\n","name":"IAM-05","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":10},{"id":"IAM-08","parent":"Identity & Access Management\r\n","name":"IAM-08","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":10},{"id":"IAM-11","parent":"Identity & Access Management\r\n","name":"IAM-11","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":10},{"id":"ISV-01","parent":"Infrastructure & Virtualization Security","name":"ISV-01","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":11},{"id":"ISV-02","parent":"Infrastructure & Virtualization Security","name":"ISV-02","value":44,"passAssetCnt":121,"totalAssetCnt":274,"layer":"third","reqnum":11},{"id":"ISV-04","parent":"Infrastructure & Virtualization Security","name":"ISV-04","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":11},{"id":"ISV-05","parent":"Infrastructure & Virtualization Security","name":"ISV-05","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":11},{"id":"ISV-06","parent":"Infrastructure & Virtualization Security","name":"ISV-06","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":11},{"id":"ISV-07","parent":"Infrastructure & Virtualization Security","name":"ISV-07","value":100,"passAssetCnt":1,"totalAssetCnt":1,"layer":"third","reqnum":11},{"id":"ISV-08","parent":"Infrastructure & Virtualization Security","name":"ISV-08","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":11},{"id":"ISV-12","parent":"Infrastructure & Virtualization Security","name":"ISV-12","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":11},{"id":"STA-01","parent":"Supply Chain Management, Transparency, and Accountability\r\n","name":"STA-01","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":14},{"id":"TEV-01","parent":"Threat and Vulnerability Management","name":"TEV-01","value":100,"passAssetCnt":1,"totalAssetCnt":1,"layer":"third","reqnum":15},{"id":"TEV-02","parent":"Threat and Vulnerability Management","name":"TEV-02","value":0,"passAssetCnt":0,"totalAssetCnt":1,"layer":"third","reqnum":15}];
formatter: function(data) {
let modifiedData = this.data.filter(
val => {
return val.layer == 'third';
}
);
// let modified = [];
for (let i = 0; i < modifiedData.length; i++) {
const modified = modifiedData.filter(val => {
return val.reqnum == modifiedData[i].reqnum;
});
const passAssetCnt = modified.reduce(
(prev, cur) => prev + cur.passAssetCnt,
0
);
console.log(passAssetCnt);
const totalAssetCnt = modified.reduce(
(prev, cur) => prev + cur.totalAssetCnt,
0
);
console.log(totalAssetCnt);
// console.log((passAssetCnt / totalAssetCnt) * 100);
const percent = (passAssetCnt / totalAssetCnt) * 100;
console.log(percent);
// return this.point.name + '<br>' + Math.round(percent) + '%';
}
}
最佳答案
终于能够通过重新创建数组然后再次与每个点进行比较来解决这个问题。
var res = this.point.series.userOptions.data.reduce((acc, obj)=>{
var existItem = acc.find(item => item.reqnum === obj.reqnum);
if(existItem){
existItem.passAssetCnt += obj.passAssetCnt;
existItem.totalAssetCnt += obj.totalAssetCnt;
return acc;
}
acc.push(obj);
return acc;
}, []);
var j;
for (j = 0; j < res.length; j++) {
if(res[j].name == this.point.name) {
console.log(this.point.name + '<br>' + Math.round(res[j].passAssetCnt/res[j].totalAssetCnt*100) + '%');
return this.point.name + '<br>' + Math.round(res[j].passAssetCnt/res[j].totalAssetCnt*100) + '%';
}
}
关于javascript - highchart 旭日百分比,不是相对百分比,而是取决于其他属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53468244/
如何将导出模块包含到 angular2 应用程序中? 我尝试将以下脚本添加到 index.html 但没有任何反应。 最佳答案 从 Angular CLI 1.0-RC.1 和最新的 angular
我正在为 Web 应用程序使用 HighCharts Javascript 库。当我下载 Highchart 时,我需要 Highchart 水印图像。 我正在使用普通的 hicgchart 代码。
我是 highcharts 的新手。默认情况下,Highchart 在图表本身内显示工具提示。这是否可以在图表外部显示工具提示,并显示在与内部显示相同的位置。有帮助吗? 最佳答案 您可以定义自己的 d
我正在尝试使用日期时间格式的数据创建 highcharts 热图。数据以小时为单位,持续数天。我不希望图表每天都环绕,但希望所有数据都在一条线上。 具体来说,它用于显示每小时的云量百分比,因此每个热图
我正在用 angular 中的简单图形来验证 highcharts。但是导出按钮不显示。我在 html 页面中添加脚本: 并在图表中添加属性: export :true, navigat
我很想知道为什么按钮 2 在这个 example 中不起作用 在这个 jsfiddle 示例中,附加到按钮 1 的“更新”方法正在运行,但在我的原始代码中,“更新”也不起作用。它显示错误:“对象# 没
我正在尝试在 highcharts 中编辑工具提示的边框。 我遇到的问题是我只想显示底部边框。 例如,您可以执行以下操作: tooltip: {borderWidth: 10}//但问题是在整个工具提
Highcharts的十字线可以显示在面积图的顶部而不是隐藏在其下方吗? 这是问题jsfiddle.net/hHjZb/1286/的示例 最佳答案 更新: Highcharts现在已经实现了the O
在将图表导出为PNG时,我试图在饼图上添加图例。 这是我的代码: var chart_23_106; $(document).ready(function () { chart_23_106 = ne
带三角规的半圆饼 如何在图表顶部创建带有三角形仪表的上述半圆饼图。 我的车速表可以工作,但不能满足需要。 在highchart api中有没有办法使用三角形作为仪表,而不是车速表? 谢谢 最佳答案 这
我们使用的是Highchart气泡图,但是,当气泡x和y在图中位于同一位置且气泡y较小时,将无法看到或单击得很少的气泡。 有什么方法可以先绘制较大的气泡,然后在顶部绘制较小的气泡?还是说较小的始终位于
是否可以使用百分比设置 Highcharts 的宽度?每当调整页面大小时,图表应具有足够的响应速度以适合页面大小吗? One Solution 这里的问题是我有3个图表需要并排显示,每次调整页面大小时
我在更新基本列 Highcharts 时遇到问题。 我从服务器返回的 json 数组是: [{"name":"positive","data":[18,35,32,38]},{"name":"nega
有没有办法创建重叠的列? 例如在 this jsFiddle ,蓝色和红色列应如下所示相互重叠,蓝色在后面,红色在前面。 澄清一下,我不想要堆叠的列,蓝色和红色列都应该从 xAxis (y=0) 开始
如何自定义图例 从 对此 最佳答案 查看 Highcharts legend api 选项。您可以使用所需的 css 进一步自定义。使用适当的 svg 图像(背景颜色取自图表本身) legend: {
我正在尝试使用模式作为列范围以允许条形图工作。 图案出现但不使用预定义的图案,所以它只是纯蓝色。通常它使用已定义的条纹图案,并在散点图等上完美运行。 这是一个片段,展示了我的意思: Highchar
我正在使用 HighStock JS 库生成一个图表,该图表使用 xAxis 的线性序列(不是时间序列)。 我仍然想使用范围选择器来缩放到我的线性系列中的预定范围。这可能吗? 例如;说我的 xAxis
我需要从一个系列向下钻取到多个系列。但是下钻 id 在一个系列上似乎是唯一的,这意味着我无法从单个系列下钻到多个系列;只有一个。我该如何解决这个问题? 最佳答案 可以使用 chart.addSingl
我制作了一个带有分组和堆叠列的Highcharts图表,就像在这里的示例http://www.highcharts.com/demo/column-stacked-and-grouped一样。该示例显
如何在 highcharts/highstock 中将滚动条位置设置为Left? 如图表加载时的图像所示, 滚动条自动右对齐。 有没有办法将它定位到左侧? 最佳答案 我们可以通过将 min 设置为 0
我是一名优秀的程序员,十分优秀!