JSFiddle - React, Tailwind, and code Playground
by Anand Rathod
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; max-width: 400px; height: 300px; margin: 0 auto"></div>
CSS
.highcharts-gauge-series .highcharts-pivot {
stroke-width: 0px;
stroke: transperent;
fill-opacity: 0.3;
}
JavaScript
$(function() {
var H = Highcharts;
var each = H.each,
merge = H.merge,
pInt = H.pInt,
pick = H.pick,
isNumber = H.isNumber;
Highcharts.seriesTypes.gauge.prototype.translate = function() {
var series = this,
yAxis = series.yAxis,
options = series.options,
center = yAxis.center;
series.generatePoints();
each(series.points, function(point) {
var dialOptions = merge(options.dial, point.dial),
isRectanglePoint = point.series.userOptions.isRectanglePoint,
radius = (pInt(pick(dialOptions.radius, 80)) * center[2]) / 200,
baseLength = (pInt(pick(dialOptions.baseLength, 70)) * radius) / 100,
rearLength = (pInt(pick(dialOptions.rearLength, 10)) * radius) / 100,
baseWidth = dialOptions.baseWidth || 3,
topWidth = dialOptions.topWidth || 1,
overshoot = options.overshoot ,
rotation = yAxis.startAngleRad + yAxis.translate(point.y, null, null, null, true);
console.log(overshoot);
// Handle the wrap and overshoot options
if (isNumber(overshoot)) {
console.log('over shoot');
overshoot = overshoot / 180 * Math.PI;
rotation = Math.max(yAxis.startAngleRad - overshoot, Math.min(yAxis.endAngleRad + overshoot, rotation));
} else if (options.wrap === false) {
rotation = Math.max(yAxis.startAngleRad, Math.min(yAxis.endAngleRad, rotation));
}
rotation = rotation * 180 / Math.PI;
console.log('rotation');
// Checking series to draw dots
if (isRectanglePoint) { //draw new dial
console.log(radius);
point.shapeType = 'path';
point.shapeArgs = {
d: dialOptions.path || [
'M', -rearLength + 6, (-baseWidth / 2),
'L', -rearLength + 12, (-baseWidth / 2) + 6, -rearLength +6, (-baseWidth / 2) + 12, -rearLength, (-baseWidth / 2) + 6,
'z'
],
translateX: center[0] - baseWidth - 1,
translateY: center[1],
rotation: rotation,
style: 'stroke: white; stroke-width:...