Skip to content

Commit

Permalink
Fixes plot/examples/scatter.v and adds fixed range support (vlang#62)
Browse files Browse the repository at this point in the history
* Added range property to Axis

* Added range handler to plotter.py (ignore empty ranges)

* Updated to use plot.Marker and plot.Line

Co-authored-by: Ulises Jeremias Cornejo Fandos <[email protected]>
  • Loading branch information
lucasrdrgs and ulises-jeremias authored Aug 13, 2021
1 parent 5f05287 commit 1dc8bc8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions plot/axis.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mut:
dtick f64
tickvals []f64
ticktext []string
range []f64
}

// AxisTitle handles needed data to render an axis title
Expand Down
6 changes: 3 additions & 3 deletions plot/examples/scatter.v
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ fn main() {
x: x
y: y
mode: 'lines+markers'
marker: {
size: []f64{len: x.len, init: 10.}
marker: plot.Marker{
size: []f64{len: x.len, init: 10.}
color: []string{len: x.len, init: '#FF0000'}
}
line: {
line: plot.Line{
color: '#FF0000'
}
)
Expand Down
7 changes: 7 additions & 0 deletions plot/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def is_valid_file(parser, arg):

# Read layout json file.
layout = json.load(args.layout)
# If there is no range specified, leave it as None
# and let Plotly handle it.
for ax in ['x', 'y']:
if f'{ax}axis' in layout:
if 'range' in layout[f'{ax}axis']:
if len(layout[f'{ax}axis']['range']) != 2:
layout[f'{ax}axis']['range'] = None

# Map vsl.plot.TraceType enum to Plotly objects.
type_map = {
Expand Down

0 comments on commit 1dc8bc8

Please sign in to comment.