Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chartist js rotate labels on x-axis

Tags:

chartist.js

I have set up a js fiddle which demonstrates how axis labels can be rotated, based on an issue raised on github. It works fine in the js fiddle example below, but when I try this on my site the labels are not visible.

http://jsfiddle.net/Lnhpwn8x/22/

html {
  box-sizing: border-box;
  font-family: Roboto, sans-serif;
}

*, *:before, *:after {
  box-sizing: inherit;
}

.ct-label.ct-label.ct-horizontal {
  position: fixed;
  justify-content: flex-end;
  text-align: right;
  transform-origin: 100% 0;
  transform: translate(-100%) rotate(-45deg);
}

If I resize the screen to make it smaller the labels appear, so I think the issue is to do with the size of chart and that it is taking up 100% of the width

like image 393
DavidB Avatar asked Nov 23 '16 10:11

DavidB


Video Answer


1 Answers

Here an exemple :

svg.ct-chart-bar, svg.ct-chart-line{
    overflow: visible;
}
.ct-label.ct-label.ct-horizontal.ct-end {
  position: relative;
  justify-content: flex-end;
  text-align: right;
  transform-origin: 100% 0;
  transform: translate(-100%) rotate(-45deg);
  white-space:nowrap;
}

http://jsfiddle.net/madvic/qek2sjs0/4/

And now work with long text...

like image 63
madvic Avatar answered Sep 22 '22 16:09

madvic