-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with the last label on the X-axis #557
Comments
Happy new Year! :-) What browser are you using? Can you post your chart config? |
Happy new Year too! :-) What browser are you using?
Can you post your chart config? var options = {
fullWidth: true,
chartPadding: { right: 100 },
lineSmooth: Chartist.Interpolation.cardinal({ fillHoles: true }),
height: self.table_height,
showArea: true,
axisX: { offset: 60 },
axisY: {
offset: 80,
labelInterpolationFnc: function(value) {
var new_value = value;
if(lang['system_currency_position'] == 'before') {
return self.shortPrice(lang['sys_currency'] + " " +new_value);
} else {
return self.shortPrice(new_value + " " +lang['sys_currency']);
}
}
}
} |
Yeah, that's a problem of the |
For now you have a few options:
|
What is the best way to remove or hide the last label? |
The easiest way is to set your last label to an empty string. If you want to implement this more like a plugin, you can use the draw event to remove the last label on the X axis: var data = {
labels: [1, 2, 3],
series: [[1, 2, 3]]
};
Chartist.Line('#chart', data, {
fullWidth: true
}).on('draw', function(context) {
if (context.type === 'label' &&
context.axis.units.pos === 'x' &&
context.index === data.labels.length - 1) {
context.element.remove();
}
}); |
Great, thank you. I'm already listening on the draw event to add labels to the lines so I can hook in there. |
We need to consider this when working on #809 |
How do you do this for a bar chart on the x-axis? In that case we cannot write |
In case someone else needs this:
That’ll add a class to the last label, which you can use to position it via CSS |
small modification to @nathanaelphilip answer did the trick for me
|
Additionally; to hide any label on the Y-axis that is shown above the chart field you can use this:
|
The best solution to this problem is just to add a css style to your svg:
|
Merry Christmas for everyone)
I've got a some problem with last label on the X-axis:
How can i put it to the one line? Bcs there is a lot of space there.
The text was updated successfully, but these errors were encountered: