zsk
May 23, 2020, 7:22am
1
;;; ------------------------------------------ Calculating resolved options ------------------------------------------
(s/defn ^:private calculate-bin-width :- s/Num
"Calculate bin width required to cover interval [`min-value`, `max-value`] with `num-bins`."
[min-value :- s/Num, max-value :- s/Num, num-bins :- su/IntGreaterThanZero]
(u/round-to-decimals 5 (/ (- max-value min-value)
num-bins)))
(s/defn ^:private calculate-num-bins :- su/IntGreaterThanZero
"Calculate number of bins of width `bin-width` required to cover interval [`min-value`, `max-value`]."
[min-value :- s/Num, max-value :- s/Num, bin-width :- (s/constrained s/Num (complement neg?) "number >= 0")]
(long (Math/ceil (/ (- max-value min-value)
bin-width))))
(s/defn ^:private resolve-default-strategy :- [(s/one (s/enum :bin-width :num-bins) "strategy")
(s/one {:bin-width s/Num, :num-bins su/IntGreaterThanZero} "opts")]
"Determine the approprate strategy & options to use when `:default` strategy was specified."
[metadata :- {:special_type (s/maybe su/FieldType), s/Any s/Any}, min-value :- s/Num, max-value :- s/Num]
(if (isa? (:special_type metadata) :type/Coordinate)
(let [bin-width (public-settings/breakout-bin-width)]
This file has been truncated. show original
Hello, I have some unclear documents about the scale in automatic grouping. Can you tell me in detail how bin width is calculated? Do you have any melon documentation?