From 89112fb19ee3ba9a4d629cb64244938d51b6652a Mon Sep 17 00:00:00 2001 From: gered Date: Wed, 29 Jun 2016 23:49:39 -0400 Subject: [PATCH] fix chart legend rendering in production builds i've no idea why this problem occurs in production builds. maybe the clojurescript / google closure compiler is miscompiling the ".-datasets" property/field access? munging the name when it shouldn't? and if so, why did it munge that name and not e.g. ".-labels" which worked fine? --- src/mtgcoll/client/routes/stats.cljs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mtgcoll/client/routes/stats.cljs b/src/mtgcoll/client/routes/stats.cljs index 0bf052e..c28c1da 100644 --- a/src/mtgcoll/client/routes/stats.cljs +++ b/src/mtgcoll/client/routes/stats.cljs @@ -30,14 +30,18 @@ (defn- render-vertical-chart-legend [chart] - (let [data (-> chart .-data) - labels (-> data .-labels) - dataset (-> data .-datasets (aget 0))] + ;; HACK: usage of aget where '.-' notation *SHOULD* have worked + ;; (in practice, it was only not working for 'datasets' in production builds + ;; even though the js object clearly DID have this field). + ;; just changing them all to aget for consistency + (let [data (-> chart (aget "data")) + labels (-> data (aget "labels")) + dataset (-> data (aget "datasets") first)] (r/render-to-string - [:ul {:id (.-id chart)} + [:ul {:id (aget chart "id")} (map-indexed (fn [idx label] - (let [bg-color (-> dataset .-backgroundColor (aget idx))] + (let [bg-color (-> dataset (aget "backgroundColor") (aget idx))] ^{:key idx} [:li [:span {:style {:background-color bg-color}}] label]))