angular-awesome-slider icon indicating copy to clipboard operation
angular-awesome-slider copied to clipboard

Can we display a label for slider with steps?

Open praswebdev opened this issue 9 years ago • 12 comments

Hi, Can we display a label for the slider with steps, which moves with the pointer? Right now i can see the the values 0, 1, 2, etc displayed for step labels. Instead can i display the scale value test1, test2,test3 etc.. $scope.singleoptions = { from: 0, to: 4, step: 1, dimension: " ", scale: ['test1', 'test2', 'test3', 'test4', 'test5'] }; http://jsfiddle.net/g9e9n8xc/67/

praswebdev avatar Mar 02 '15 17:03 praswebdev

good idea, I see what I can do with dimension string, maybe with a specific character to handle prefix or suffix.

darul75 avatar Mar 03 '15 08:03 darul75

That would be really useful, i've stumbled upon the need of it.

olegakbarov avatar Mar 24 '15 08:03 olegakbarov

need time but ok I will stop what I was doing to implement it first ;)

darul75 avatar Mar 24 '15 08:03 darul75

i'm actually WIP with this stuff and came up with this monkey-patch:

At first i added an array of label values to options object

var OPTIONS = {
...
discreteValues: ["value1", "value2", "value3"]
...
}

than in directive i've rewritten the defaults

var OPTIONS = {
from: 0,
to: scope.options.discreteValues.length - 1
...
discreteValues: scope.options.discreteValues
}

and finally just set the value to map to corresponding string in discreteValues array

this.o.labels[pointer.uid].value.html(
this.settings.discreteValues[this.nice(pointer.value.origin)]
);

let me know what you do think i can send a PR if you think this is fine solution

olegakbarov avatar Mar 24 '15 15:03 olegakbarov

dimension is given ability to set suffix string, would a prefix string enough for you ?

dimension "km" : will display "1 km", "2 km", "3 km"... dimension ">> km " : will display "km 1", "km 2", "km 3"...

I was thinking about that.

You all mean labels on pointers ? we change nothing to scale labels ? ;)

darul75 avatar Mar 24 '15 16:03 darul75

hmm or just display scale value for pointer when pointers on it ?

darul75 avatar Mar 24 '15 16:03 darul75

Thanks for reply!

Suffix string would not be option for me. I need to display strings without numbers :/ I need a value that works like dropdown:

sld

I think binding a model to pointer value would be useful case.

olegakbarov avatar Mar 25 '15 08:03 olegakbarov

ok, maybe still not closed enough to what you mean but can you check this one:

http://jsfiddle.net/darul75/3kt5mv8w/1/

value binding is set in options with json obj "keyModel:valueLabel"

modelLabels: {1: 'WTF', 2: 'OK'},`

bit it is display on top of pointers ?

darul75 avatar Mar 25 '15 09:03 darul75

Yeah, this fiddle looks like what i need! So the question is how to attach modelLabels to the top fo pointer?

olegakbarov avatar Mar 25 '15 10:03 olegakbarov

to the bottom you mean ? ;)

darul75 avatar Mar 25 '15 10:03 darul75

Hahaha, yeah! I guess i need one more cup of coffee.

olegakbarov avatar Mar 25 '15 10:03 olegakbarov

I have to go now but check that asap

darul75 avatar Mar 25 '15 10:03 darul75