Skip to content

Conversation

@saumya1317
Copy link
Contributor

@saumya1317 saumya1317 commented Oct 22, 2025

This pull request adds multi-expression plotting capabilities to the graphing application, similar to Desmos. Users can now plot multiple mathematical expressions simultaneously, each with its own customizable color. The feature includes dynamic expression management (add/remove), individual enable/disable toggles, and support for both regular functions and parametric curves.
Semver Changes

  • Patch (bug fix, no new features)
  • Minor (new features, no breaking changes)
  • Major (breaking changes)

Issues

Closes #8 (Add support for plotting multiple expressions)

Checklist

  • I have read the Contributing Guidelines.

@nsh07
Copy link
Member

nsh07 commented Oct 23, 2025

LGTM, I'll review and merge this by this evening

#include "exprtk.hpp"
#include "funcs.hpp"

using namespace std;
Copy link
Member

Choose a reason for hiding this comment

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

Please revert the use of using namespace std. It is bad practice and it will create trouble at some point, if not now. See https://stackoverflow.com/questions/1452721/whats-the-problem-with-using-namespace-std for further reading.

Comment on lines +173 to +179
string s(e.expr);
bool ok = false;

if (!s.empty() && s.front() == '(' && s.back() == ')') {
string inner = s.substr(1, s.size() - 2);
int d = 0;
size_t pos = string::npos;
Copy link
Member

Choose a reason for hiding this comment

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

Also refrain from shortening variables for no reason. It makes the code unreadable. s should be renamed to func_str, d should be renamed to depth, and ok should be renamed to plotted.

Comment on lines +193 to +197
exprtk::symbol_table<double> st;
st.add_constants();
addConstants(st);
st.add_variable("t", t);
exprtk::expression<double> ef, eg;
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here, rename st to symbolTable and ef, eg to expr_fx, expr_gx

Comment on lines +215 to +221
exprtk::symbol_table<double> st;
st.add_constants();
addConstants(st);
st.add_variable("x", x);
exprtk::expression<double> expr;
expr.register_symbol_table(st);
exprtk::parser<double> p;
Copy link
Member

Choose a reason for hiding this comment

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

Same thing, rename the variables here as well

@nsh07
Copy link
Member

nsh07 commented Oct 23, 2025

@saumya1317 Important: I would suggest you to wait until I merge both of the other PRs. You will have to resolve merge conflicts and thus I would suggest you to only start working on my requested changes once I merge the other 2 open PRs. I'll ping you here once I do that.

@saumya1317
Copy link
Contributor Author

ok

@nsh07 nsh07 closed this Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add support for plotting multiple expressions

2 participants