jqPlot, char names for Y-axis Ticks

char, jqplot, jquery

Solution

You can specify the ticks as `[val, label]` pairs. Note that they must be ordered properly.

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

Fiddle here.

Problem

This is my first asked-myself question on stackoverflow - a site that has helped me so many times already. Please be understanding :) I have problems with jqPlot that looks really simple, but its seems not to be. I want to give static char names in Y axis (ticks). Y-axis values comes from real height on the Y-axis. I would like to create names like: value 1, value 2, value 3, value 4, value 5... instead of (for example) 1.5, 3.0, 4.5, 7.0, 100.0... Is it possible with jqPlot configuration alone. I could not see option as such, but maybe there is one, and I will feel ashamed :). Thank you in advance for any help. (EDIT) Here is the FULL code I used: ``` 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', ] } }); ```

Original source