Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change element size of lib jquery.knob.js

i have a page

after you press button, you see element of lib jquery.knob.js(circle) i want ot change circle size and i wrote this code:

<div style="float:left; width:255px; height:155px">
            <input class="knob" data-fgColor="#9dc806" data-cgColor="black" data-bgColor="#7d7d7d" data-tickColor="black" data-thickness=".25" data-readOnly=true value="<?php echo $percent; ?>">
        </div>

but if i change width and height of div, circle size don't changed?

All code page of pb.php:

<?php
header('Content-Type: text/html; charset=utf-8');
include '../connect.php';
include '../ProcessingMySQL.php';
$mysqli = new ProcessingMySQL($hostname, $user_name, $password, $db_name);
$site = $_POST['sites'];
$percent = $mysqli->getPercentTopQuery($site);
?>

<html>
    <head>
    <style type="text/css">
        .knob{color:#000000 !important;}
    </style>

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
        <script src="js/jquery.knob.js"></script>
        <script>
            $(function() {
                $(".knob").knob();
                var val,up=0,down=0,i=0
                    ,$idir = $("div.idir")
                    ,$ival = $("div.ival")
                    ,incr = function() { i++; $idir.show().html("+").fadeOut(); $ival.html(i); }
                    ,decr = function() { i--; $idir.show().html("-").fadeOut(); $ival.html(i); };
                $("input.infinite").knob(
                                    {
                                    'min':0
                                    ,'max':20
                                    ,'stopper':false
                                    ,'change':function(v){
                                                if(val>v){
                                                    if(up){
                                                        decr();
                                                        up=0;
                                                    }else{up=1;down=0;}
                                                }else{
                                                    if(down){
                                                        incr();
                                                        down=0;
                                                    }else{down=1;up=0;}
                                                }
                                                val=v;
                                            }
                                    }
                                );     
                                $('.knob').val($('.knob').val() + '%');     
             });
        </script>
        <style>
            h2{color:#87CEEB;font-family:'Georgia';}
        </style>
    </head>
    <body>
        <h1>Процент запросов в топе для сайта <?php echo $site; ?></h1>
        <div style="float:left; width:255px; height:155px">
            <input class="knob" data-fgColor="#9dc806" data-cgColor="black" data-bgColor="#7d7d7d" data-tickColor="black" data-thickness=".25" data-readOnly=true value="<?php echo $percent; ?>">
        </div>

    </body>
</html>
like image 955
Ilya Z. Avatar asked Nov 13 '22 15:11

Ilya Z.


1 Answers

<div style="float:left; width:255px; height:155px">
            <input class="knob" data-fgColor="#9dc806" data-cgColor="black" data-bgColor="#7d7d7d" data-tickColor="black" data-thickness=".25" data-readOnly=true data-width="255" value="<?php echo $percent; ?>">
        </div>

Try to add data-width="width_of_circle" attribute to your input.knob. As far as I can see, that is how you can control width of a circle. Like in code above (width is set to 255)

like image 136
Viktor S. Avatar answered Nov 15 '22 06:11

Viktor S.