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

FIX: render multiline legend items without overlapping (#10532) #10641

Conversation

kartik-madhak
Copy link
Contributor

Co-authored-by: Nirav Chavda [email protected]

Fixes: this issue

Explanation

Previously all the labels were considered to have a constant height, we changed it so that it calculates the height in case of multi-line labels

Screenshot

image

Input for the above screenshot: -

var myChart = new Chart(ctx, {
  type: 'doughnut',
  data: {
	labels: [
	      'Some Text',
	      [
	        'ABCDEFG',
	        'ABCDEFG',
	      ],
	      [
	        'Hello World',
	        'Lorem Ipsum',
	        'Multi Line Text',
	      ],
	      'Some Text',
	      'Some Text',
	      'Some Text',
	],
	datasets: [
	      {
	        label: 'test',
	        data: [
		  73.42,
		  18.13,
		  7.54,
		  0.9,
		  0.0025,
		  1.8e-5,
	        ],
	        backgroundColor: [
		  '#0078C2',
		  '#56CAF5',
		  '#B1E3F9',
		  '#FBBC8D',
		  '#F6A3BE',
		  '#4EC2C1',
	        ],
	      },
	],
  },
  options: {
	plugins: {
	      legend: {
	        labels: {
		  usePointStyle: true,
		  pointStyle: 'rect',
	        },
	        position: 'right',
	        align: 'center',
	        maxWidth: 860,
	      },
	},
	aspectRatio: 3,
  },
});

@LeeLenaleee LeeLenaleee added this to the Version 4.0 milestone Aug 29, 2022
etimberg
etimberg previously approved these changes Sep 12, 2022
kurkle
kurkle previously approved these changes Sep 14, 2022
etimberg
etimberg previously approved these changes Sep 14, 2022
@etimberg
Copy link
Member

Looks like the size limit needs to be increased slightly to accommodate this change. @kartik-madhak can you up that and then we'll merge this?

It's this file https://github.com/chartjs/Chart.js/blob/master/.size-limit.cjs and the failing GH action logs https://github.com/chartjs/Chart.js/blob/master/.size-limit.cjs#L37 should be updated. I think a good new size is "27.5KB"

LeeLenaleee
LeeLenaleee previously approved these changes Sep 15, 2022
@niravchavda99 niravchavda99 deleted the bugfix/10532-vertical-legend-multiline-labels-overlaps branch September 16, 2022 13:08
@kartik-madhak kartik-madhak restored the bugfix/10532-vertical-legend-multiline-labels-overlaps branch September 16, 2022 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vertical legend multiline labels overlaps
5 participants