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

kinakomochi picture kinakomochi · Dec 26, 2012 · Viewed 17.2k times · Source

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.

Answer

vortexwolf picture vortexwolf · Dec 26, 2012

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>