Plot a line (y = 2x + 7) on a graph

北城余情 提交于 2019-12-13 12:23:09

问题


I am working on a scientific calculator in C#. I have the parsing engine and such, now I would like to add a graph so the user can plot a line. Is there any kind of control that will let me input a function and it will graph a line in the chart? I'm not talking about plotting individual points by the way.

Take this linear equation in slope-intercept form for instance:

f(x) = 2x + 7

The main goal is to allow the user to write 2x + 7 in a textbox, and then it will graph the line. It would be preferable if custom functions could be used other than just linear functions, such as:

((x - 8) * 4^2)/(7.136 + x)

But it's not a requirement. Is there a third-party control for this? If not, how could I create such a control?

I have downloaded a program that graphs functions like this:

How can I achieve this functionality in my Visual C# 2010 WinForms application?


回答1:


I searched for mathematical function plot library for windows and found this:

  • FPlot a ".NET library for plotting functions and measurement data" (a project on CodeProject)

and you can try to use the source code of:

  • MathGV
  • Graph

You'll have to check the licenses. I didn't try any of these, by the way.



来源:https://stackoverflow.com/questions/14371085/plot-a-line-y-2x-7-on-a-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!