How to change the dot point color and style in Morris.js line graph?
Asked Answered
M

2

6

I uses morris.js to draw line chart graph, but I can't figure out how to change just dot color and style in line chart. Does anyone know how to change just dot styles?

Thanks.

Maieutic answered 26/12, 2012 at 7:17 Comment(0)
E
14

Use the pointFillColors property. From the documentation:

pointFillColors Colors for the series points. By default uses the same values as lineColors

Here is the example of the chart with blue line and green dots:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="raphael-min.js"></script>
<script type="text/javascript" src="morris.min.js"></script>
<script type="text/javascript">
function drawChart() {
    Morris.Line({
        element: 'chart',
        data: [
            {y: '2012', a: 100},
            {y: '2011', a: 75},
            {y: '2010', a: 50},
            {y: '2009', a: 75},
            {y: '2008', a: 50},
            {y: '2007', a: 75},
            {y: '2006', a: 100}
        ],
        xkey: 'y',
        ykeys: ['a'],
        labels: ['Test series'],
        lineColors: ['#0b62a4'],
        pointFillColors: ['#00ff00']
    });
}

window.onload = drawChart;
</script>
<div id="chart" style="width: 400px; height: 250px;"></div>
Emblematize answered 26/12, 2012 at 22:23 Comment(0)
O
6

Instead of "lineColors", try "colors" like this:

function drawChart() {
Morris.Line({
    element: 'chart',
    data: [
        {y: '2012', a: 100},
        {y: '2011', a: 75},
        {y: '2010', a: 50},
        {y: '2009', a: 75},
        {y: '2008', a: 50},
        {y: '2007', a: 75},
        {y: '2006', a: 100}
    ],
    colors: ['#0b62a4','#D58665','#37619d','#fefefe','#A87D8E','#2D619C','#2D9C2F']
});

}

for every line there should be one color.

Oriflamme answered 6/3, 2013 at 18:13 Comment(2)
What if you have dynamic data that is not known for the time that colors are set?Feet
Then you can have an array of colours and dip in to that array to pull out a colourIranian

© 2022 - 2024 — McMap. All rights reserved.