In addition to the above configuration options, you may also pass in any of the graph settingsbelow as part of the options object. The distinction between configuration options and graphsettings is that configuration options are properties related to the particular calculatorinstance, while graph settings are properties related to the graph state itself.
Destroy the GraphingCalculator instance, unbind event listeners, and free resources. This method should be called whenever a calculator's container element is removed from the DOM. Attempting to call methods on a GraphingCalculator object after it has been destroyed will result in a no-op and log a warning to the console.
Replace the calculator's "Delete All" button (under the "Edit List" menu) with a "Reset" button that will reset the calculator to the state represented by obj. Also, if a default state is set, the "home" zoom buttonwill reset the zoom to the viewport associated with the default state insteadof the usual Desmos default (roughly from -10 to 10, centered at the origin). Ifthe showResetButtonOnGraphpaper option is true, a small reset button willappear on the graphpaper.
The 'change' event is emitted by the calculator whenever any change occurs that will affect the persisted state of the calculator. This applies to any changes caused either by direct user interaction, or by calls to API methods.
The callback provided to observeEvent is called with two parameters: the name of the event (e.g. 'change') and an event object containing a boolean isUserInitiated property.The value of event.isUserInitiated is true if the change that triggered the event was caused by a user interacting with the graph, and false otherwise (e.g. if the changeis due to an API call like calculator.setExpression()).
Note that the calculator evaluates expressions asynchronously, so attempts to access expressionAnalysis in synchronous code may not accurately reflect the most current evaluation state. Instead, the expressionAnalysis object should be observed and referenced inside of a callback.
In addition to normal expressions that show up in the calculator's expressions list, you can create "helper expressions" that are evaluated like normal expressions, but don't show up in the expressions list. Helper expressions are useful for monitoring and reacting to what a user is doing with an embedded calculator. Every calculator object has a HelperExpression constructor for adding helper expressions to that calculator.
In addition, a point may have its dragMode set to Desmos.DragModes.AUTO, in which case the normal calculator rules for determining point behavior will be applied. For example, a point whose coordinates are both slider variables would be draggable in both the x and y directions.
The labelOrientation property specifies the desired position of a point's label, relative to the point itself.This will override the calculator's default behavior of trying to position labels in such a way as to maintain legibility.To restore this behavior, set the value back to Desmos.LabelOrientations.DEFAULT.
In authorFeatures: true mode, whenever a folder is created, it can optionally be made secret by checking the "hide this folder from students" option. The contents of these folders will be hidden when loaded into a calculator in administerSecretFolders: false mode (the default). Any expression, note, image, folder, or table can be marked readonly from Edit List Mode.
Also note that certain combinations of options are mutually exclusive. If an update wouldproduce incompatible options, additional options may be ignored or adjusted toobtain a compatible set. To prevent the calculator from making those adjustmentson your behalf, you should avoid passing in the following combinations:
The graphing calculator has a built-in random() function that returns randomsamples from lists and statistical distributions. Behind every call torandom() is a pseudorandom number generator (PRNG) that takes a seed. Whilethe seed ultimately consumed by the PRNG comprises several components, thesettings object exposes a property called randomSeed that can be observed orset.
By default, the calculator will fill its container element (with one notable exception: see GraphingCalculator.resize() immediately below). That means sizing the calculator appropriately for your layout is equivalent to sizing its containing , just like any other element on the page, with two additional considerations:
The calculator will automatically display in one of two layouts depending on its container element's width: above 450px the expressions list will be placed to the left of the graph paper; below 450px the expressions list will be placed below the graph paper.
Resize the calculator to fill its container. This will happen automatically unless the autosize constructor option is set to false. In that case, this method must be called whenever the dimensions of the calculator's container element change, and whenever the container element is added to or removed from the DOM.
pixelCoordinates are referenced to the top left of the calculator's parent DOM element---that is, the element that is passed into the GraphingCalculator constructor. Note that pixelCoordinates.top < pixelCoordinates.bottom, but mathCoordinates.top > mathCoordinates.bottom.
The calculator exposes several objects with observable properties that may be accessed via an observe method. The first argument to observe is a property string, and the second is a callback to be fired when the property changes. The attached callback represents an observer for that property. Multiple observers can be added to a single property.
GraphingCalculator.observeEvent and GraphingCalculator.unobserveEvent behave in the same way as observe and unobserve, respectively. The only difference is that, while observe is always associated with a property of an object that is being updated, observeEvent is used to listen for global calculator events (currently just 'change'). Calculator events can be namespaced in the same way that properties can. For instance, binding a callback to 'change.foo' would make it possible to remove a single observer with GraphingCalculator.unobserveEvent('change.foo').
When an expression in the calculator is selected, its corresponding curve is highlighted. Expressions may be selected even when the expressions list is not present. Currently, only one expression may be selected at a time, but in the future it may be possible to select more than one expression.
Focus the first expression in the expressions list. Note that the first expression isn't focused by default because if the calculator is embedded in a page that can be scrolled, the browser will typically scroll the focused expression into view at page load time, which may not be desirable.
Open the calculator keypad. An expression must be focused for the keypad to be open, so if no expression is focused, this method will focus the first expression. If the onscreen keypad is already open, this method has no effect.
You may also specify colors as a property on the options object in the constructor, which will override the default color palette. colors must be an object whose values are strings representing valid CSS color values. As a convenience, a calculator instance's current color palette can be accessed via Calculator.colors.
Though the calculator's fontSize property can be set to any numeric value, we provide a set of predefined font sizes for convenience. These are available through the FontSizes object.
The calculator's display language can be set to any of our supported languages using the updateSettings method. Languages are not provided by default, but they may be requested from the api/ endpoint via a lang URL parameter. The requested translations are bundled into calculator.js before it is returned, and those languages become available to any calculator instance in the page. (If you are self-hosting the API code and are interested in using languages other than English, contact partne...@desmos.com for more information.)
The default calculator configurations represent our current best thinking about how to make the calculator accessible to everyone. Changing certain options can have important accessibility implications, which API consumers should consider carefully.
When storing images remotely, it is important that they are either served from the same domain as the page that the calculator is displayed on, or that proper CORS Access-Control-Allow-Origin headers are set to allow the images to be loaded on a different domain.
In addition to the graphing calculator, Desmos offers a four function calculator and a scientific calculator. The four function and scientific calculators are created in a similar way to the graphing calculator, and support a subset of its functionality.
Note that access to the four function and scientific calculators must be separately enabled per API key. You can see which features are enabled for your API key by reading Desmos.enabledFeatures. Calling a constructor for a feature that is not enabled is an error.
The methods and events above function exactly as described for the graphing calculator. The updateSettings method is more limited in that it only supports a subset of the options available in the graphing calculator.
New stable versions of the calculator API are released once per year in April. At any given time, there is an experimental preview version, a stable version that is recommended for production, and older versions are frozen.
Karen's Calculator is a high-precision calculator. Unlike ordinary calculators, it returns completely accurate results, even with operands containing thousands of digits. If you're patient, operands and results containing hundreds of thousands of digits are possble too!
Most calculators are only accurate when dealing with numbers containing a few digits -- usually 16 to 32. When asked to calculate using larger numbers, they either fail (displaying an error) or return results that are only approximately accurate.
3a7c801d34