2012-12-26 102 views

回答

12

使用pointFillColors财产。 来自文档:

pointFillColors系列点的颜色。默认情况下,使用作为lineColors相同的价值观

这里是蓝线和绿点的图表的例子:

<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> 
6

而不是“lineColors”,尝试“色彩” 这样的:

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'] 
}); 

}

,每行应该有一种颜色。

+0

如果您的动态数据在设置颜色时未知,该怎么办? –

+0

然后你可以有一个颜色数组,然后进入该数组来拉出颜色 –

相关问题