eskimoblood / jim-knopf

:o: small JavaScript library to create knobs using SVG
http://eskimoblood.github.com/jim-knopf/
199 stars 44 forks source link

data-labels scale are rendered according to supplied settings, but the pointer is not #4

Closed wakandan closed 10 years ago

wakandan commented 10 years ago

image

As can be seen in the picture, the pointers are not using supplied settings, make it difficult to sync with the dials,

Ui.P6 = function() {};

Ui.P6.prototype = Object.create(Ui.prototype);

Ui.P6.prototype.createElement = function() {
  Ui.prototype.createElement.apply(this, arguments);  
  this.addComponent(new Ui.Pointer({
    type: 'Arc',
    size: 30,
    outerRadius: this.width / 2.6,
    innerRadius: this.width / 2.6 - this.width / 6,
    angleoffset: this.options.angleoffset
  }));
  // this.addComponent(new Ui.Text());
  this.addComponent(new Ui.Scale(this.merge(this.options, {
    drawScale: false,
    drawDial: true,
    radius: this.width/2.5
  })));
  var circle = new Ui.El.Circle(this.width / 2.1, this.width / 2, this.height / 2);
  this.el.node.appendChild(circle.node);
  this.el.node.setAttribute("class", "p5 p6");
};

new Knob(document.getElementById('p6'), new Ui.P6()); 

The above code is basically p5, with the addition of Scale which made used of data-labels attribute.

I was trying to make it work but had no clue how to sync the pointer. Any suggestion?

eskimoblood commented 10 years ago

I've looked at it yesterday, and I think the problem is in this function changed function and _updateWhileMoving function. Setting the value to the actual label, should fix the problem.

wakandan commented 10 years ago

Ok I can look into it.

eskimoblood commented 10 years ago

This would be cool, thanks.

wakandan commented 10 years ago

there's a correction in my original description: - the pointer is not using supplied settings -

In the picture, data-angleOffset was 270, but offset for the pointer was 90 - as can be seen that the pointer is 180 degrees off from its supposed position. In the starting position - the position of "test1" - the pointer will be at "test5" position.

wakandan commented 10 years ago

please check fix #5. It should fix this problem. Thanks

eskimoblood commented 10 years ago

Thanks again for your work.

wakandan commented 10 years ago

Cool, thanks so much!