Proportion between Red, Green and Blue in custom color, represented in jqxBarGauge.
A live JavaScript/jQuery example of jqxBarGauge, the jQWidgets BarGauge component, with its complete source code below. It is one of 8 jqxBarGauge demos for jQuery.
colorScheme property – Sets the jqxBarGauge's color palette.customColorScheme property – Sets custom color palette in the BarGauge.endAngle propertyheight property – Sets or gets the BarGauge's height.labels property – This property is used to make fine settings on BarGauge labels at each segment.max property – Sets or gets the end value of BarGauge.min property – Sets or gets BarGauge's min.relativeInnerRadius property – Sets or gets the relativeInnerRadius of jqxBarGauge.startAngle property – Sets or gets the startAngle of the BarGauge.theme property – Sets the widget's theme.title property – Sets or gets the BarGauge's title.values property – Sets or gets array of values for the BarGauge.width property – Sets or gets the BarGauge's width.val method – Returns an array of the BarGauge values.To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $.
The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxdraw.js, jqxbargauge.js, jqxcolorpicker.js, jqxradiobutton.js, jqxdropdownbutton.js, jqxslider.js, jqxscrollview.js, jqxbuttons.js.
It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).
$(document).ready(function ()
{
var colorArray = [];
var rgbArray = [187, 255, 170];
var disabled = false;
var isRendered = false;
var isClosed = false;
$('#barGauge').jqxBarGauge({
width: getWidth('BarGauge'),
height: getHeight('BarGauge'),
values: rgbArray,
max: 255,
relativeInnerRadius: 0.5,
startAngle: 0,
endAngle: 90,
colorScheme: 'rgb',
customColorScheme: {
name: 'rgb',
colors: ['#307DD7', '#89A54E', '#AA4643']
},
title: {
text: 'jqxBarGauge',
font: {
size: 40
},
verticalAlignment: 'top',
margin: 0,
subtitle: {
text: '( visualization of "RGB" color proportions )',
font: {
size: 20
}
}
},
labels: { precision: 0, indent: 10 }
});
$('#redLevel').jqxSlider({theme: "arctic", mode: "fixed", min: 0, max: 255, ticksFrequency: 25.5, value: 170, step: 25.5 });
$('#greenLevel').jqxSlider({ theme: "arctic", mode: "fixed", min: 0, max: 255, ticksFrequency: 25.5, value: 255, step: 25.5 });
$('#blueLevel').jqxSlider({ theme: "arctic", mode: "fixed", min: 0, max: 255, ticksFrequency: 25.5, value: 187, step: 25.5 });
var setColor = function ()
{
var red = $('#redLevel').val();
var green = $('#greenLevel').val();
var blue = $('#blueLevel').val();
$('#barGauge').val(new Array(blue, green, red));
}
$('#redLevel').on('change', function (event)
{
setColor();
});
$('#greenLevel').on('change', function (event)
{
setColor();
});
$('#blueLevel').on('change', function (event)
{
setColor();
});
});
<div id="barGauge"></div>
<div style="float: left">
<span style="font-style: italic;">Red</span>
<div id="redLevel">
</div>
<span style="font-style: italic;">Green</span>
<div id="greenLevel">
</div>
<span style="font-style: italic;">Blue</span>
<div id="blueLevel">
</div>
</div>