I need a specific format for the tick:
tick: {
fit: true,
multiline: false,
outer: false,
format: function (x) {
var value = this.api.categories()[x];
if(value.length > 5)
return value.substring(0,5)+"...";
else
return value;
}
},
value
is a unique attribute. However, I need to truncate it to only show the first 5 characters.
Additionally, I have a click event on the ticks:
_.each(this.chart.element.querySelectorAll('svg g.c3-axis-x .tick text tspan'), (el) => {
el.onclick = (e) => this.someFunction(e)
})
In the someFunction()
, I want to retrieve the unique attribute in order to fetch data specific to the current tick.
Previously, I obtained this attribute using angular.element(e.target).text()
, but sometimes it might be cropped. Is there a way to get the current index or another method to retrieve the full text?