1

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

[編集]

私は以前のコードを削除しました - それは赤いニシンだったからです。また、何日も苦労した後、問題を解決しようとしている新しい方法を反映するようにタイトルを変更しました。

4

2 に答える 2

5

凡例の後に、次のように追加してください。

legend: {show: true } , 
series:[{label:'BANANA'}, {label:'ORANGE'}  ],  

これにより、凡例の名前が付けられます。

于 2011-06-14T22:36:48.097 に答える
0

seriesColors次のように使用して、シリーズと凡例の色を設定できます。

var plot1 = $.jqplot('chart', [data1, data2], {
legend: {
    show: true
},
seriesColors: ['red', 'blue']
});
于 2016-09-29T10:04:23.197 に答える