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

Fixed tooltipHoverFormatter not being deserialized as a function #451

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

SparkyTD
Copy link
Contributor

Fixes #449

I added 'tooltipHoverFormatter' to the list of JSON keys that will be evaluated as a function in the browser.

@SparkyTD
Copy link
Contributor Author

I think there might be a more flexible way of solving this, using an attribute on the C# side, and some custom serialization/deserialization logic.

I'll look into the feasibility of that solution, and I might create another PR if it looks good.

@joadan joadan merged commit 54064ce into apexcharts:master Apr 27, 2024
3 checks passed
@SparkyTD
Copy link
Contributor Author

@joadan I have implemented the idea I was referring to: fucntion-serializer. It basically uses a custom JsonConverter to prefix all function strings with a custom JSON key ('@eval'), and replaces the name checking logic on the JS side with a much simpler logic that checks if a string is prefixed with this key.

So instead of serializing a function as myFunction: "function(arg) { ... }", it gets serialized as such:

myFunction: {
    "@eval": "function(arg) { ... }"
}

This way the client can simply check if the value is an object containing the '@eval' key, and use that to decide whether or not to evaluate the contents. It also works for function arrays that use CustomFunction.

Please tell me if this looks good, and I should open another PR.

@joadan
Copy link
Member

joadan commented Apr 27, 2024

@SparkyTD, this sounds great!
If you create a PR I'll take a look at it.

Thank you for your work!

@SparkyTD
Copy link
Contributor Author

No problem, I love this project!

I created the PR: #453

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants