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

Formatting option on data label #37

Open
hagaygo opened this issue Mar 16, 2023 · 7 comments
Open

Formatting option on data label #37

hagaygo opened this issue Mar 16, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@hagaygo
Copy link

hagaygo commented Mar 16, 2023

After #33 is implemented using chartjs-plugin-datalabels plugin it seems i am now missing an option to format the data label.

It seems to be supported by the plugin itself : https://chartjs-plugin-datalabels.netlify.app/guide/formatting.html#multiline-labels

I can workaround this need currently by truncating the data itself , but not it is not always to workaround this way, so it should be possible with this package someday.

Thanks in advance.

@erossini
Copy link
Owner

I know that because I'm trying to implement this functionality. I'll keep you posted.

@erossini erossini self-assigned this Mar 16, 2023
@erossini erossini added the enhancement New feature or request label Mar 16, 2023
@erossini
Copy link
Owner

erossini commented Apr 4, 2023

I added a callbacks for Title and Labels. You can see the demo page here
I'll release the NuGet package tomorrow

@erossini
Copy link
Owner

erossini commented Apr 6, 2023

Is it working? Can I close the issue?

@hagaygo
Copy link
Author

hagaygo commented Apr 6, 2023

Hi , Can't check it now , I will check it on the start of next week and let you know.

Thanks for your efforts so far.

@hagaygo
Copy link
Author

hagaygo commented Apr 9, 2023

Hi

Just tested the new nuget (6.0.40) and i think there a little mistunderstanding.

It Seems you handled the tooltip data , while i was referring to the the label on the graph it self, here is a screenshot of my graph :

image

As you can see i want to format the label on the bar graph it self , not the tooltip.

Let me know if i missed something.

Thanks again for your time and efforts.

@soulfire03
Copy link

I need this change too, for the DataLabels object.
Thanks!

@yhbder
Copy link

yhbder commented Oct 12, 2024

const workingHoursSummaryChart = new Chart(workingHoursSummaryEle.getContext('2d'), {
type: 'bar',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [{
label: 'Month',
data: [80, 60, 70, 140],
borderRadius: 8,
borderWidth: 1,
barPercentage: 1.15,
borderSkipped: false,
backgroundColor: ['#E8ECF1', '#E8ECF1', '#E8ECF1', '#1A4573', ],
borderColor: ['#E8ECF1', '#E8ECF1', '#E8ECF1', '#1A4573', ],
datalabels: {
color: ['#0B1D30', '#0B1D30', '#0B1D30', '#1A4573'],
anchor: 'end',
align: 'top',
font: {
size: '12px',
weight: '600',
family: 'Nohemi'
},
},
}]
},
plugins: [ChartDataLabels],
options: {
responsive: false,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
},
datalabels: {
display: false,
formatter: (value) => {
return value + 'hrs';

}
}
},
layout: {
padding: {
top: 30,
}
},
scales: {
y: {
display: false,
offset: true,
},
x: {
reverse: false,
grid: {
display: false
}
}
}
}
});


This code in JavaScript

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

No branches or pull requests

4 participants