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
Add formatter option #48
Conversation
I had the feeling, but never got around to test. The |
@kurkle yes, I discovered today that ;) Nevertheless The implementation of this PR enables also the possibility to add and format labels for no-group data. Make sense to you? |
If you comment the This is the reason why I think |
@kurkle I have committed first changes to go to the direction you proposed. There are some behaviors that I don't know why there are happening:
These behavoirs are weird... Furthermore, due to my low knowledge, I have defined the types of labels as following: type TreemapControllerDatasetLabelsOptions = {
display?: boolean;
formatter?: Scriptable<string | Array<string>, ScriptableContext<'treemap'>>
}
...
export interface TreemapControllerDatasetOptions<DType> {
...
labels?: TreemapControllerDatasetLabelsOptions;
...
} When I test the types, it seems that the context is not recognized and I have got the following error:
Maybe you can help me. |
@kurkle I have tested the Chart.js master with PR chartjs/Chart.js#9758 in order to understand if some behaviors are changed. What I see is when you configure the treemap chart to use groups, and only enable the labels data: {
datasets: [{
tree: statsByState,
key: 'area',
groups: [],
spacing: -0.5,
borderWidth: 0.5,
borderColor: 'rgba(200,200,200,1)',
hoverBackgroundColor: 'rgba(220,230,220,0.5)',
labels: {
display: true,
}
}]
}, but you want to use the default formatter, the I'm still investigating... |
Did you check the changes I proposed in https://github.com/pepstock-org/chartjs-chart-treemap/pull/1/files ? |
nooooo... I didn't... apologize. I'm gonna apply your updates and test it again, |
Fix type of `raw` in scriptable context
Done!
Before seeing your PR, I was playing with descriptors too. Nevertheless it does still not working. labels: {
display: true,
} With this config, it should use the default I have also changed (function(Utils) {
//const chartjsUrl = 'https://cdn.jsdelivr.net/npm/chart.js/dist/chart.js';
const chartjsUrl = 'https://www.chartjs.org/dist/master/chart.js';
..... Opening the sample by FF, this is the result: |
Just verified it works with 9770 merged to master |
@kurkle thanks a lot! let me try again. feedback soon |
Yes, it works! THANK YOUUU! I'd like to change the Another thoughts: does it make sense to use the option named |
Need to update the package.lock too (just run |
I didn't commit it... I do.
In my opinion, this PR should address the issues above mentioned. To align to other plugins, maybe it's better another PR to add additional options. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Fixes #41
Fixes #24
Fixes #20
Ref #38, #44
This PR adds
formatter
options in order to format the label to show on the treemap elements.The PR changes also the
label
option defintion in order to be align to the datasetlabel
option of all other controllers.