简体   繁体   中英

dc.legend in dc.js - Is it possible to add custom labels?

On this chart: http://junklogic.com/dcjs/barpie/index-controls.html

I have legends that correspond to a severity rating in my sample JSON file, that represents a file I will be using in production. Severity is "1", "2" & "3".

I would like to know if there is a way that I can label these "High" "Medium" and "Low". Unfortunately the job requirement won't allow me to add anything to the JSON file. I am hoping I can add a condition somehow. Thank you.

Links to files:

javascript: http://junklogic.com/dcjs/barpie/js/threatgraphs.js

json: http://junklogic.com/dcjs/barpie/data/dashdata.json

You can simply add these labels in your data preprocessing step:

data.forEach( function(d) {
        d.malwareName   = d.malware_name;
        d.endpoint      = d.endpoint;
        d.date          = dateFormat.parse(d.date);
        d.severity      = d.severity == 1 ? "high" : (d.severity == 2 ? "medium" : "low");
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM