hoonzis / KoExtensions

Simple charting library originaly built for KnockoutJS and few useful knockout bindings
MIT License
36 stars 10 forks source link

is there way to control tooltip text? #4

Open Qvatra opened 9 years ago

Qvatra commented 9 years ago

for example I need to format the value in tooltip which in my case is 1.333333333333333 which is not informative at all but take a lot of space..

hoonzis commented 9 years ago

Yes there is a way. You need to add option parameter called unitTransform, which is a function applied to the value before shown in the tooltip.

It works with barchart. Check the GraphTests.html file which has the example. Basically if the parent viewModel has a function "valueToLabel" the following will work:

<div id="monthlySales2" data-bind="barchart: carSales,chartOptions:{style:'bar',xcoord:'month',unitTransform:valueToLabel}">