改变莫里斯地区图表

时间:2015-06-11 03:14:53

标签: morris.js

我想自定义区域图表颜色,我该怎么办?

这是我的代码:

$.getJSON("http://10.30.6.69:1200/WebAPI.aspx/?api=RequestPostFiveMins", function (data4) {

    new Morris.Area({
        backgroundColor: '#ccc',
        labelColor: '#060',

        // ID of the element in which to draw the chart.
        element: 'POSTFIVEMINS',
        // Chart data records -- each entry in this array corresponds to a point on
        // the chart.
        data: data4,
        // The name of the data record attribute that contains x-values.
        xkey: 'Time',
        // A list of names of data record attributes that contain y-values.
        ykeys: ['Total', 'Success', 'Error'],
        // Labels for the ykeys -- will be displayed when you hover over the
        // chart.
        labels: ['Total', 'Success', 'Error'],
        parseTime: false,
        hideHover: 'auto',



}).progress(function () {
    $(document.getElementById("POSTFIVEMINSID").style.display = "");
}).done(function () {
    $(document.getElementById("POSTFIVEMINSID").style.display = "none");
});

1 个答案:

答案 0 :(得分:1)

尝试添加lineColors属性,该属性采用包含系列行/点颜色的数组:

new Morris.Area({
    // ...
    lineColors: ['#0B62A4', '#F79263', '#A7B3BC'],
    // ...
});