issue warning only once - apply to other backends

This commit is contained in:
t-bltg 2021-07-04 15:48:16 +02:00
parent 3536acbcc8
commit 124d2d6aa3
5 changed files with 19 additions and 18 deletions

View File

@ -355,9 +355,9 @@ end
# draw ONE symbol marker # draw ONE symbol marker
function gr_draw_marker(series, xi, yi, clims, i, msize, strokewidth, shape::Symbol) function gr_draw_marker(series, xi, yi, clims, i, msize, strokewidth, shape::Symbol)
GR.setborderwidth(strokewidth); GR.setborderwidth(strokewidth)
gr_set_bordercolor(get_markerstrokecolor(series, i)); gr_set_bordercolor(get_markerstrokecolor(series, i))
gr_set_markercolor(get_markercolor(series, clims, i)); gr_set_markercolor(get_markercolor(series, clims, i))
gr_set_transparency(get_markeralpha(series, i)) gr_set_transparency(get_markeralpha(series, i))
GR.setmarkertype(gr_markertype(shape)) GR.setmarkertype(gr_markertype(shape))
GR.setmarkersize(0.3msize / gr_nominal_size(series)) GR.setmarkersize(0.3msize / gr_nominal_size(series))
@ -1717,7 +1717,7 @@ end
function gr_draw_segments(series, x, y, fillrange, clims) function gr_draw_segments(series, x, y, fillrange, clims)
st = series[:seriestype] st = series[:seriestype]
if x !== nothing && length(x) > 1 if x !== nothing && length(x) > 1
segments = series_segments(series, st) segments = series_segments(series, st; check=true)
# do area fill # do area fill
if fillrange !== nothing if fillrange !== nothing
GR.setfillintstyle(GR.INTSTYLE_SOLID) GR.setfillintstyle(GR.INTSTYLE_SOLID)
@ -1754,7 +1754,7 @@ end
function gr_draw_segments_3d(series, x, y, z, clims) function gr_draw_segments_3d(series, x, y, z, clims)
if series[:seriestype] === :path3d && length(x) > 1 if series[:seriestype] === :path3d && length(x) > 1
lz = series[:line_z] lz = series[:line_z]
segments = series_segments(series, :path3d) segments = series_segments(series, :path3d; check=true)
for segment in segments for segment in segments
i, rng = segment.attr_index, segment.range i, rng = segment.attr_index, segment.range
lc = get_linecolor(series, clims, i) lc = get_linecolor(series, clims, i)

View File

@ -327,7 +327,7 @@ end
function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, opt) function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, opt)
# treat segments # treat segments
segments = collect(series_segments(series, series[:seriestype])) segments = collect(series_segments(series, series[:seriestype]; check=true))
sf = opt[:fillrange] sf = opt[:fillrange]
for (k, segment) in enumerate(segments) for (k, segment) in enumerate(segments)
i, rng = segment.attr_index, segment.range i, rng = segment.attr_index, segment.range

View File

@ -663,7 +663,7 @@ function plotly_series(plt::Plot, series::Series)
end end
function plotly_series_shapes(plt::Plot, series::Series, clims) function plotly_series_shapes(plt::Plot, series::Series, clims)
segments = series_segments(series) segments = series_segments(series; check=true)
plotattributes_outs = Vector{KW}(undef, length(segments)) plotattributes_outs = Vector{KW}(undef, length(segments))
# TODO: create a plotattributes_out for each polygon # TODO: create a plotattributes_out for each polygon

View File

@ -442,7 +442,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
# end # end
# push!(handles, handle) # push!(handles, handle)
# else # else
for (k, segment) in enumerate(series_segments(series, st)) for (k, segment) in enumerate(series_segments(series, st; check=true))
i, rng = segment.attr_index, segment.range i, rng = segment.attr_index, segment.range
handle = ax."plot"((arg[rng] for arg in xyargs)...; handle = ax."plot"((arg[rng] for arg in xyargs)...;
label = k == 1 ? series[:label] : "", label = k == 1 ? series[:label] : "",

View File

@ -75,22 +75,23 @@ function iter_segments(args...)
NaNSegmentsIterator(tup, n1, n2) NaNSegmentsIterator(tup, n1, n2)
end end
function series_segments(series::Series, seriestype::Symbol = :path) function series_segments(series::Series, seriestype::Symbol=:path; check=false)
x, y, z = series[:x], series[:y], series[:z] x, y, z = series[:x], series[:y], series[:z]
(x === nothing || isempty(x)) && return UnitRange{Int}[] (x === nothing || isempty(x)) && return UnitRange{Int}[]
args = RecipesPipeline.is3d(series) ? (x, y, z) : (x, y) args = RecipesPipeline.is3d(series) ? (x, y, z) : (x, y)
nan_segments = collect(iter_segments(args...)) nan_segments = collect(iter_segments(args...))
scales = :xscale, :yscale, :zscale if check
for (n, s) enumerate(args) scales = :xscale, :yscale, :zscale
scale = get(series, scales[n], :identity) for (n, s) enumerate(args)
if scale _logScales scale = get(series, scales[n], :identity)
for (i, v) enumerate(s) if scale _logScales
if v <= 0 for (i, v) enumerate(s)
msg = "Invalid negative or zero value $v found at serie index $i for $(scale) based $(scales[n])" if v <= 0
@warn msg @warn "Invalid negative or zero value $v found at series index $i for $(scale) based $(scales[n])"
@debug msg exception=(DomainError(v), stacktrace()) @debug "" exception=(DomainError(v), stacktrace())
end
end end
end end
end end