Update documentation

This commit is contained in:
linarphy 2024-01-25 16:38:59 +01:00
parent cdb46185ef
commit 778a23516e
No known key found for this signature in database
GPG key ID: 1D42980937147C95
3 changed files with 220 additions and 32 deletions

View file

@ -26,6 +26,11 @@ This project is licensied under the Chocolate-Ware license - see the
## Changelog ## Changelog
*v 0.1.4*
- Add marker styling
- Add more option to stylize the line
- Update linestyle format
*v 0.1.3* *v 0.1.3*
- Add text support - Add text support
- Add x and y-Axis with label - Add x and y-Axis with label
@ -44,5 +49,5 @@ This project is licensied under the Chocolate-Ware license - see the
## Roadmap ## Roadmap
- Add more option to stylize the line - Update documentation
- Add **point** style - Add "pyplot" style procedural function

View file

@ -147,9 +147,9 @@ Height of the axes (relative to the [Figure](#figure))
### Axes.title ### Axes.title
*property*: **String** *property*: **Title**
Title of the axes [Title](#title) of the axes
### Axes.lines ### Axes.lines
@ -171,23 +171,43 @@ x data
y data y data
- *linestyle*(optional): **object** - *linestyle*(optional): **String**
Object defining a style for a line. The structure of the object should Style of the line between `solid`, `dotted`, `dashdot`, `dashed` or
be: empty for no line. Default value to `solid`
```json
{
color: "color",
style: "style",
}
```
where `"color"` is a string like `rgb(x,y,z)`, or `#abcdef` or a name of
a color an,d `"style"` is `solid`, `dotted`, `dashdot` or `dashed`.
Default is "black" and "solid" for color and style.
- *label*(optional): **String** - *linecolor*(optional): **String**
Label that will be displayed in the legend. Default to empty String Color of the line whith a form like `rgb(x,y,z)`, or `#abcdef` or
a name of a color. Default value to `black`
- *markerstyle*(optional): **String**
Style of the marker for each point between `circle`, `point`, `little`,
`cross` or empty for no marker. Default to `circle`
- *markercolor*(optional): **String**
Color of the marker for each point with the same format than the
*linecolor* option. Default to `black`
- *markersize*(optional): **Number**
Size of the marker for each point in pixel. Default to 5
### Axes.draw
Render the axes to the canvas
Parameters:
- *ctx*: **CanvasRenderingContext2D**
Context of the canvas
- *view*: **2dlist<Number>**
Window were to draw the canvas
## Line ## Line
@ -207,24 +227,37 @@ ydata
### Line.linestyle ### Line.linestyle
*property*: **object** *property*: **String**
Object defining a style for a line. The structure of the object should Style of the line between `solid`, `dotted`, `dashdot`, `dashed` or
be: empty for no line. Default value to `solid`
```json
{
color: "color",
style: "style",
}
```
where `"color"` is a string like `rgb(x,y,z)`, or `#abcdef` or a name of
a color and `"style"` is `solid`, `dotted`, `dashdot` or `dashed`
### Line.label ### Line.linecolor
*property*: **String** *property*: **String**
Label that will be displayed in the legend Color of the line whith a form like `rgb(x,y,z)`, or `#abcdef` or
a name of a color. Default value to `black`
### Line.markerstyle
*property*: **String**
Style of the marker for each point between `circle`, `point`, `little`,
`cross` or empty for no marker. Default to `circle`
### Line.markercolor
*property*: **String**
Color of the marker for each point with the same format than
[linecolor](#line-linecolor) property. Default to `black`
### Line.markersize
*property*: **Number**
Size of the marker for each point in pixel. Default to 5
### Line.draw ### Line.draw
@ -245,6 +278,155 @@ Box where to draw the line (absolute dimension)
Box where to draw the line (in the xdata and ydata scale). It links Box where to draw the line (in the xdata and ydata scale). It links
absolute coordinate and value. absolute coordinate and value.
### Line.drawLine
Draw a line in the given context at the given coordinates
Parameters:
- *ctx*: **CanvasRenderingContext2D**
Context of the canvas
- *x_coordinates*: **1dlist<Number>**
x coordinates
- *y_coordinates*: **1dlist<Number>**
y coordinates
### Line.drawPoints
Draw points in the given context at the given coordinates
Parameters:
- *ctx*: **CanvasRenderingContext2D**
Context of the canvas
- *x_coordinates*: **1dlist<Number>**
x coordinates
- *y_coordinates*: **1dlist<Number>**
y coordinates
## Font
An object representing a font
### Font.size
*property*: **int**
Size of the font (in pixel)
### Font.family
*property*: **String**
"Family" of the font (Times new roman, Lato, etc.)
### Font.color
*property*: **String**
Color of the font with the form `#abcdef`, `rgb(x,y,z)` or a name of a
color
## Title
Title of an axes
### Title.content
*property*: **String**
Content of a title
### Title.font
*property*: **String**
[Font](#Font) of a title
### Title.draw
Draw the title in the given box
Parameters:
- *ctx*: **CanvasRenderingContext2D**
Context of the canvas
- *box*: **2darray<Number>**
Window where to write the title on
Return:
**2darray<Number>**: New window for the plot
## Axis
Axis (x and y) of the axes (not separated xaxis and yaxis)
### Axis.number_x_tick
*property*: **int**
Number of x axis tick
### Axis.number_y_tick
*property*: **int**
Number of y axis tick
### Axis.size_tick
*property*: **int**
Size of each tick
### Axis.margin
*property*: **int**
Size of the margin
### Axis.text_height
*property*: **int**
Height of the text label
### Axis.draw
Draw xaxis and yaxis to canvas
Parameters:
- *ctx*: **CanvasRenderingContext2D**
Context of the canvas
- *box*: **2darray<Number>**
Window where to draw the axis on the canvas
- *view*: **2darray<Number>**
Window where to draw the canvas with real value (in space of plot)
Return:
**2darray<Number>**: New window where to draw the rest of the plot
## get_ext_array ## get_ext_array
Get max or min of a 1d array of number Get max or min of a 1d array of number

View file

@ -714,6 +714,7 @@ class Axis
* @param box 2darray<Number> Window where to draw the axis * @param box 2darray<Number> Window where to draw the axis
* @param view 2darray<Number> Window where to draw the canvas with the * @param view 2darray<Number> Window where to draw the canvas with the
* real value * real value
* @return 2darray<Number> New window where to draw the rest of the plot
*/ */
draw(ctx, box, view) draw(ctx, box, view)
{ {