简体   繁体   中英

How to add color under a single line graph with Morris.js

I am currently using Morris.js to draw graphs for an Android application. I pass in data that contains points for 1 single line. Donations and Dates. I am trying to add color to the bottom side of the line graph but cannot figure out how to do it.

这是我要复制的样式

This is the style I am trying to replicate.

在此处输入图片说明

But under a single line.

I have edited the Morris.js code and also passed in as many different options to Morris.Line but to no avail. This is currently the code I am using to setup the graph. I thought the 'fillOpacity' option would work but it hasn't. Is there an option that I am missing? Or is there a duplicate answer to this I have passed over?

    var xKey = "day"
    var yKey = 'funds'
    var jsonData

    var graph = Morris.Line({
            element: 'graph',
            data: jsonData,
            xkey: xKey,
            ykeys: [yKey],
            labels: ['funds gathered'],
            smooth: true,
            resize: true,
            parseTime: true,
            grid: false,
            fillOpacity: true
        });

    function setGraph(data) {
        graph.setData(data);
    }

Ok so the issue was that in the above example I am trying to instantiate a Morris.Line where actually what I want is a Morris.Area.

<script>
    var xKey = "day"
    var yKey = 'funds'
    var jsonData

    var graph = Morris.Area({
            element: 'graph',
            data: jsonData,
            xkey: xKey,
            ykeys: [yKey],
            labels: ['funds gathered'],
            smooth: true,
            resize: true,
            parseTime: true,
            grid: false
        });

    function setGraph(data) {
        graph.setData(data);
    }
</script>

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