jqPlot,Y轴Ticks的char名称

时间:2012-10-13 12:37:40

标签: jquery char jqplot

这是我第一次问自己关于stackoverflow的问题 - 这个网站已经帮了很多次了。请理解:)

我遇到的jqPlot问题看起来很简单,但似乎不是。

我想在Y轴(刻度线)中给出静态字符名称。 Y轴值来自Y轴上的实际高度。我想创建名称,如:值1,值2,值3,值4,值5 ...而不是(例如)1.5,3.0,4.5,7.0,100.0 ......

是否可以单独使用jqPlot配置。我不能看到这样的选项,但也许有一个,我会感到惭愧:)。

提前感谢您的帮助。

(编辑)以下是我使用的完整代码:

var plot2 = $.jqplot('chart2', [line_oczekiwana_srednia, line_sd_plus_1, line_sd_plus_2, line_sd_plus_3, line_sd_plus_4, line_sd_minus_1, line_sd_minus_2, line_sd_minus_3, line_sd_minus_4, line1, line_WEST4, ], {
    animate: true,
    title:'OLYMPUS LEVEL 1 0029 : Kontrola biochemii. Typ materiału: Surowica', 
    axes:{
      xaxis:{
        renderer:$.jqplot.DateAxisRenderer,
        tickOptions:{ 
          formatString:'%#d-%m-%y %#H:%M',
          angle: -30,
        },
        tickRenderer:$.jqplot.CanvasAxisTickRenderer,
        label:'Zakres czasu kontroli', 
        labelOptions:{
          fontFamily:'Helvetica',
          fontSize: '14pt'
        },
        labelRenderer: $.jqplot.CanvasAxisLabelRenderer
      },           
      yaxis:{
        numberTicks: 9,
        ticks:[3.6284,3.6863,3.7442,3.8021,3.8600,3.9179,3.9758,4.0337,4.0916],
        renderer:$.jqplot.LogAxisRenderer,
        tickOptions:{
          showGridline: false,
          **formatString:'SDx:%.1f',**
          labelPosition: 'middle', 
          angle:-0,
        },
        tickRenderer:$.jqplot.CanvasAxisTickRenderer,
        labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
        labelOptions:{
            fontFamily:'Helvetica',
            fontSize: '14pt'
        },
        label:'Wartości (mmol/l)'
      },        
    },
    highlighter: {
      show: true,
      sizeAdjust: 12.5,
    },
    cursor: {
      show: true,
      zoom:true,
      dblClickReset:true,
      tooltipLocation:'sw'
    },        
    series:[
      {lineWidth:1, color: '#76a4e8', showMarker: false},
      {lineWidth:1, color: '#d8d8d8', showMarker: false},
      {lineWidth:1, color: '#d8d8d8', showMarker: false},
      {lineWidth:1, color: '#d8d8d8', showMarker: false},
      {lineWidth:1, color: '#d8d8d8', showMarker: false},
      {lineWidth:1, color: '#d8d8d8', showMarker: false},
      {lineWidth:1, color: '#d8d8d8', showMarker: false},
      {lineWidth:1, color: '#d8d8d8', showMarker: false},                                                            
      {lineWidth:1, color: '#d8d8d8', showMarker: false},
      {lineWidth:2, color: '#f4ad31', rendererOptions: {animation: {speed: 1500}}, markerOptions:{color: 'gray', style:'filledSquare'}},
      {showLine: false, color: 'red', markerOptions:{color: 'red', style:'filledSquare'}},
    ],
    legend:{
       renderer: jQuery.jqplot.EnhancedLegendRenderer,
       show: true,
       hideZeros: true,
       location: 'se',
       labels: ['Oczekiwana średnia (3.8600)', 'SD+1 (3.9179)', 'SD+2 (3.9758)', 'SD+3 (4.0337)', 'SD+4 (4.0916)', 'SD-1 (3.8021)', 'SD-2 (3.7442)', 'SD-3 (3.6863)', 'SD-4 (3.6284)', 'Wyniki kontroli (3.6284)', 'Reguła WEST4', ]
    }        

});

1 个答案:

答案 0 :(得分:8)

您可以将刻度线指定为[val, label]对。请注意,必须正确订购。

$(document).ready(function(){
    var plot1 = $.jqplot ('chart1', [[3,7,1,4,6]],{
           axes: {
                yaxis: {
                    ticks: [[1,'-SD1'],[3,'-SD4'],[4,'MEAN'],[6,'SD1'],[7,'-SD3']]
                }
           }});
});​

enter image description here

小提琴here