Coder Social home page Coder Social logo

Comments (15)

paulmasson avatar paulmasson commented on July 18, 2024

If you have complete control of the web page, then you could load the library at the top of the page and return the scripts inside a <div> of class mathcell as indicated in the template of the documentation. That is how the library was written to be used and how I use it on my own website.

All of the JavaScript functions in MathCell are global for convenience of use, which is a bit nonstandard. If you want to avoid any possibility of overwriting existing functions, then you could wrap the script in an entire HTML document and return it inside an <iframe>. That's how the Three.js backend works for SageMath in a Jupyter notebook: I know well because I'm the main author of that functionality.

from mathcell.

axkr avatar axkr commented on July 18, 2024

I have update the website:

I tried to insert a <div> element as suggested.
At least in Firefox I can see only the slider. Is it possible to set the width and height?

from mathcell.

paulmasson avatar paulmasson commented on July 18, 2024

At least in Firefox I can see only the slider. Is it possible to set the width and height?

Sure, and make sure to include the class as well:

<div class="mathcell" style="width: 5in; height: 4in">

from mathcell.

paulmasson avatar paulmasson commented on July 18, 2024

After updating the div settings in the Firefox console I can see and use the interactive graphic.

from mathcell.

axkr avatar axkr commented on July 18, 2024

I'm not good at javascript.
I even didn't know that I can manipulate attributes in the browser console.

Do you have an example, how I can set width and height to 600x400 for example?

from mathcell.

paulmasson avatar paulmasson commented on July 18, 2024

Do you have an example, how I can set width and height to 600x400 for example?

<div class="mathcell" style="width: 600px; height: 400px">

from mathcell.

axkr avatar axkr commented on July 18, 2024

Ok I get a basic example running and deployed:
axkr/symja_web@9162ecc

from mathcell.

axkr avatar axkr commented on July 18, 2024

Next problem is in this example: Manipulate(Plot3D(Sin(x + y^2), {x, -3, 3}, {y, -2, 2}))

I have an older three.js integrated in the website. Could this be the problem?

from mathcell.

paulmasson avatar paulmasson commented on July 18, 2024

MathCell has its own links to the version of Three.js appropriate to its internal template, so your version won't be an issue. Although a lot has changed since r49...

Part of the problem could be that the website is currently using version 1.3.0 of MathCell and things have changed since then. First try updating to 1.7.0 and regenerating. If the problem persists then please post your generated script here so that I can see what you're actually feeding into the cell.

from mathcell.

axkr avatar axkr commented on July 18, 2024

Updated only version to 1.7.0.

The log for a Plot3D:

>> three.min.js:177:216
THREE.WebGLRenderer 100 

>> srcdoc:147:3
TypeError: v is undefined
    <anonym> about:srcdoc:147

Also example Manipulate(Plot(Sin(x)*Cos(1 + a*x), {x, 0, 2*Pi}), {a,0,10}) gives an error:

>> mathcell.js:1350:14
TypeError: l.points.forEach is not a function

from mathcell.

paulmasson avatar paulmasson commented on July 18, 2024

In order to help with this issue, I really need to see the generated script.

from mathcell.

axkr avatar axkr commented on July 18, 2024

Can we chat about general questions for example this evening on Gitter Chat?
Have questions about math formula evaluation etc,...
https://gitter.im/symja_android_library/Lobby

from mathcell.

axkr avatar axkr commented on July 18, 2024

With the JSForm() function you can now display the generated JavaScript function from Manipulate() in the online web interface.

  JSForm( Manipulate(Plot(Sin(x)*Cos(1 + a*x), {x, 0, 2*Pi}), {a,0,10}) )

It is wrapped by this JavaScript tags:

<script type="text/javascript">

var parent = document.getElementById("mathcell");

var id = generateId();
parent.id = id;
...

...
parent.update( id );

</script>

(see the question mark in the upper right corner and search for JSForm or Manipulate help)

from mathcell.

paulmasson avatar paulmasson commented on July 18, 2024

Your generated code for Manipulate(Plot(Sin(x)*Cos(1 + a*x), {x, 0, 2*Pi}), {a,0,10}) is fine. If I copy it to a local file it displays properly.

What appears to be the problem (and which I don't understand) is that your function JSON.parse() returns a string instead of a JavaScript array containing objects. That's the source of the error l.points.forEach is not a function.

I thought you said you had this example working at one point. What else has changed that would affect the behavior of JSON?

from mathcell.

paulmasson avatar paulmasson commented on July 18, 2024

Since it is now working inside an iframe this issue can be closed.

from mathcell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.