From 57ebeae1add75604e773b9e0dc9d758e63784541 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Aug 2019 01:12:39 +0300 Subject: [PATCH] Replace low-level Char handling with a type recipe. --- src/recipes.jl | 5 +++++ src/series.jl | 7 ++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 9be74970..9227f189 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1101,6 +1101,11 @@ timeformatter(t) = string(Dates.Time(Dates.Nanosecond(t))) @recipe f(::Type{Dates.Time}, t::Dates.Time) = (t -> Dates.value(t), timeformatter) @recipe f(::Type{P}, t::P) where P <: Dates.Period = (t -> Dates.value(t), t -> string(P(t))) +# ------------------------------------------------- +# Characters + +@recipe f(::Type{<:AbstractChar}, ::AbstractChar) = (string, string) + # ------------------------------------------------- # Complex Numbers diff --git a/src/series.jl b/src/series.jl index d494a342..023c7c4b 100644 --- a/src/series.jl +++ b/src/series.jl @@ -7,12 +7,12 @@ # 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, AbstractChar, Missing} +const DataPoint = Union{Number, AbstractString, 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(handlechars(s)) +prepareSeriesData(s::SeriesData) = handlemissings(s) handlemissings(v) = v handlemissings(v::AbstractArray{Union{T,Missing}}) where T <: Number = replace(v, missing => NaN) @@ -20,9 +20,6 @@ handlemissings(v::AbstractArray{Union{T,Missing}}) where T <: AbstractString = r 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)]