问题
I want to scale the y axis like following image
But i have the graph like following
I want to implement the y axis scaling like the first figure.I want to show the values between .09 and 1 in a large scale. also i want to show the pf value range as 0 to 1( 0 as minimum and 1 as maximum.)
Any idea?
My tried code is HERE
$.jqplot.config.enablePlugins = true;
var chartData = [[1, .92], [2,.93], [3, .98],[4,.95]];
function PlotChart(chartData) {
var plot2 = $.jqplot('chart1', [chartData], {
title: '',
seriesDefaults: {
renderer: $.jqplot.CanvasAxisLabelRenderer,
rendererOptions: {
smooth: true
},
pointLabels: {
show: true
}
},
axes: {
xaxis: {
label: 'date',
ticks : [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10','11', '12', '13', '14'],
renderer: $.jqplot.CategoryAxisRenderer,
// renderer to use to draw the axis,
tickOptions: {
formatString: '%d'
}
},
yaxis: {
ticks:[ '0', '.5','.9', '1' ],
label: 'PF',
tickOptions: {
formatString: '%.2f'
}
}
},
highlighter: {
sizeAdjust: 7.5
},
cursor: {
show: true
}
});
}
PlotChart(chartData);
回答1:
I think jqplot won't permit to do something like you want to do, I know it's very strict about working on axes (I was trying to show on tooltips the full value with decimals even when the scale was too big to show decimals).
What you can do is resizing the interval, try with min and max:
yaxis: {
ticks:[ '.9', '1' ],
label: 'PF',
tickOptions: {
formatString: '%.2f'
}
min: 0.8,
max: 1.1
}
With that interval jqplot will render your graph showing perfectly the lines.
来源:https://stackoverflow.com/questions/20851806/jqplot-y-axis-scaling