Documentation
Getting Started
jqxKnob represents a jQuery plugin with round shape which displays a draggable indicator within a range of values. Knob can be used in a table or matrix to show the relative value of a field in a range of values in the data region, for example, as a KPI. It supports HTML5, SVG and VML rendering.Every UI widget from jQWidgets toolkit needs its JavaScript files to be included in order to work properly.
The first step is to create html page and add links to the javascript files and css dependencies to your project. The jqxKnob widget requires the following files:
<head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdraw.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxknob.js"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=G-2FX5PV9DNT"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-2FX5PV9DNT');</script></head>
The next step is to create html element within the body of the html document.
<div id='knob'></div>
The last step is to initialize the widget by adding the following script to the html document:
<script type="text/javascript"> $(document).ready(function () { $("#knob").jqxKnob(); });</script>
To call a function(method), you need to pass the method name and parameters(if any) in the jqxKnob’s constructor.
To get the result of a function after calling it, you can use the following syntax:$("#jqxKnob").jqxKnob('refresh');
To set a property(option), you need to pass the property name and value(s) in the jqxKnob's constructor.var value = $("#jqxKnob").jqxKnob('val');
To get a property(option), you need to pass the property name to the jqxKnob's constructor.$("#jqxKnob").jqxKnob({ allowValueChangeOnClick: false });
To bind to an event of a UI widget, you can use basic jQuery syntax. Let’s suppose that you want to get the selected date after the user clicks on a cell. The example code below demonstrates how to bind to the ‘valuechanged’ event of jqxKnob.var allowValueChangeOnClick = $("#jqxKnob").jqxKnob('allowValueChangeOnClick');
$('#jqxKnob').on('change', function (event) {});
Basic Sample
<!DOCTYPE html><html lang="en"><head> <title id='Description'>jQuery Knob widget</title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdraw.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxknob.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxnumberinput.js"></script> <style type="text/css"> #container { position: relative; } .inputField { left: 110px; top: 323px; position: absolute; background: transparent; border: none; } text.jqx-knob-label { font-size: 20px; } .inputField .jqx-input-content { background: transparent; font-size: 20px; color: grey; } </style> <script type="text/javascript"> $(document).ready(function () { $('#container').jqxKnob({ value: 60, min: 0, max: 100, startAngle: 120, endAngle: 420, snapToStep: true, rotation: 'clockwise', style: { stroke: '#dfe3e9', strokeWidth: 3, fill: { color: '#fefefe', gradientType: "linear", gradientStops: [[0, 1], [50, 0.9], [100, 1]] } }, marks: { colorRemaining: { color: 'grey', border: 'grey' }, colorProgress: { color: '#00a4e1', border: '#00a4e1' }, type: 'line', offset: '71%', thickness: 3, size: '6%', majorSize: '9%', majorInterval: 10, minorInterval: 2 }, labels: { offset: '88%', step: 10, visible: true }, progressBar: { style: { fill: '#00a4e1', stroke: 'grey' }, size: '9%', offset: '60%', background: { fill: 'grey', stroke: 'grey' } }, pointer: { type: 'arrow', style: { fill: '#00a4e1', stroke: 'grey' }, size: '59%', offset: '49%', thickness: 20 } }); var input = $('<div class="inputField">'); $('#container').append(input); var inputOptions = { width: 180, height: '40px', decimal: 60, // starting value same as widget min: 0, // same as widget max: 100, // same as widget textAlign: 'center', decimalDigits: 1, inputMode: 'simple' }; $(input).jqxNumberInput(inputOptions); $(input).on('mousedown', function (event) { event.stopPropagation(); }); $(input).on('keyup', function () { var val = $(this).val(); $('#container').val(val); }); $(input).on('change', function () { var val = $(this).val(); $('#container').val(val); }); $('#container').on('change', function (event) { if (event.args.changeSource == 'propertyChange' || event.args.changeSource == 'val') { return; } $(input).val(event.args.value); }) }); </script><script async src="https://www.googletagmanager.com/gtag/js?id=G-2FX5PV9DNT"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-2FX5PV9DNT');</script></head><body class='default'> <div id='container' style="width: 400px; height: 400px;"> </div></body></html>