Skip to content

Commit

Permalink
Allow setting fractional y-axis min/max values in addition (#5)
Browse files Browse the repository at this point in the history
Grafana allows this and it is useful sometimes. Keeps compatibility by also still allowing Int32.
  • Loading branch information
cmur2 authored and kalinon committed Dec 21, 2019
1 parent 3a310d8 commit 4b45f0d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/crafana/models/y_axis.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ module Crafana
# Grafana graphs have two Y axes: one on the left and one on the right.
class YAxis
# :nodoc:
class IntConverter
class FloatConverter
def self.from_json(pull : JSON::PullParser)
case pull.kind
when :string
pull.read_string.to_i
pull.read_string.to_f32
else
raise "Unsupported conversion for kind: #{pull.kind}"
end
Expand All @@ -32,11 +32,11 @@ module Crafana
@[JSON::Field(key: "logBase")]
property log_base : Int32 = 1

@[JSON::Field(converter: Crafana::YAxis::IntConverter)]
property max : Int32? = nil
@[JSON::Field(converter: Crafana::YAxis::FloatConverter)]
property max : (Int32 | Float32)? = nil

@[JSON::Field(converter: Crafana::YAxis::IntConverter)]
property min : Int32? = 0
@[JSON::Field(converter: Crafana::YAxis::FloatConverter)]
property min : (Int32 | Float32)? = 0

property show : Bool = true

Expand Down

0 comments on commit 4b45f0d

Please sign in to comment.