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

Upgrade chart.js to the latest version #22

Merged
merged 36 commits into from
Sep 29, 2022
Merged

Conversation

DarkSide666
Copy link
Member

@DarkSide666 DarkSide666 commented Aug 31, 2022

  • upgrada to newest ChartJS
  • more Chart classes
  • improved demo of all charts

NOTE: There are BC incompatible changes !


  • withCurrency() workaround for chartjs do not work anymore.
  • Scatter and Bubble charts need custom setModel method to fill dataset
  • review summarize() method - what it does and do we need it (basically that's simplified models group by feature)

@mvorisek mvorisek changed the title a lot of changes Upgrade chart.js to the latest version Sep 1, 2022
@mvorisek mvorisek added MAJOR and removed BC-break labels Sep 24, 2022
'tooltip' => [
'enabled' => true,
'mode' => 'point',
'callbacks' => [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in atk4/* we prefer as much as possible things to be done in php, here format the values using atk4/ui UI persistence - can we do that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can with some workaround (like first storing all labels as JS array filled from PHP side) and then in JS callback lookup that value, but I don't think it's worth it. This way it's easy and straightforward at least for now.
There definitely is space for improvement - maybe someone who use charts in projects will contribute something nicer with a time, but for now ... i guess it's fine like this.

*/
protected function prepareDatasets(): void
{
if ($this->model === null || $this->columns === null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is model required to be set or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes model and columns are required. Do you think exception here would be better?

public function setColumnOptions(array $options)
{
// IMPORTANT: use replace not merge here to preserve numeric keys !!!
$this->columnOptions = array_replace_recursive($this->columnOptions, $options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array_replace_recursive function is highly problematic, see atk4/ui#1811 and related data bug

why we need it and do you understand all the side effects? I prefer to never use this function across all atk4 repos

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about all side effects, but replace was needed here to be able to merge array elements with numeric keys. array_merge_recursive appends (not merge/replace) elements with numeric keys.

@mvorisek mvorisek merged commit 0d8431e into develop Sep 29, 2022
@mvorisek mvorisek deleted the feature/upgrade-charts branch September 29, 2022 12:59
@mvorisek
Copy link
Member

Thank you @DarkSide666!

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

Successfully merging this pull request may close these issues.

2 participants