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

Arbitrary chart variable assignment by @gotkaren's PR714 #1673

Closed
wants to merge 0 commits into from

Conversation

catherinedevlin
Copy link
Contributor

Supports passing arbitrary chart variables to the Chart Module.

Supersedes #714 by @gotkaren. I apologize that I wasn't able to preserve any of her commits, but there have been too many changes since then and I wasn't able to unsnarl git.

I don't know if we have a way to test JavaScript, but I informally tried some examples mesa-examples; they didn't break, and I was able to change chart visual parameters. For instance, changed https://github.com/projectmesa/mesa-examples/blob/68c8e87c8e9b0eed5cf87419bcec4de5839ff5a1/examples/forest_fire/forest_fire/server.py#L23 to

[{"Label": label, "Color": color, "borderWidth": 10, "pointRadius": 10} for (label, color) in COLORS.items()]

and got the desired effect.

I didn't make any changes to the docs - as far as I can see, they already imply that you ought to be able to submit arbitrary parameters to a chart, so this PR just brings the code into sync with the docs.

@catherinedevlin catherinedevlin changed the title Arbitrary chart variable assignment by @gotkaren's Arbitrary chart variable assignment by @gotkaren's PR714 Apr 26, 2023
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (529e73c) 81.69% compared to head (9b5ae6f) 81.69%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1673   +/-   ##
=======================================
  Coverage   81.69%   81.69%           
=======================================
  Files          18       18           
  Lines        1393     1393           
  Branches      271      271           
=======================================
  Hits         1138     1138           
  Misses        209      209           
  Partials       46       46           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

backgroundColor: convertColorOpacity(s.Color),
data: [],
};
for (var property in s){
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be const instead of var.

for (var property in s){
new_series[property] = s[property];
}
new_series["backgroundColor"] = convertColorOpacity(s.Color)
Copy link
Contributor

Choose a reason for hiding this comment

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

This has already been specified in L31.

@rht
Copy link
Contributor

rht commented May 9, 2023

@catherinedevlin I tried to edit your branch to apply my comments, but it appears that I am not able to push to the main branch of a fork. I will reopen your PR in a new PR instead.

@rht
Copy link
Contributor

rht commented May 9, 2023

Superseded by #1685.

rht pushed a commit to rht/mesa that referenced this pull request May 9, 2023
Original work: projectmesa#714 and
projectmesa#1673.

Co-Authored-By: Catherine Devlin <devlinch@corning.com>
rht pushed a commit to rht/mesa that referenced this pull request May 9, 2023
Original work: projectmesa#714 and
projectmesa#1673.

Co-Authored-By: Catherine Devlin <devlinch@corning.com>
rht pushed a commit to rht/mesa that referenced this pull request May 9, 2023
Original work: projectmesa#714 and
projectmesa#1673.

Co-Authored-By: Catherine Devlin <devlinch@corning.com>
rht added a commit to rht/mesa that referenced this pull request May 9, 2023
Original work: projectmesa#714 and
projectmesa#1673.

Co-authored-by: Karen Gonzalez <karenyglez.tr@gmail.com>
Co-authored-by: rht <rhtbot@protonmail.com>
rht added a commit that referenced this pull request May 9, 2023
Original work: #714 and
#1673.

Co-authored-by: Catherine Devlin <devlinch@corning.com>
Co-authored-by: Karen Gonzalez <karenyglez.tr@gmail.com>
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 this pull request may close these issues.

2 participants