|
Move the slider to change start angle: |
Move the slider to change end angle: |
|
Move the slider to rotate: |
Move the slider to change the radius: |
|
Tick marks between values
|
Auto rotate axis text
|
JavaScript Partial Polar Chart example.
A live JavaScript/jQuery example of jqxChart, the jQWidgets Chart component, with its complete source code below. It is one of 92 jqxChart demos for jQuery.
title property – Sets or gets the jqxChart title.description property – Sets or gets the jqxChart description.source property – Sets the chart's data source.showLegend property – Determines whether to show or hide the chart series legend.padding propertytitlePadding propertycolorScheme propertyenableAnimations property – Determines if the animations are enabled.xAxis property – Sets the Chart's xAxis.valueAxis propertyseriesGroups property – The seriesGroups property is used to describe all series displayed on the chart.getInstance methodupdate methodTo 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 $. Getting started with jqxChart shows the setup step by step.
The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxdata.js, jqxdraw.js, jqxchart.core.js, jqxslider.js, jqxbuttons.js, jqxcheckbox.js, jqxlistbox.js, jqxscrollbar.js, jqxdropdownlist.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 dataset = [
{ City: 'London', SalesCountJan: 210, SalesRevenueJan: 123 },
{ City: 'Madrid', SalesCountJan: 190, SalesRevenueJan: 114 },
{ City: 'Munich', SalesCountJan: 201, SalesRevenueJan: 112 },
{ City: 'Amsterdam', SalesCountJan: 110, SalesRevenueJan: 98 },
{ City: 'Paris', SalesCountJan: 105, SalesRevenueJan: 93 },
{ City: 'Prague', SalesCountJan: 54, SalesRevenueJan: 100 }
];
// prepare jqxChart settings
var settings = {
title: "Sales volume and revenue by city",
description: "(revenue in thousands)",
enableAnimations: false,
showLegend: true,
padding: { left: 5, top: 5, right: 5, bottom: 5 },
titlePadding: { left: 0, top: 0, right: 0, bottom: 5 },
colorScheme: 'scheme01',
source: dataset,
xAxis:
{
dataField: 'City',
valuesOnTicks: true,
labels: { autoRotate: true }
},
valueAxis:
{
labels: {
formatSettings: { decimalPlaces: 0 },
autoRotate: true
}
},
seriesGroups:
[
{
polar: true,
//startAngle: 90,
endAngle: 270,
radius: 120,
type: 'line',
series: [
{ dataField: 'SalesCountJan', displayText: 'Sales count', opacity: 0.7, lineWidth: 1, radius: 2, lineWidth: 2, symbolType: 'circle' },
{ dataField: 'SalesRevenueJan', displayText: 'Revenue', opacity: 0.7, lineWidth: 1, radius: 2, lineWidth: 2, symbolType: 'square' }
]
}
]
};
// create the chart
$('#chartContainer').jqxChart(settings);
// get the chart's instance
var chart = $('#chartContainer').jqxChart('getInstance');
// start angle slider
$('#sliderStartAngle').jqxSlider({ width: 240, min: 0, max: 360, step: 1, ticksFrequency: 20, mode: 'fixed' })
.on('change', function (event) {
var value = event.args.value;
settings.seriesGroups[0].startAngle = value;
chart.update();
});
// end angle slider
$('#sliderEndAngle').jqxSlider({ width: 240, min: 0, max: 360, value: 360 - 270, step: 1, ticksFrequency: 20, mode: 'fixed' })
.on('change', function (event) {
var value = 360 - event.args.value;
settings.seriesGroups[0].endAngle = value;
chart.update();
});
// end angle slider
$('#sliderRotate').jqxSlider({ width: 240, min: 0, max: 360, step: 1, ticksFrequency: 20, mode: 'fixed' })
.on('change', function (event) {
var value = event.args.value;
var endAngle = chart.seriesGroups[0].endAngle;
if (isNaN(endAngle))
endAngle = 360;
var startAngle = chart.seriesGroups[0].startAngle;
if (isNaN(startAngle))
startAngle = 0;
var diff = endAngle - startAngle;
settings.seriesGroups[0].startAngle = value;
settings.seriesGroups[0].endAngle = value + diff;
chart.update();
});
// radius slider
$('#sliderRadius').jqxSlider({ width: 240, min: 80, max: 140, value: 120, step: 1, ticksFrequency: 20, mode: 'fixed' })
.on('change', function (event) {
var value = event.args.value;
settings.seriesGroups[0].radius = value;
chart.update();
});
$("#checkBoxTicksBetween").jqxCheckBox({ width: 120, height: 25, hasThreeStates: false, checked: false });
$("#checkBoxTicksBetween").on('change', function (event) {
settings.xAxis.valuesOnTicks = !event.args.checked;
chart.update();
});
$("#checkBoxAutoRotate").jqxCheckBox({ width: 120, height: 25, hasThreeStates: false, checked: true });
$("#checkBoxAutoRotate").on('change', function (event) {
settings.xAxis.labels.autoRotate = event.args.checked;
settings.valueAxis.labels.autoRotate = event.args.checked;
chart.update();
});
});
<div id="chartContainer" style="width: 850px; height: 500px">
</div>
<table style="width: 850px">
<tbody><tr>
<td style="padding-left:50px">
<p style="font-family: Verdana; font-size: 12px;">Move the slider to change start angle:
</p>
<div id="sliderStartAngle">
</div>
</td>
<td>
<p style="font-family: Verdana; font-size: 12px;">Move the slider to change end angle:
</p>
<div id="sliderEndAngle">
</div>
</td>
</tr>
<tr>
<td style="padding-left:50px">
<p style="font-family: Verdana; font-size: 12px;">Move the slider to rotate:
</p>
<div id="sliderRotate">
</div>
</td>
<td>
<p style="font-family: Verdana; font-size: 12px;">Move the slider to change the radius:
</p>
<div id="sliderRadius">
</div>
</td>
</tr>
<tr style="height: 15px;">
</tr>
<tr>
<td style="padding-left:50px">
<div id="checkBoxTicksBetween">
Tick marks between values
</div>
</td>
<td>
<div id="checkBoxAutoRotate">
Auto rotate axis text
</div>
</td>
</tr>
</tbody></table>