<commit_before>(ns statspop.charts.core
  (:require [reagent.core :refer [atom create-class]]))

;; test data to be deleted in due course and replaced with calls to constructor functions from other namespaces

(def test-data-1 {:chart-type js/Chartist.Line
                  :data {:labels ["Mar-2012" "Jun-2012" "Nov-2012" "Oct-2013" "Nov-2014"]
                         :series [[1 1 6 15 25]]}
                  :options {:width  "700px"
                            :height "380px"}
                  :class "ct-chart ct-perfect-fourth"})

(def test-data-2 {:chart-type js/Chartist.Line
                       :data {:labels ["Mar-2013" "Jun-2013" "Nov-2013" "Oct-2014" "Nov-2015"]
                              :series [[25 15 6 1 1]]}
                       :options {:width  "700px"
                                 :height "380px"}
                       :class "ct-chart ct-perfect-fourth"})

;; core functions to retain.

(def chart-datom (atom nil))
;; this throws an error on initial render because there isn't a chart-type to call. I'm ok with that.  It doesn't crash.  though maybe I can try it with bogus data?  or just catch the error.


(defn show-chart
  [chart-data]
  (let [{:keys [chart-type data options]} chart-data]
    (new chart-type ".ct-chart" (clj->js data) (clj->js options))))

(defn chart-component
  [chart-datom]
  (create-class
   {:component-did-mount #(show-chart @chart-datom)
    :component-did-update #(show-chart @chart-datom)
    :display-name        "chart-component"
    :reagent-render      (fn [chart-datom]
                           [:div {:class (:class @chart-datom)}])}))<commit_msg>error cleared just by not showing the chart on mount but only on update.<commit_after>(ns statspop.charts.core
  (:require [reagent.core :refer [atom create-class]]))

;; test data to be deleted in due course and replaced with calls to constructor functions from other namespaces

(def test-data-1 {:chart-type js/Chartist.Line
                  :data {:labels ["Mar-2012" "Jun-2012" "Nov-2012" "Oct-2013" "Nov-2014"]
                         :series [[1 1 6 15 25]]}
                  :options {:width  "700px"
                            :height "380px"}
                  :class "ct-chart ct-perfect-fourth"})

(def test-data-2 {:chart-type js/Chartist.Line
                       :data {:labels ["Mar-2013" "Jun-2013" "Nov-2013" "Oct-2014" "Nov-2015"]
                              :series [[25 15 6 1 1]]}
                       :options {:width  "700px"
                                 :height "380px"}
                       :class "ct-chart ct-perfect-fourth"})

;; core functions to retain.

(def chart-datom (atom nil))

(defn show-chart
  [chart-data]
  (let [{:keys [chart-type data options]} chart-data]
    (new chart-type ".ct-chart" (clj->js data) (clj->js options))))

(defn chart-component
  [chart-datom]
  (create-class
   {:component-did-update #(show-chart @chart-datom)
    :display-name        "chart-component"
    :reagent-render      (fn [chart-datom]
                           [:div {:class (:class @chart-datom)}])}))

;; this is going to throw an error whenever the chart is taken down unless I find some way to replace it with a blank chart or blank component.  Or just not have an option to take it down?  because why bother, it'll be reset for any new page or table anyway. 
{'fraction_non_alphanumeric': 0.13046080191502094, 'fraction_numerical': 0.040694195092758824, 'mean_word_length': 2.064161319890009, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6424420', 'n_tokens_mistral': 1145, 'n_tokens_neox': 979, 'n_words': 331}