(jqplot) How to show a small grid in the log scale graph?

I have jqplot with the axis of the log scale, which looks like this:

my log graph

And here is my x and y axis setup for my jqplot:

            axes : {
            xaxis : {
                renderer : $j.jqplot.LogAxisRenderer,
                ticks : [0.1, 1, 10, 100],
            },
            yaxis : {
                renderer : $j.jqplot.LogAxisRenderer,           
                ticks : [0.1, 1, 10, 100],
            },
        }

But I would like to show small grids that look exactly like this:

log graph I want

How can i do this?

+4
source share
2 answers
max = 100;
min = 1;

// calculate the power of 10 of max value
var dcmMax = Math.floor(Math.log(max)/Math.log(10));

// calculate the power of 10 of min value
var dcmMin = Math.floor(Math.log(min)/Math.log(10));

var ticks = [];
var tick, f;

for (var i = dcmMin ; i <= dcmMax ; i++){

    tick = Math.floor(Math.log(i)/Math.log(10));

    if (i == dcmMin){
       ticks.push(tick.toFixed(1));
    }

    f = tick;

    for (var j = 0; j < 8; j++){
        tick = tick + f;
        ticks.push(myTick(tick.toFixed(1)));
    }

    if (i == dcmMax){
        ticks.push(tick.toFixed(1));
    }
}

function myTick(value){
return {value:value, showLabel:false, showMark:false};
}

this will create the main ticks from 1.0, 10.0, 100.0, 1000.0 and show only the grid without minor ticks, since the corresponding showLabel and showMark are set to false

+3
source

Any answer better than mine?

    majorTicks = [      
                    1,
                    {value:2, showLabel:false, showMark:false},
                    {value:3, showLabel:false, showMark:false},
                    {value:4, showLabel:false, showMark:false},
                    {value:5, showLabel:false, showMark:false},
                    {value:6, showLabel:false, showMark:false},
                    {value:7, showLabel:false, showMark:false},
                    {value:8, showLabel:false, showMark:false},
                    {value:9, showLabel:false, showMark:false},
                    10,
                    {value:20, showLabel:false, showMark:false},
                    {value:30, showLabel:false, showMark:false},    
                    {value:40, showLabel:false, showMark:false},    
                    {value:50, showLabel:false, showMark:false},    
                    {value:60, showLabel:false, showMark:false},    
                    {value:70, showLabel:false, showMark:false},    
                    {value:80, showLabel:false, showMark:false},
                    {value:90, showLabel:false, showMark:false},    
                    100
                ];
+1
source

Source: https://habr.com/ru/post/1536059/


All Articles