2016-06-02 26 views
0

xaxisに表示される目盛にy軸の値を設定したい(値だけを変更し、位置は変更しないでください)。以下x軸の目盛りラベルを変更する

https://jsfiddle.net/sonal215/337afs1h/1/

ではなく1、2は、x軸上に示されているJsFiddleは、iは10、5(それぞれのY軸値)は、X軸目盛りラベルに表示したいです。

私はそれをデバッグしようとしましたが、ティックの値を設定するライブラリにクラスjqplot-xaxis-tickがあります。

<div class="jqplot-axis jqplot-xaxis" style="position: absolute; width: 180px; height: 18px; left: 0px; bottom: 0px;"><div class="jqplot-xaxis-tick" style="position: absolute; left: 47px;">1</div><div class="jqplot-xaxis-tick" style="position: absolute; left: 127px;">2</div></div> 

私はライブラリの値を表示するロジックを変更することができます。 これを行う方法は他にありません。

あなたはそれらが作成された後jqplot-xaxis-tick divを操作し、それらをあなたのs1データ配列からy値を割り当てることができます

答えて

1

を助けてください。

$(document).ready(function() { 
    var s1 = [ 
    [1, 10], 
    [2, 5] 
    ]; 
    plot1 = $.jqplot('chart1', [s1], { 
    seriesColors: ["#EB2300", "#FFCC00"], 
    seriesDefaults: { 
     renderer: $.jqplot.BarRenderer, 
     rendererOptions: { 
     varyBarColor: true, 
     barWidth: 30, 
     barMargin: -30 
     }, 
     pointLabels: { 
     show: true 
     } 
    }, 
    grid: { 
     drawBorder: false 
    }, 
    axes: { 
     xaxis: { 
     renderer: $.jqplot.CategoryAxisRenderer 
     }, 
     yaxis: { 
     tickOptions: { 
      show: false 
     }, 
     rendererOptions: { 
      drawBaseline: false 
     } 
     } 
    } 
    }); 
//assign x values with y values// 
$('.jqplot-xaxis-tick').each(function(i,elem) { 
     $(this).text(s1[i][1]); 
    }); 
}); 

はあなたのフィドルでの作業例を参照してください:

https://jsfiddle.net/337afs1h/2/

+0

あなたのソリューションは、私のためのおかげで完全に正常に動作します。また、私は次のことを試みました - var s1 = [['10'、1]、['5'、5]];これも私の目的に役立ちます。再度、感謝します – sk215

関連する問題