Skip to content

Commit

Permalink
Merge pull request #2124 from daschw/chars
Browse files Browse the repository at this point in the history
handle chars
  • Loading branch information
daschw authored Aug 7, 2019
2 parents 2ef692c + a63a924 commit 0deb703
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
# note: returns meta information... mainly for use with automatic labeling from DataFrames for now

const FuncOrFuncs{F} = Union{F, Vector{F}, Matrix{F}}
const DataPoint = Union{Number, AbstractString, Missing}
const DataPoint = Union{Number, AbstractString, AbstractChar, Missing}
const SeriesData = Union{AVec{<:DataPoint}, Function, Surface, Volume}

prepareSeriesData(x) = error("Cannot convert $(typeof(x)) to series data for plotting")
prepareSeriesData(::Nothing) = nothing
prepareSeriesData(s::SeriesData) = handlemissings(s)
prepareSeriesData(s::SeriesData) = handlemissings(handlechars(s))

handlemissings(v) = v
handlemissings(v::AbstractArray{Union{T,Missing}}) where T <: Number = replace(v, missing => NaN)
handlemissings(v::AbstractArray{Union{T,Missing}}) where T <: AbstractString = replace(v, missing => "")
handlemissings(s::Surface) = Surface(handlemissings(s.surf))
handlemissings(v::Volume) = Volume(handlemissings(v.v), v.x_extents, v.y_extents, v.z_extents)

handlechars(x) = x
handlechars(c::AVec{<:AbstractChar}) = string.(c)

# default: assume x represents a single series
convertToAnyVector(x) = Any[prepareSeriesData(x)]

Expand Down

0 comments on commit 0deb703

Please sign in to comment.