Вы можете сделать это, используя опцию "transform" на yaxis.
См. Работу здесь .
$(function () {
// setup plot
function sampleFunction(x1, x2, func) {
var d = [ ];
var step = (x2-x1)/300;
for (var i = x1; i < x2; i += step )
d.push([i, func( i ) ]);
return d;
}
var options1 = {
lines: { show: true },
xaxis: { ticks: 4 },
yaxis: { ticks: [0.001,0.01,0.1,1,10,100],
transform: function(v) {return Math.log(v+0.0001); /*move away from zero*/},
tickDecimals: 3 },
grid: { hoverable: true, clickable: true, color: "#999" }
};
var data1 = sampleFunction( 0, 5, function(x){ return Math.exp(x)*Math.sin(x)*Math.sin(x) } );
var plot1 = $.plot($("#chart1"), [ { label: "exp(x)sin(x)^2", data: data1 } ], options1);
});
Полный рабочий код:
$(function () {
// setup plot
function sampleFunction(x1, x2, func) {
var d = [ ];
var step = (x2-x1)/300;
for (var i = x1; i < x2; i += step )
d.push([i, func( i ) ]);
return d;
}
var options1 = {
lines: { show: true },
xaxis: { ticks: 4 },
yaxis: { ticks: [0.001,0.01,0.1,1,10,100],
transform: function(v) {return Math.log(v+0.0001); /*move away from zero*/} , tickDecimals: 3 },
grid: { hoverable: true, clickable: true , color: "#999"}
};
var data1 = sampleFunction( 0, 5, function(x){ return Math.exp(x)*Math.sin(x)*Math.sin(x) } );
var plot1 = $.plot($("#chart1"), [ { label: "exp(x)sin(x)^2", data: data1} ], options1);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.min.js"></script>
<br/><br/>
<div id="chart1" style="width:600px;height:300px;"></div>