:::{.animategraph }
[]{.addElement type="line" var-x="quantity" var-y="demand" id="demand" }
[]{.addElement type="line" var-x="quantity" var-y="supply" }
[]{.addElement type="point" var-x="quantity" var-y="demand; supply" lines="true" }
[]{.addElement type="tick" var-x="2.5" var-y="2.5" label-y="$p^\\star$" label-x="$q^{\\star}$" id="equilibrium" }
[]{.move id="demand" var-x="quantity" var-y="demand_right" index=0 clone="true" }
[]{.addElement type="line" var-x="quantity" var-y="supply" }
:::
100% with minimum 100px.df attribute.
[{"x":1, "y":1}, {"x":2, "y":5}].df-label can be added to be able to call the data across different graphs.var-x and var-y attributes.:::{.animategraph var-x="x" var-y="y" df-label="df" df='[{"x":0,"y":0},{"x":1,"y":1},{"x":2,"y":4},{"x":3,"y":9},{"x":4,"y":16},{"x":5,"y":25},{"x":6,"y":36},{"x":7,"y":49},{"x":8,"y":64},{"x":9,"y":81},{"x":10,"y":100}]' }
:::jsonlite::toJSON to convert data.frame to the desired format.
'.line: plots y=f(x).point: draws a circle at (x,y) coordinate.area: fills the area between y_0 and y_1.text: adds a text at (x,y) coordinate.tick: add a label on an axis at some value.span with:
animategraph and addElement.type attribute to specify the type of the element.var-* to specify variables. * may be x, y, y1 etc.style (more on this later).line: need to specify var-x and var-y as variable names.point: need to specify var-x and var-y as coordinates.area: We need to specify var-x as a single variable name and var-y as a semicolon separated by two variable names.text: need to specify var-x and var-y as coordinates.tick: need to specify var-* for a set of values for position and label-* for a set of labels to print.
* can be either x or y, indicating the axis.data.frame in R.df to it..addElement,type="line"var-x="x" and var-y="y" (or name of other variables).
df attribute to an array of JS objects.jsonlite::toJSON(df) function in R.
span with:
.addElement,type="point"var-x="5" and var-y="5" (or any other number).
point element.var-x,var-y separated by a semicolon.
lines attribute of a point to "true".
span with:
.addElement,type="area"var-x="x", var-y="y0; y1" (or name of other variables).y0 and y1 until the first intersection.
range-x.range-x is either full or two values separated with a semicolon.
full fills the entire range.x coordinate.
intersection to indicate an intersection point.
left or right). The default is intersection; left.
:::{.animategraph df='`r jsonlite::toJSON(df)`' }
[]{ .addElement type="area" var-x="x" var-y="y; q" range-x='intersection; left' }
[]{ .addElement type="area" var-x="x" var-y="y; q" range-x='6; 9' }
[]{ .addElement type="line" var-x="x" var-y="y" }
[]{ .addElement type="line" var-x="x" var-y="q" }
:::span with:
.addElement,type="text"var-x="number" var-y="number" (coordinates).text="text to display".text may contain math expressions (more on this later).style of the span is assigned to the style of the element.
style-type: value.background-color: red; color:green;.
span with:
.addElement,type="tick"var-x="value on x axis", var-y="value on y axis".label-x="label on x axis" and label-y="label on y axis".var-* and label-* can be semicolon separated values.
style attribute.
title.$math expression$.\\ to use a Greek letter: $\\alpha$ print \alpha.Text,tick,title,axis labels,legend,ticks.
id or the df-label attribute is defined in the graph the data is attached to.df-label attribute of the graph div.span.
:::{.animategraph #data var-x="x" var-y="y" df='`r jsonlite::toJSON(df)`' df-label="data" style="height:40%;" }
[]{ .addElement type="area" var-x="x" var-y="y; yy" range-x="full" }
:::
:::{.animategraph var-x="x" var-y="y" df-label="data" style="height:40%;" }
[]{ .addElement type="line" var-x="x" var-y="y" }
:::id must be defined.
id='someString' or #someString.id must be unique within a graph.
span object with classes animategraph and move.id.var-* parameters.index attribute.
index automatically adds fragment as a class and data-fragment-index=index.
:::{.animategraph var-x="x" var-y="y" df-label="data" }
[]{ .addElement type="line" var-x="x" var-y="y" id="line1" }
[]{ .move id="line1" var-x="x" var-y="yy" index=1 }
[]{ .addElement type="point" var-x="5" var-y="25" #point1 }
[]{ .move #point1 var-x="8" var-y="50" index=0 }
[]{ .addElement type="area" var-x="x" var-y0="z" var-y1="y" range-x="full" id="area1" }
[]{ .move type="area" var-x="x" var-y0="z" var-y1="yy" range-x="full" id="area1" index=2 }
:::clone="true".
:::{.animategraph var-x="x" var-y="y" df-label="data" }
[]{ .addElement type="line" var-x="x" var-y="y" id="line1" }
[]{ .move id="line1" var-x="x" var-y="yy" index=0 clone="true" }
[]{ .move id="line1" var-x="x" var-y="q" index=1 clone="true" }
[]{ .addElement type="point" var-x="5" var-y="25" #point1 }
[]{ .move #point1 var-x="8" var-y="50" index=1 }
[]{ .addElement type="area" var-x="x" var-y0="z" var-y1="y" id="area1" }
[]{ .move type="area" var-x="x" var-y0="z" var-y1="yy" id="area1" index=3 }
:::index attribute specifies the fragment it becomes visible.index-out attribute specifies the fragment to which it becomes hidden.index and index-out attributes, you may time fade-in and fade-out.
:::{.animategraph var-x="x" var-y="y" df-label="data" }
[]{ .addElement type="line" var-x="x" var-y="y" id="line1" }
[]{ .addElement type="line" var-x="x" var-y="yy" id="line2" index="0" index-out="1" }
[]{ .addElement type="text" var-x="2" var-y="20" text="Hello!" index="1" index-out="2" }
[]{ .addElement type="point" var-x="5" var-y="25" #point1 }
:::span with classes animategraph and setAttribute.id.index.
title attribute of the graph div.animategraph-title.
label-x and label-y attributes for x and y axes (respectively).
legend attribute of graph div to "true".legend is "false".id of the line.
No Label!.showlegend attribute to "false"."true".line type.
range-x and range-y attributes.
econ Datasetecon.
quantity, demand, supply,demandCurve,supplyCurve`,*_left for left-shifted curves and *_right for righted shifted curves,
* can be anything other than quantity.Curve implies functions have curvature.
:::{.animategraph title="Linear" style="height:50%;" }
[]{.addElement type="line" var-x="quantity" var-y="demand" id="demand" }
[]{.addElement type="line" var-x="quantity" var-y="supply" }
[]{.move id="demand" var-x="quantity" var-y="demand_right" index=0 clone="true" }
:::
:::{.animategraph title="Curve" style="height:50%;" }
[]{.addElement type="line" var-x="quantity" var-y="demandCurve" }
[]{.addElement type="line" var-x="quantity" var-y="supplyCurve" id="supply" }
[]{.move var-x="quantity" var-y="supplyCurve_right" index="1" id="supply" }
:::