I'm doing documentation for implementing ApexCharts into a ClojureScript program. Here's…
- User
I'm doing documentation for implementing ApexCharts into a ClojureScript program. Here's my markdown page so far. Please help me complete it.
Apex Charts and You
Required Framework to Add to Any Page
Basic Requirements
Add to ns require list:
(:require [reagent.core :as ra] ["react-apexcharts" :default Chart]) (def ApexChart (ra/adapt-react-class Chart))Helpful addons
TODO: Currently building. Presently found at:
[blueridge.dashboard.utils :as util :refer [colours]]You can use the colours as easy to remember keywords. These are the official Gojee colours.
You can use it like this:
(colours :teal :green :orange-dark :yellow :red)Example implementation
(def donut-chart [ApexChart {:options (clj->js {:chart {:id "donut-it-aint"} :labels ["more donut", "less donut", "this much donut", "most donut" "some amount of donut"] :title {:text "Ratio of Donut" :align "left"} :colors (colours :teal :green :orange :yellow :red)}) :series [45, 20, 33, 55, 40] :type "donut" :width 500}])You need to use clj->js in order for options (some charts also support names for the series, this will need to be a map) to be read properly.
Your chart :id must be unique. If it isn't, there's no big problem with displaying the chart but you will be unable to refer to the chart with other code.
:labels and :series are often connected, but not for every chart type. They should be in a vector, and will be associated in the same order as they are presented.
Available Resources
Charts
- line
- area
- bar
- pie
- donut
- column
- rangeArea
- candlestick
- radar
- polarArea
- radialBar
- bubble
- scatter
- heatmap
- treemap (There is also a sparklines variant but it was difficult to set up and I do not recommend it)
Further Options
More information can be obtained from here: https://apexcharts.com/docs/options/
- Assistant
- User
I'm trying to make a custom tooltip for this chart, but it's not working:
(defn approved-invoice-chart [drafted-amt invoiced-amt] (let [percent (get-percentage invoiced-amt drafted-amt)] [ApexChart {:options (clj->js {:chart {:id "invoice-chart" :toolbar download-option-only} :plotOptions {:radialBar {:hollow {:size "60%"} :dataLabels {:value {:offsetY 154}}}} :title {:text "Approved Invoices" :align "left"} :tooltip {:custom (str "Actual revenue is " percent "% of estimated revenue.")}} :labels [["Revenue Estimate Total" "" "Actual Revenue Total"]] ; these are styled separately to the values we want to import :subtitle {:text ["" ; total estimated revenue (str "" invoiced-amt)] ; replace with real values later :align "center" :margin 0 :offsetX 0 :offsetY 196 :floating true :style {:fontWeight "bold" :fontSize "14px"}} :colors (colours :orange-dark)}) :series [percent] :type "radialBar" :width 500 :height 400}]))
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.