HanSolo / SteelSeries-Canvas

The HTML5 Canvas port of the SteelSeries component library. Mainly contains gauges.
120 stars 76 forks source link

Radial Dial numbered ticks display error #16

Closed nomad-cam closed 9 years ago

nomad-cam commented 9 years ago

I seem to be getting incorrectly numbered ticks on my radial dials as seen in the attached image. The number sequence should be 23,23.5,24,24.5,25 etc. It seems like the half increments are being rounded up... Is it possible to not display the half increment numbers to avoid this confusion? or have the option to change this behaviour?

var bat_breakpoints = Array(steelseries.Section(23,24, 'rgba(220,0,0,0.3)'),
                            steelseries.Section(24,25.5, 'rgba(0,220,0,0.3)'),
                            steelseries.Section(25.5,27, 'rgba(220,220,0,0.3)'),
                            steelseries.Section(27,28, 'rgba(220,0,0,0.3)'));
var bat_areas = Array(steelseries.Section(23,24, 'rgba(220,0,0,0.3)'),
                      steelseries.Section(27,28, 'rgba(220,0,0,0.3)'));

var radial_bat1 = new steelseries.Radial(
    'canvas_bat1', {
    section: bat_breakpoints,
    area: bat_areas,
    titleString: 'Battery 1',
    unitString: 'V',
    minValue: 23,
    maxValue: 28,
    pointerType: steelseries.PointerType.TYPE11
    });

var radial_bat2 = new steelseries.Radial(
    'canvas_bat2', {
    section: bat_breakpoints,
    area: bat_areas,
    titleString: 'Battery 2',
    unitString: 'V',
    minValue: 23,
    maxValue: 28,
    pointerType: steelseries.PointerType.TYPE11
    });

steelseries_display_error

mcrossley commented 9 years ago

You could fix that by adding the parameter to make the scale labels fractional rather than integer, and another to specify the number of decimal places to display...

var radial_bat1 = new steelseries.Radial(
    'canvas', {
    section: bat_breakpoints,
    area: bat_areas,
    titleString: 'Battery 1',
    unitString: 'V',
    minValue: 23,
    maxValue: 28,
    labelNumberFormat: steelseries.LabelNumberFormat.FRACTIONAL,
    fractionalScaleDecimals: 1,
    pointerType: steelseries.PointerType.TYPE11
    });
nomad-cam commented 9 years ago

Perfect, thanks for the tip. That's exactly what I was after.