Skip to content
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

Pie chart series name class for text ct-label element #942

Closed
karinseve opened this issue May 4, 2017 · 3 comments · May be fixed by #1198
Closed

Pie chart series name class for text ct-label element #942

karinseve opened this issue May 4, 2017 · 3 comments · May be fixed by #1198

Comments

@karinseve
Copy link

I'm using a donut chart like in the examples:
The produced HTML code (FRAGMENT) is

<g>
<text dx="134.29110117477677" 
      dy="30.08812886535611" 
      text-anchor="middle" class="ct-label">3400
      </text>
<text dx="143.04223215855663" 
        dy="247.2452044679772" 
        text-anchor="middle" class="ct-label">1800
        </text>
</g>

As you can see I'm not able to customize with CSS the two labels differently, because they have the same class. Even if I set up

series: [{
   value: 20,
   name: 'Series 1',
   className: 'my-custom-class-one',
   meta: 'Meta One'
 }

I would expect to obtain

<g>
<text dx="134.29110117477677" 
      dy="30.08812886535611" 
      text-anchor="middle" class="ct-label my-custom-class-one">20
      </text>
...
</g>
@gionkunz
Copy link
Collaborator

That's a bit unfortunate at the moment, but is not likely to change before the Major update with 1.0.0. You can use an ugly selector approach as a workaround. .ct-label:nth-child(1), .ct-label:nth-child(2) etc.

@karinseve
Copy link
Author

I see, would you consider a pull request?

@petervtzand
Copy link

@gionkunz I have the same problem. Your suggested solution fixes it, unless you have a 0 value (for example [0, 6, 7], and ignoreEmptyValues: true. When this is the case, In series-b .ct-label:nth-child(1) and in series-c .ct-label:nth-child(2) are shown (instead of label 2 & 3)

To fix this problem I set ignoreEmptyValues: false and created a labelInterpolationFnc that returns ' ' if value === 0, but that is very hacky.

My suggested solution is that the className of the 'slice', like 'series-a' or 'my-custom-class-name' is set on the label as well. I created a PR for it: https://github.com/gionkunz/chartist-js/pull/1198

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants