jqplot を使用して、ページにグラフをプロットしています。複数の線をプロットしており、線を識別するのに役立つ凡例を表示する必要があります。
線の色が異なるため、凡例に表示される個々のラベルの色を設定する方法を見つける必要があります。
var plot3 = jQuery.jqplot('div1', [data1, data2, data3, data4],
{
// Series options are specified as an array of objects, one object
// for each series.
series:[
{
color: '#FF0000',
// Change our line width and use a diamond shaped marker.
lineWidth:2,
markerOptions: { style:'diamond' }
},
{
color: '#00FF00',
// Don't show a line, just show markers.
// Make the markers 7 pixels with an 'x' style
showLine:false,
markerOptions: { size: 7, style:"x" }
},
{
color: '#0000FF',
// Use (open) circular markers.
markerOptions: { style:"circle" }
},
{
color: '#F0000F',
// Use a thicker, 5 pixel line and 10 pixel
// filled square markers.
lineWidth:5,
markerOptions: { style:"filledSquare", size:10 }
}
],
legend:{
renderer: jQuery.jqplot.EnhancedLegendRenderer,
show: true,
labels: ['data1', 'data2', 'data3', 'data4']
}
}
[編集]
私は以前のコードを削除しました - それは赤いニシンだったからです。また、何日も苦労した後、問題を解決しようとしている新しい方法を反映するようにタイトルを変更しました。