Skip to content

Commit

Permalink
Change axis API from xAxis, yAxis to x and y.
Browse files Browse the repository at this point in the history
Taking advantage of the major bump to 2.0.0 to also make changes in
the API.
  • Loading branch information
mauriciopoppe committed Jun 11, 2024
1 parent 9224a99 commit 227e6e1
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 145 deletions.
82 changes: 41 additions & 41 deletions site/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function onSiteDependenciesLoaded() {

functionPlot({
target: '#description-sample',
yAxis: { domain: [-1, 9] },
y: { domain: [-1, 9] },
tip: {
renderer: function () {}
},
Expand All @@ -24,8 +24,8 @@ function onSiteDependenciesLoaded() {

functionPlot({
target: '#description-sin-exp-x-naive',
yAxis: { domain: [-4, 4] },
xAxis: { domain: [-2, 6] },
y: { domain: [-4, 4] },
x: { domain: [-2, 6] },
tip: {
renderer: function () {}
},
Expand All @@ -40,8 +40,8 @@ function onSiteDependenciesLoaded() {

functionPlot({
target: '#description-sin-exp-x',
yAxis: { domain: [-4, 4] },
xAxis: { domain: [-2, 6] },
y: { domain: [-4, 4] },
x: { domain: [-2, 6] },
tip: {
renderer: function () {}
},
Expand Down Expand Up @@ -88,12 +88,12 @@ function onSiteDependenciesLoaded() {
* - `title`: the title of the graph
* - `width`: width of the graph
* - `height`: height of the graph
* - `xAxis`:
* - `x`:
* - `type`: the type of scale for this axis, possible values `linear|log`
* (default value: `'linear'`)
* - `label`: x axis label
* - `domain`: x axis possible values (see examples below)
* - `yAxis`: same options as `xAxis`
* - `y`: same options as `x`
* - `disableZoom`: true to disable translation/scaling on the graph
*/
functionPlot({
Expand All @@ -102,11 +102,11 @@ function onSiteDependenciesLoaded() {
width: 580,
height: 400,
disableZoom: true,
xAxis: {
x: {
label: 'x - axis',
domain: [-6, 6]
},
yAxis: {
y: {
label: 'y - axis'
},
data: [
Expand All @@ -123,10 +123,10 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#grid',
xAxis: {
x: {
label: 'real'
},
yAxis: {
y: {
label: 'imaginary'
},
grid: true,
Expand All @@ -151,8 +151,8 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#domain',
yAxis: { domain: [-1, 1] },
xAxis: { domain: [8, 24] },
y: { domain: [-1, 1] },
x: { domain: [8, 24] },
data: [
{
fn: 'sin(x)'
Expand Down Expand Up @@ -204,7 +204,7 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#annotations',
yAxis: { domain: [-1, 9] },
y: { domain: [-1, 9] },
data: [
{
fn: 'x^2'
Expand Down Expand Up @@ -238,7 +238,7 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#closed',
xAxis: { domain: [-2, 12] },
x: { domain: [-2, 12] },
data: [
{
fn: '3 + sin(x)',
Expand All @@ -252,16 +252,16 @@ function onSiteDependenciesLoaded() {
* ### Logarithmic scales
*
* The type of each axis can be configured to be logarithmic by specifying the
* type of axis to `log` inside the `xAxis` option, note how this
* type of axis to `log` inside the `x` option, note how this
* change affects the way the functions are sampled
*/
functionPlot({
target: '#logarithmic',
xAxis: {
x: {
type: 'log',
domain: [0.01, 1]
},
yAxis: {
y: {
domain: [-100, 100]
},
grid: true,
Expand Down Expand Up @@ -391,8 +391,8 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#secant',
yAxis: { domain: [-1, 9] },
xAxis: { domain: [-3, 3] },
y: { domain: [-1, 9] },
x: { domain: [-3, 3] },
data: [
{
fn: 'x^2',
Expand Down Expand Up @@ -448,7 +448,7 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#derivative',
yAxis: { domain: [-1, 9] },
y: { domain: [-1, 9] },
data: [
{
fn: 'x^2',
Expand All @@ -469,7 +469,7 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#derivative-update',
yAxis: { domain: [-1, 9] },
y: { domain: [-1, 9] },
data: [
{
fn: 'x^2',
Expand Down Expand Up @@ -520,13 +520,13 @@ function onSiteDependenciesLoaded() {
a = functionPlot({
target: '#linked-a',
height: 250,
xAxis: { domain: [-10, 10] },
x: { domain: [-10, 10] },
data: [{ fn: 'x * x' }]
})
b = functionPlot({
target: '#linked-b',
height: 250,
xAxis: { domain: [-10, 10] },
x: { domain: [-10, 10] },
data: [{ fn: '2 * x' }]
})
a.addLink(b)
Expand All @@ -546,19 +546,19 @@ function onSiteDependenciesLoaded() {
a = functionPlot({
target: '#linked-a-multiple',
height: 250,
xAxis: { domain: [-10, 10] },
x: { domain: [-10, 10] },
data: [{ fn: 'x * x' }]
})
b = functionPlot({
target: '#linked-b-multiple',
height: 250,
xAxis: { domain: [-10, 10] },
x: { domain: [-10, 10] },
data: [{ fn: '2 * x' }]
})
c = functionPlot({
target: '#linked-c-multiple',
height: 250,
xAxis: { domain: [-10, 10] },
x: { domain: [-10, 10] },
data: [{ fn: '2' }]
})
a.addLink(b, c)
Expand Down Expand Up @@ -675,8 +675,8 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#circle-explicit',
yAxis: { domain: [-1.897959183, 1.897959183] },
xAxis: { domain: [-3, 3] },
y: { domain: [-1.897959183, 1.897959183] },
x: { domain: [-3, 3] },
data: [{ fn: 'sqrt(1 - x * x)' }, { fn: '-sqrt(1 - x * x)' }]
})

Expand Down Expand Up @@ -708,8 +708,8 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#parametric-circle',
yAxis: { domain: [-1.897959183, 1.897959183] },
xAxis: { domain: [-3, 3] },
y: { domain: [-1.897959183, 1.897959183] },
x: { domain: [-3, 3] },
data: [
{
x: 'cos(t)',
Expand All @@ -734,8 +734,8 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#butterfly-curve',
yAxis: { domain: [-4.428571429, 4.428571429] },
xAxis: { domain: [-7, 7] },
y: { domain: [-4.428571429, 4.428571429] },
x: { domain: [-7, 7] },
data: [
{
x: 'sin(t) * (exp(cos(t)) - 2 cos(4t) - sin(t/12)^5)',
Expand Down Expand Up @@ -774,8 +774,8 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#polar-circle',
yAxis: { domain: [-1.897959183, 1.897959183] },
xAxis: { domain: [-3, 3] },
y: { domain: [-1.897959183, 1.897959183] },
x: { domain: [-3, 3] },
data: [
{
r: 'r0 * cos(theta - gamma) + sqrt(a^2 - r0^2 * (sin(theta - gamma))^2)',
Expand All @@ -801,8 +801,8 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#polar-complex',
yAxis: { domain: [-1.897959183, 1.897959183] },
xAxis: { domain: [-3, 3] },
y: { domain: [-1.897959183, 1.897959183] },
x: { domain: [-3, 3] },
data: [
{
r: '2 * sin(4 theta)',
Expand Down Expand Up @@ -838,8 +838,8 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#circle-implicit',
yAxis: { domain: [-1.897959183, 1.897959183] },
xAxis: { domain: [-3, 3] },
y: { domain: [-1.897959183, 1.897959183] },
x: { domain: [-3, 3] },
data: [
{
fn: 'x * x + y * y - 1',
Expand All @@ -863,7 +863,7 @@ function onSiteDependenciesLoaded() {
functionPlot({
target: '#implicit-complex',
yAxis: { domain: [-3.795918366, 3.795918366] },
xAxis: { domain: [-6, 6] },
x: { domain: [-6, 6] },
disableZoom: true,
data: [
{
Expand Down Expand Up @@ -928,7 +928,7 @@ function onSiteDependenciesLoaded() {
*/
functionPlot({
target: '#vector',
xAxis: { domain: [-3, 8] },
x: { domain: [-3, 8] },
grid: true,
data: [
{
Expand Down
Loading

0 comments on commit 227e6e1

Please sign in to comment.