diff --git a/README.md b/README.md
index bec59a36..48b44618 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,20 @@
# Bonsai
-Bonsai is a library for building interactive browser-based UI.
+[Bonsai](https://github.com/janestreet/bonsai) is a library for building incremental, composable state machines.
-Documentation can be found in the [docs](./docs) directory, and API documentation
-can be found in [src/bonsai.mli](./src/bonsai.mli).
+[Bonsai_web](https://github.com/janestreet/bonsai_web) is a library for building
+interactive browser-based UI using `bonsai`.
+
+[Bonsai_examples](https://github.com/janestreet/bonsai_examples) contains example websites built using `bonsai_web`.
+
+[Bonsai_web_components](https://github.com/janestreet/bonsai_web_components) contains a collection of component libraries
+for building web applications using `bonsai_web`.
+
+[Bonsai_test](https://github.com/janestreet/bonsai_test) contains a library for testing bonsai state machines.
+
+[Bonsai_web_test](https://github.com/janestreet/bonsai_web_test) contains a library for testing bonsai web applications.
+
+[Bonsai_bench](https://github.com/janestreet/bonsai_bench) contains a library for benchmarking bonsai applications.
+
+Documentation can be found in [Bonsai web's docs](https://github.com/janestreet/bonsai_web)
+directory, and API documentation can be found in [src/proc_intf.ml](https://github.com/janestreet/bonsai_web/tree/master/docs).
diff --git a/bench/example/dune b/bench/example/dune
deleted file mode 100644
index b1d8e94b..00000000
--- a/bench/example/dune
+++ /dev/null
@@ -1,6 +0,0 @@
-(executables
- (modes byte exe)
- (names main)
- (libraries bonsai bonsai_bench)
- (preprocess
- (pps ppx_bonsai ppx_jane js_of_ocaml-ppx)))
diff --git a/bench/example/main.ml b/bench/example/main.ml
deleted file mode 100644
index 8ac217ac..00000000
--- a/bench/example/main.ml
+++ /dev/null
@@ -1,301 +0,0 @@
-open! Core
-open Bonsai.For_open
-open! Bonsai.Let_syntax
-open! Bonsai_bench
-
-let const =
- Bonsai_bench.create
- ~name:"Bonsai.const"
- ~component:(Bonsai.const 4)
- ~get_inject:(fun _ -> Nothing.unreachable_code)
- (Interaction.many [])
-;;
-
-let state =
- Bonsai_bench.create
- ~name:"Bonsai.state"
- ~component:(Bonsai.state 0 ~sexp_of_model:[%sexp_of: Int.t] ~equal:[%equal: Int.t])
- ~get_inject:(fun (_, inject) -> inject)
- Interaction.(many_with_stabilizations [ inject 1; reset_model ])
-;;
-
-module State_machine = struct
- module Action = struct
- type t =
- | Incr
- | Decr
- [@@deriving sexp, equal]
- end
-
- let component =
- Bonsai.state_machine0
- ()
- ~sexp_of_model:[%sexp_of: Int.t]
- ~equal:[%equal: Int.t]
- ~sexp_of_action:[%sexp_of: Action.t]
- ~default_model:0
- ~apply_action:(fun (_ : _ Bonsai.Apply_action_context.t) model action ->
- match action with
- | Incr -> model + 1
- | Decr -> model - 1)
- ;;
-
- let incr = Interaction.inject Action.Incr
- let decr = Interaction.inject Action.Decr
-end
-
-(* The state does not get reset by default between benchmark runs. We choose
- an interaction which is idempotent so each test run will be identical. *)
-let state_machine_idempotent =
- [ State_machine.incr; State_machine.decr; State_machine.incr; State_machine.decr ]
- |> Interaction.many_with_stabilizations
- |> Bonsai_bench.create
- ~name:"Bonsai.state_machine0: idempotent"
- ~component:State_machine.component
- ~get_inject:(fun (_, inject) -> inject)
-;;
-
-(* This state machine benchmark does not have an idempotent interaction. As a result, this
- test will cause the model to grow by 2 every time the test is run during benchmarking.
- Since (number of test runs * 2) won't exceed the range of int and the performance of
- incrementing/decrementing by 1 is ~identical between int values, this won't cause
- skewed benchmark results. *)
-let state_machine_without_reset =
- [ State_machine.incr; State_machine.decr; State_machine.incr; State_machine.incr ]
- |> Interaction.many_with_stabilizations
- |> Bonsai_bench.create
- ~name:"Bonsai.state_machine0: not idempotent; no model reset"
- ~component:State_machine.component
- ~get_inject:(fun (_, inject) -> inject)
-;;
-
-(* If it was important that the state machine restarted from the same model every time,
- then we could use [Test.create_with_resetter] to explicitly reset the model. This
- comes with an overhead cost, though, as we must reset the model and perform a
- stabilization. Note that the interaction performed in [state_machine_without_reset]
- and [state_machine_with_reset] are identical. *)
-let state_machine_with_reset =
- [ State_machine.incr; State_machine.decr; State_machine.incr; State_machine.incr ]
- |> Interaction.many_with_stabilizations
- |> Bonsai_bench.create_with_resetter
- ~name:
- "Bonsai.state_machine0: not idempotent; model reset using create_with_resetter"
- ~component:State_machine.component
- ~get_inject:(fun (_, inject) -> inject)
-;;
-
-(* We can also manually reset the component's model with [Interaction.reset_model]. The
- test above with [Test.create_with_resetter] is equivalent to this one. *)
-let state_machine_with_manual_reset =
- [ State_machine.incr
- ; State_machine.decr
- ; State_machine.incr
- ; State_machine.incr
- ; Interaction.reset_model
- ; Interaction.stabilize
- ]
- |> Interaction.many_with_stabilizations
- |> Bonsai_bench.create
- ~name:"Bonsai.state_machine0: not idempotent; model reset manually"
- ~component:State_machine.component
- ~get_inject:(fun (_, inject) -> inject)
-;;
-
-module My_triple = struct
- let component first second third =
- let%arr first = first
- and second = second
- and third = third in
- first, second, third
- ;;
-end
-
-(* This benchmark calls stabilize in between setting each of the components in the
- [My_triple] component. *)
-let piecewise_triple_stabilize_between_each =
- let first = Bonsai.Var.create 0 in
- let second = Bonsai.Var.create "" in
- let third = Bonsai.Var.create 0. in
- Interaction.
- [ change_input first 1
- ; change_input second "second"
- ; change_input third 3.
- ; change_input first 0
- ; change_input second ""
- ; change_input third 0.
- ]
- |> Interaction.many_with_stabilizations
- |> Bonsai_bench.create
- ~name:"My_triple setting components and stabilizing between each one"
- ~component:
- (My_triple.component
- (Bonsai.Var.value first)
- (Bonsai.Var.value second)
- (Bonsai.Var.value third))
- ~get_inject:(fun _ -> Nothing.unreachable_code)
-;;
-
-(* If we wanted to ensure stabilization only happened after all of the inputs were set,
- we could do the following. Since [many_with_stabilizations] just intersperses
- [stabilize]s in the list of interactions, stabilization is only inserted between the
- two [many] groups below. *)
-let piecewise_triple_stabilize_after_all =
- let first = Bonsai.Var.create 0 in
- let second = Bonsai.Var.create "" in
- let third = Bonsai.Var.create 0. in
- Interaction.
- [ many [ change_input first 1; change_input second "second"; change_input third 3. ]
- ; many [ change_input first 0; change_input second ""; change_input third 0. ]
- ]
- |> Interaction.many_with_stabilizations
- |> Bonsai_bench.create
- ~name:"My_triple setting components and stabilizing after all three"
- ~component:
- (My_triple.component
- (Bonsai.Var.value first)
- (Bonsai.Var.value second)
- (Bonsai.Var.value third))
- ~get_inject:(fun _ -> Nothing.unreachable_code)
-;;
-
-module Do_work_every_second = struct
- let component =
- Bonsai.Incr.with_clock (fun clock ->
- let%map.Ui_incr () =
- Bonsai.Time_source.at_intervals clock (Time_ns.Span.of_sec 1.0)
- in
- for _ = 1 to 1000 do
- ()
- done)
- ;;
-
- let advance_by_zero = Interaction.advance_clock_by (Time_ns.Span.of_sec 0.)
- let advance_by_second = Interaction.advance_clock_by (Time_ns.Span.of_sec 1.0)
-end
-
-let do_work_every_second_advance_by_zero =
- Bonsai_bench.create
- ~name:"Component that does work every second: advance clock by zero each run"
- ~component:Do_work_every_second.component
- ~get_inject:(fun _ -> Nothing.unreachable_code)
- Do_work_every_second.advance_by_zero
-;;
-
-let do_work_every_second_advance_by_second =
- Bonsai_bench.create
- ~name:"Component that does work every second: advance clock by a second each run"
- ~component:Do_work_every_second.component
- ~get_inject:(fun _ -> Nothing.unreachable_code)
- Do_work_every_second.advance_by_second
-;;
-
-let two_state_machines_that_alternate =
- let component =
- let%map.Computation which, set_which =
- Bonsai.state true ~sexp_of_model:[%sexp_of: Bool.t] ~equal:[%equal: Bool.t]
- and state_1, inject_1 = State_machine.component
- and state_2, inject_2 = State_machine.component in
- let inject action =
- match which with
- | true -> Effect.Many [ set_which false; inject_1 action ]
- | false -> Effect.Many [ set_which true; inject_2 action ]
- in
- (state_1, state_2), inject
- in
- [ State_machine.incr; State_machine.incr; State_machine.decr; State_machine.decr ]
- |> Interaction.many_with_stabilizations
- |> Bonsai_bench.create
- ~name:"Alternating state machines"
- ~component
- ~get_inject:(fun (_, inject) -> inject)
-;;
-
-let () = print_endline "======== Basic benchmarking ========"
-
-(* These computations will all be benchmarked by [Core_bench_js]. *)
-let () =
- let quota = Core_bench_js.Quota.Span (Time_float.Span.of_sec 1.0) in
- [ const
- ; state
- ; state_machine_idempotent
- ; state_machine_without_reset
- ; state_machine_with_reset
- ; state_machine_with_manual_reset
- ; piecewise_triple_stabilize_after_all
- ; piecewise_triple_stabilize_between_each
- ; do_work_every_second_advance_by_zero
- ; do_work_every_second_advance_by_second
- ; two_state_machines_that_alternate
- ]
- |> Bonsai_bench.benchmark ~run_config:(Core_bench_js.Run_config.create () ~quota)
-;;
-
-let () = print_endline "======== Benchmarking a computation with a bug ========"
-
-(* Sometimes, you may notice that a benchmark is suspiciously slow. In that case, it may
- be helpful to [profile] the computation to see what's taking so long. For example,
- consider the following: *)
-
-type r =
- { a : int
- ; b : Time_ns.t
- }
-
-let do_some_work a =
- for _ = 1 to a do
- Sys.opaque_identity ()
- done
-;;
-
-let component_that_does_work_too_often =
- let component =
- let%sub now = Bonsai.Clock.now in
- let%sub r =
- let%arr now = now in
- { a = 1000000; b = now }
- in
- (* BUG: The below [let%arr] will get fired every time any field in the record changes,
- i.e, whenever [Bonsai.Clock.now] updates. The body of this is expensive and depends
- only on [a]. *)
- let%arr { a; _ } = r in
- do_some_work a
- in
- Interaction.advance_clock_by (Time_ns.Span.of_ms 1.)
- |> Bonsai_bench.create
- ~name:"Component that fires too often"
- ~component
- ~get_inject:(fun _ -> Nothing.unreachable_code)
-;;
-
-let component_that_does_work_the_right_amount =
- let component =
- let%sub now = Bonsai.Clock.now in
- let%sub r =
- let%arr now = now in
- { a = 1000000; b = now }
- in
- (* This [let%sub] ensures that the below [let%arr] only depends on [a], and hence
- doesn't run when [Bonsai.Clock.now] updates. *)
- let%sub { a; _ } = return r in
- let%arr a = a in
- do_some_work a
- in
- Interaction.advance_clock_by (Time_ns.Span.of_ms 1.)
- |> Bonsai_bench.create
- ~name:"Component that fires the right amount"
- ~component
- ~get_inject:(fun _ -> Nothing.unreachable_code)
-;;
-
-let () =
- let quota = Core_bench_js.Quota.Span (Time_float.Span.of_sec 1.0) in
- [ component_that_does_work_too_often; component_that_does_work_the_right_amount ]
- |> Bonsai_bench.benchmark ~run_config:(Core_bench_js.Run_config.create () ~quota)
-;;
-
-let () = print_endline "======== Profiling computations to find the bug ========"
-
-let () =
- Bonsai_bench.profile
- [ component_that_does_work_too_often; component_that_does_work_the_right_amount ]
-;;
diff --git a/bench/example/main.mli b/bench/example/main.mli
deleted file mode 100644
index 8b434a57..00000000
--- a/bench/example/main.mli
+++ /dev/null
@@ -1 +0,0 @@
-(* This file intentionally left blank *)
diff --git a/bench/src/bonsai_bench.ml b/bench/src/bonsai_bench.ml
deleted file mode 100644
index ce95c1e0..00000000
--- a/bench/src/bonsai_bench.ml
+++ /dev/null
@@ -1,34 +0,0 @@
-open! Core
-module Interaction = Interaction
-include Config
-
-let to_core_bench_test (T { clock; name; component; get_inject; interaction } : t) =
- let bonsai_bench_initialize_run `init =
- let runner =
- Runner.initialize
- ~clock
- ~component
- ~wrap_driver_creation:{ f = (fun create_driver -> create_driver ()) }
- ~get_inject
- ~interaction
- ~filter_profiles:true
- in
- Cleanup.register_driver runner;
- fun () -> Runner.run_interactions runner ~handle_profile:(Fn.const ())
- in
- Core_bench_js.Test.create_with_initialization ~name bonsai_bench_initialize_run
-;;
-
-let benchmark ?run_config ?analysis_configs ?display_config ?save_to_file ?libname ts =
- ts
- |> List.map ~f:to_core_bench_test
- |> List.intersperse ~sep:Cleanup.invalidate_observers
- |> Core_bench_js.bench
- ?run_config
- ?analysis_configs
- ?display_config
- ?save_to_file
- ?libname
-;;
-
-let profile profiles = List.iter ~f:Profile.profile profiles
diff --git a/bench/src/bonsai_bench.mli b/bench/src/bonsai_bench.mli
deleted file mode 100644
index 2f1c6503..00000000
--- a/bench/src/bonsai_bench.mli
+++ /dev/null
@@ -1,92 +0,0 @@
-open! Core
-open Bonsai.For_open
-
-(** [t] is roughly equivalent to [Core_bench_js.Test.t], but can also be used to obtain
- [profile]s of the benchmarks. See [profile] below for more details. *)
-type t
-
-module Interaction : sig
- (** A ['action Interaction.t] represents an interaction that occurs with a
- [Component] whose action type is ['action]. *)
- type 'action t
-
- (** [change_input] sets the given [Var.t] to the supplied value. *)
- val change_input : 'a Bonsai.Var.t -> 'a -> _ t
-
- (** [inject] calls the [inject_action] function for the component being benchmarked
- with the supplied action. *)
- val inject : 'action -> 'action t
-
- (** [advance_clock_by] advances the current clock by the supplied amount. Note that the
- clock is not reset between benchmark runs. *)
- val advance_clock_by : Time_ns.Span.t -> _ t
-
- (** [stabilize] forces a stabilization of the incremental graph for the component being
- benchmarked. *)
- val stabilize : _ t
-
- (** [reset_model] resets the benchmarked component's model back to the value it was at
- the beginning of the benchmark. *)
- val reset_model : _ t
-
- (** [profile] indicates that the [profile] function below should print a snapshot of the
- time spent in each part of your computation since the previous snapshot.
-
- Note: profiling interactions are filtered out in [benchmark] runs, so you needn't
- worry about
- *)
- val profile : name:string -> _ t
-
- (** [many] is used to create lists of interactions all at once. Interactions created
- this way will get flattened prior to benchmark runtime, so that there isn't
- performance cost to using the constructor. *)
- val many : 'action t list -> 'action t
-
- (** [many_with_stabilizations] is similar to many, but intersperses [stabilize]s in the
- supplied list of actions. *)
- val many_with_stabilizations : 'action t list -> 'action t
-end
-
-(** [create] produces a benchmark which performs [interactions] on [component].
- The computation is shared between runs within the benchmark runner. Since they are
- run a non-deterministic amount of times, benchmarks created this way should either
- have an interaction which is idempotent on the state, or have similar performance
- when the interaction is repeated many times. *)
-val create
- : ?clock:Bonsai.Time_source.t
- -> name:string
- -> component:'r Computation.t
- -> get_inject:('r -> 'a -> unit Effect.t)
- -> 'a Interaction.t
- -> t
-
-(** [create_with_resetter] is equivalent to calling [create], with interactions equal to
- [Interaction.many interactions; Interaction.reset_model; Interaction.stabilize]. *)
-val create_with_resetter
- : ?clock:Bonsai.Time_source.t
- -> name:string
- -> component:'r Computation.t
- -> get_inject:('r -> 'a -> unit Effect.t)
- -> 'a Interaction.t
- -> t
-
-(** [benchmark] works identically to [Core_bench_js.bench], but ensures that [Observer]s
- involved in benchmarks are cleaned up between consecutive benchmarks. *)
-val benchmark
- : ?run_config:Core_bench_js.Run_config.t
- -> ?analysis_configs:Core_bench_js.Analysis_config.t list
- -> ?display_config:Core_bench_js.Display_config.t
- -> ?save_to_file:(Core_bench_js.Measurement.t -> string)
- -> ?libname:string
- -> t list
- -> unit
-
-(** [profile] runs a given [t] as an instrumented computation, and provides snapshots of
- how much time is spent within different parts of bonsai code. It also provides
- statistics on incremental overhead.
-
- Note: because [profile] runs on an instrumented computation, the total running time
- of the test may be higher. Furthermore, because [profile] only runs the computation
- once, timing may vary between runs. It is useful for drilling into slow benchmarks,
- but [benchmark] should be the source of truth for timing interactions. *)
-val profile : t list -> unit
diff --git a/bench/src/cleanup.ml b/bench/src/cleanup.ml
deleted file mode 100644
index 8d4ea949..00000000
--- a/bench/src/cleanup.ml
+++ /dev/null
@@ -1,17 +0,0 @@
-open! Core
-
-type packed = T : Runner.t -> packed
-
-let (most_recent_driver : packed option ref) = ref None
-let register_driver driver = most_recent_driver := Some (T driver)
-
-let invalidate_observers =
- Core_bench_js.Test.create_with_initialization
- ~name:"cleaning up observers..."
- (fun `init ->
- (match !most_recent_driver with
- | None -> ()
- | Some (T driver) -> Runner.invalidate_observers driver);
- most_recent_driver := None;
- fun () -> ())
-;;
diff --git a/bench/src/cleanup.mli b/bench/src/cleanup.mli
deleted file mode 100644
index 77455f19..00000000
--- a/bench/src/cleanup.mli
+++ /dev/null
@@ -1,4 +0,0 @@
-open! Core
-
-val register_driver : Runner.t -> unit
-val invalidate_observers : Core_bench_js.Test.t
diff --git a/bench/src/config.ml b/bench/src/config.ml
deleted file mode 100644
index eb7fb1d9..00000000
--- a/bench/src/config.ml
+++ /dev/null
@@ -1,40 +0,0 @@
-open! Core
-open! Bonsai
-
-type ('a, 'r) unpacked =
- { clock : Bonsai.Time_source.t
- ; name : string
- ; component : 'r Computation.t
- ; get_inject : 'r -> 'a -> unit Effect.t
- ; interaction : 'a Interaction.t
- }
-
-type t = T : (_, _) unpacked -> t
-
-let create
- ?(clock = Bonsai.Time_source.create ~start:Time_ns.epoch)
- ~name
- ~component
- ~get_inject
- interaction
- =
- T { clock; name; component; get_inject; interaction }
-;;
-
-let create_with_resetter
- ?(clock = Bonsai.Time_source.create ~start:Time_ns.epoch)
- ~name
- ~component
- ~get_inject
- interaction
- =
- T
- { clock
- ; name
- ; component
- ; get_inject
- ; interaction =
- [ interaction; Interaction.Reset_model; Interaction.Stabilize ]
- |> Interaction.many
- }
-;;
diff --git a/bench/src/config.mli b/bench/src/config.mli
deleted file mode 100644
index 37705d71..00000000
--- a/bench/src/config.mli
+++ /dev/null
@@ -1,28 +0,0 @@
-open! Core
-open! Bonsai
-
-type ('a, 'r) unpacked =
- { clock : Bonsai.Time_source.t
- ; name : string
- ; component : 'r Computation.t
- ; get_inject : 'r -> 'a -> unit Effect.t
- ; interaction : 'a Interaction.t
- }
-
-type t = T : (_, _) unpacked -> t
-
-val create
- : ?clock:Bonsai.Time_source.t
- -> name:string
- -> component:'r Computation.t
- -> get_inject:('r -> 'a -> unit Effect.t)
- -> 'a Interaction.t
- -> t
-
-val create_with_resetter
- : ?clock:Bonsai.Time_source.t
- -> name:string
- -> component:'r Computation.t
- -> get_inject:('r -> 'a -> unit Effect.t)
- -> 'a Interaction.t
- -> t
diff --git a/bench/src/dune b/bench/src/dune
deleted file mode 100644
index b0cff986..00000000
--- a/bench/src/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(library
- (name bonsai_bench)
- (public_name bonsai.bench)
- (libraries bonsai bonsai_driver core_bench.js incr_dom.javascript_profiling
- js_of_ocaml)
- (preprocess
- (pps ppx_jane js_of_ocaml-ppx ppx_pattern_bind)))
diff --git a/bench/src/interaction.ml b/bench/src/interaction.ml
deleted file mode 100644
index 8982792f..00000000
--- a/bench/src/interaction.ml
+++ /dev/null
@@ -1,19 +0,0 @@
-open! Core
-
-type 'action t =
- | Profile : string -> _ t
- | Change_input : 'a Bonsai.Var.t * 'a -> _ t
- | Inject : 'action -> 'action t
- | Advance_clock_by : Time_ns.Span.t -> _ t
- | Stabilize : _ t
- | Reset_model : _ t
- | Many : 'action t list -> 'action t
-
-let change_input var value = Change_input (var, value)
-let inject action = Inject action
-let advance_clock_by span = Advance_clock_by span
-let stabilize = Stabilize
-let reset_model = Reset_model
-let profile ~name = Profile name
-let many ts = Many ts
-let many_with_stabilizations ts = Many (List.intersperse ts ~sep:Stabilize)
diff --git a/bench/src/interaction.mli b/bench/src/interaction.mli
deleted file mode 100644
index 2de58c80..00000000
--- a/bench/src/interaction.mli
+++ /dev/null
@@ -1,19 +0,0 @@
-open! Core
-
-type 'action t =
- | Profile : string -> _ t
- | Change_input : 'a Bonsai.Var.t * 'a -> _ t
- | Inject : 'action -> 'action t
- | Advance_clock_by : Time_ns.Span.t -> _ t
- | Stabilize : _ t
- | Reset_model : _ t
- | Many : 'action t list -> 'action t
-
-val advance_clock_by : Time_ns.Span.t -> _ t
-val change_input : 'a Bonsai.Var.t -> 'a -> _ t
-val inject : 'action -> 'action t
-val stabilize : _ t
-val reset_model : _ t
-val profile : name:string -> 'a t
-val many : 'action t list -> 'action t
-val many_with_stabilizations : 'action t list -> 'action t
diff --git a/bench/src/profile.ml b/bench/src/profile.ml
deleted file mode 100644
index 2098b572..00000000
--- a/bench/src/profile.ml
+++ /dev/null
@@ -1,293 +0,0 @@
-open! Core
-open Js_of_ocaml
-module Graph_info = Bonsai.Private.Graph_info
-
-module Id = struct
- let instance = String.Table.create ()
-
- let of_node_path node_path =
- let key = Bonsai.Private.Node_path.to_string node_path in
- match Hashtbl.find instance key with
- | Some id -> id
- | None ->
- let id = Hashtbl.length instance in
- Hashtbl.set instance ~key ~data:id;
- id
- ;;
-end
-
-module Measurement = struct
- module Kind = struct
- module T = struct
- type t =
- | Startup
- | Snapshot
- | Named of string
- [@@deriving sexp, equal, compare]
- end
-
- include T
- include Comparable.Make_plain (T)
-
- let time_to_first_stabilization = "Bonsai_bench profile: first stabilization"
- let time_since_snapshot_began = "Bonsai_bench profile: current snapshot"
-
- let to_string = function
- | Named s -> s
- | Startup -> time_to_first_stabilization
- | Snapshot -> time_since_snapshot_began
- ;;
-
- let of_string s =
- if String.equal time_to_first_stabilization s
- then Startup
- else if String.equal time_since_snapshot_began s
- then Snapshot
- else Named s
- ;;
-
- let is_bonsai_measurement = function
- | Named _ -> true
- | _ -> false
- ;;
- end
-
- type t =
- { kind : Kind.t
- ; duration : float
- ; id : int option
- }
- [@@deriving sexp]
-
- let create ~label ~duration = { kind = Kind.of_string label; duration; id = None }
- let before label = label ^ "_before"
- let after label = label ^ "_after"
- let mark_before t = Javascript_profiling.Manual.mark (before (Kind.to_string t))
-
- let mark_after_and_measure t =
- let name = Kind.to_string t in
- let before = before name in
- let after = after name in
- Javascript_profiling.Manual.mark after;
- Javascript_profiling.Manual.measure ~name ~start:before ~end_:after
- ;;
-end
-
-module Accumulated_measurement = struct
- type t =
- { kind : Measurement.Kind.t
- ; total_duration : float
- ; count : int
- ; id : int option
- }
- [@@deriving sexp]
-
- let compare
- { kind; total_duration; _ }
- { kind = kind'; total_duration = total_duration'; _ }
- =
- match kind, kind' with
- | Named _, Named _ -> Float.descending total_duration total_duration'
- | _, _ -> Measurement.Kind.compare kind kind'
- ;;
-
- let of_measurement { Measurement.kind; duration; id } =
- { kind; count = 1; total_duration = duration; id }
- ;;
-
- let add { kind; total_duration; count; id } ~measurement =
- assert (Measurement.Kind.equal kind measurement.Measurement.kind);
- { kind
- ; count = count + 1
- ; total_duration = total_duration +. measurement.duration
- ; id
- }
- ;;
-end
-
-let create_summary_table ~total_time ~incremental_time =
- let open Ascii_table_kernel in
- to_string_noattr
- [ Column.create "Statistic" fst; Column.create "Value" snd ]
- ~limit_width_to:Int.max_value
- ~bars:`Unicode
- [ "Total time (ms)", Float.to_string total_time
- ; "Incremental time (ms)", Float.to_string incremental_time
- ; "Incremental Overhead (ms)", Float.to_string (total_time -. incremental_time)
- ; ( "Incremental Overhead (%)"
- , Percent.Always_percentage.to_string
- (Percent.of_percentage ((total_time -. incremental_time) /. total_time *. 100.))
- )
- ]
-;;
-
-let create_snapshot_table data ~incremental_time =
- let open Ascii_table_kernel in
- let columns =
- [ Column.create "Id" (fun { Accumulated_measurement.id; _ } ->
- match id with
- | Some int -> Int.to_string int
- | None -> "N/A")
- ; Column.create "Name" (fun { Accumulated_measurement.kind; _ } ->
- Measurement.Kind.to_string kind)
- ; Column.create "Times fired" (fun { Accumulated_measurement.count; _ } ->
- Int.to_string count)
- ; Column.create
- "Total time (ms)"
- (fun { Accumulated_measurement.total_duration; _ } ->
- Float.to_string total_duration)
- ; Column.create
- "Percent of incremental time"
- (fun { Accumulated_measurement.total_duration; _ } ->
- Percent.Always_percentage.to_string
- (Percent.of_percentage (total_duration /. incremental_time *. 100.)))
- ]
- in
- to_string_noattr columns data ~limit_width_to:Int.max_value ~bars:`Unicode
-;;
-
-let print_statistics data =
- let sorted_data = List.sort (Map.data data) ~compare:Accumulated_measurement.compare in
- let incremental_measurements, bonsai_bench_internals =
- List.partition_tf sorted_data ~f:(fun { kind; _ } ->
- Measurement.Kind.is_bonsai_measurement kind)
- in
- let total_time =
- match bonsai_bench_internals with
- | [ { Accumulated_measurement.total_duration; _ } ] -> total_duration
- | _ ->
- raise_s
- [%message
- "An error occurred while profiling your computation. Bonsai bench expected \
- only one internal measurement. Please report this error to the bonsai team."
- ~internal_measurements:
- (bonsai_bench_internals : Accumulated_measurement.t list)]
- in
- let incremental_time =
- List.sum
- (module Float)
- incremental_measurements
- ~f:(fun { kind; total_duration; _ } ->
- if Measurement.Kind.is_bonsai_measurement kind then total_duration else 0.)
- in
- print_endline "Summary:";
- print_endline (create_summary_table ~total_time ~incremental_time);
- print_endline "Details:";
- print_endline (create_snapshot_table incremental_measurements ~incremental_time)
-;;
-
-let accumulate_measurements
- ~(source_locations : Graph_info.Node_info.t Bonsai.Private.Node_path.Map.t)
- measurements
- =
- let with_ids, without_ids =
- List.map measurements ~f:(fun measurement ->
- match measurement.Measurement.kind with
- | Snapshot | Startup -> measurement
- | Named label ->
- Option.value
- ~default:measurement
- (let%bind.Option node_path =
- Bonsai.Private.Instrumentation.extract_node_path_from_entry_label label
- in
- let%bind.Option { node_type; here } = Map.find source_locations node_path in
- let%map.Option here = here in
- { measurement with
- kind = Named [%string "%{node_type} (%{here#Source_code_position})"]
- ; id = Some (Id.of_node_path node_path)
- }))
- |> List.fold
- ~init:(Int.Map.empty, Measurement.Kind.Map.empty)
- ~f:(fun (with_ids, without_ids) measurement ->
- let accumulate_measurements = function
- | None -> Accumulated_measurement.of_measurement measurement
- | Some accumulated -> Accumulated_measurement.add accumulated ~measurement
- in
- match measurement.id with
- | None ->
- with_ids, Map.update without_ids measurement.kind ~f:accumulate_measurements
- | Some id -> Map.update with_ids id ~f:accumulate_measurements, without_ids)
- in
- Map.fold without_ids ~init:with_ids ~f:(fun ~key:_ ~data:measurement acc ->
- let id =
- match Map.max_elt acc with
- (* This could happen if the user never [let%sub]s. It's not very realistic for a
- practical app, but totally possible to write. *)
- | None -> 0
- | Some (id, _) -> id + 1
- in
- let measurement = { measurement with id = Some id } in
- Map.set acc ~key:id ~data:measurement)
-;;
-
-let take_profile_snapshot ~name graph_info performance_entries =
- match List.length !performance_entries with
- | 0 | 1 -> ()
- | _ ->
- print_endline [%string "Bonsai_bench Profile: %{name}"];
- let source_locations =
- Graph_info.pull_source_locations_from_nearest_parent graph_info
- in
- print_statistics (accumulate_measurements ~source_locations !performance_entries);
- performance_entries := []
-;;
-
-let profile (T { clock; component; get_inject; interaction; name } : Config.t) =
- print_endline [%string "Running Bonsai_bench profile of %{name}"];
- let graph_info = ref Graph_info.empty in
- let component =
- Bonsai.Debug.instrument_computation
- component
- ~start_timer:(fun s -> Measurement.mark_before (Named s))
- ~stop_timer:(fun s -> Measurement.mark_after_and_measure (Named s))
- in
- let component =
- Graph_info.iter_graph_updates
- (Bonsai.Private.top_level_handle component)
- ~on_update:(fun gi -> graph_info := gi)
- in
- let component graph = Bonsai.Private.perform graph component in
- let performance_entries = ref [] in
- let performance_observer =
- if PerformanceObserver.is_supported ()
- then
- PerformanceObserver.observe ~entry_types:[ "measure" ] ~f:(fun entries _ ->
- Array.iter
- (Js.to_array entries##getEntries)
- ~f:(fun entry ->
- let label = Js.to_string entry##.name in
- let duration = entry##.duration in
- performance_entries
- := Measurement.create ~label ~duration :: !performance_entries))
- else
- failwith
- "PerformanceObserver could not be found. Please reach out to webdev-public on \
- symphony for assistance."
- in
- let handle_profile name =
- Measurement.mark_after_and_measure Snapshot;
- take_profile_snapshot ~name !graph_info performance_entries;
- Measurement.mark_before Snapshot
- in
- let runner =
- Runner.initialize
- ~filter_profiles:false
- ~wrap_driver_creation:
- { f =
- (fun create_driver ->
- Measurement.mark_before Startup;
- let driver = create_driver () in
- Measurement.mark_after_and_measure Startup;
- driver)
- }
- ~clock
- ~component
- ~get_inject
- ~interaction
- in
- take_profile_snapshot ~name:"startup" !graph_info performance_entries;
- Measurement.mark_before Snapshot;
- Runner.run_interactions runner ~handle_profile;
- performance_observer##disconnect;
- Runner.invalidate_observers runner
-;;
diff --git a/bench/src/profile.mli b/bench/src/profile.mli
deleted file mode 100644
index 9458baf6..00000000
--- a/bench/src/profile.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-open! Core
-
-val profile : Config.t -> unit
diff --git a/bench/src/runner.ml b/bench/src/runner.ml
deleted file mode 100644
index 34c4107d..00000000
--- a/bench/src/runner.ml
+++ /dev/null
@@ -1,86 +0,0 @@
-open! Core
-open Bonsai
-
-type t =
- | T :
- { driver : 'r Bonsai_driver.t
- ; clock : Bonsai.Time_source.t
- ; inject_action : 'a -> unit Effect.t
- ; interactions : 'a Interaction.t array
- }
- -> t
-
-type wrap_create = { f : 'a. (unit -> 'a) -> 'a } [@@unboxed]
-
-let handle_interaction ~driver ~clock ~inject_action ~handle_profile interaction =
- match (interaction : _ Interaction.t) with
- | Profile name -> handle_profile name
- | Stabilize -> Bonsai_driver.flush driver
- | Reset_model -> Bonsai_driver.Expert.reset_model_to_default driver
- | Change_input (var, value) -> Var.set var value
- | Inject action -> Bonsai_driver.schedule_event driver (inject_action action)
- | Advance_clock_by span -> Bonsai.Time_source.advance_clock_by clock span
- | Many _ ->
- (* We flatten the interaction structure prior to running the benchmark. *)
- assert false
-;;
-
-let rec flatten_interactions_to_list = function
- | Interaction.Many nested -> List.concat_map nested ~f:flatten_interactions_to_list
- | t -> [ t ]
-;;
-
-let dedup_stabilizations interactions =
- let both_stabilize (t : _ Interaction.t) (t' : _ Interaction.t) =
- match t, t' with
- | Stabilize, Stabilize -> true
- | _ -> false
- in
- List.remove_consecutive_duplicates interactions ~equal:both_stabilize
-;;
-
-(* We perform two optimizations in this step: flattening the interactions and deduping
- stabilizations. Flattening the structure ensures that there's no additional
- overhead to nesting lots of [Many]s when creating benchmarks. Consecutive
- [Stabilize]s don't add anything to benchmarks and would add a function call of
- overhead. *)
-let initialize
- ~filter_profiles
- ~wrap_driver_creation
- ~clock
- ~component
- ~get_inject
- ~interaction
- =
- let driver = wrap_driver_creation.f (fun () -> Bonsai_driver.create ~clock component) in
- let inject_action action =
- (* Calling Driver.result every time that inject_action is called
- is important because the value can change during stabilization *)
- let result = Bonsai_driver.result driver in
- (get_inject result) action
- in
- let interactions =
- Interaction.many
- [ Interaction.stabilize
- ; interaction
- ; Interaction.stabilize
- ; Interaction.profile ~name:"end of run"
- ]
- |> flatten_interactions_to_list
- |> List.filter ~f:(fun interaction ->
- match filter_profiles, interaction with
- | true, Profile _ -> false
- | _ -> true)
- |> dedup_stabilizations
- |> Array.of_list
- in
- T { driver; clock; inject_action; interactions }
-;;
-
-let run_interactions (T { driver; clock; inject_action; interactions }) ~handle_profile =
- Array.iter
- interactions
- ~f:(handle_interaction ~driver ~clock ~inject_action ~handle_profile)
-;;
-
-let invalidate_observers (T t) = Bonsai_driver.Expert.invalidate_observers t.driver
diff --git a/bench/src/runner.mli b/bench/src/runner.mli
deleted file mode 100644
index fcf82185..00000000
--- a/bench/src/runner.mli
+++ /dev/null
@@ -1,16 +0,0 @@
-open Bonsai.For_open
-
-type t
-type wrap_create = { f : 'a. (unit -> 'a) -> 'a } [@@unboxed]
-
-val initialize
- : filter_profiles:bool
- -> wrap_driver_creation:wrap_create
- -> clock:Bonsai.Time_source.t
- -> component:'r Computation.t
- -> get_inject:('r -> 'a -> unit Effect.t)
- -> interaction:'a Interaction.t
- -> t
-
-val run_interactions : t -> handle_profile:(string -> unit) -> unit
-val invalidate_observers : t -> unit
diff --git a/bindings/dygraph/README.md b/bindings/dygraph/README.md
deleted file mode 100644
index f7009a85..00000000
--- a/bindings/dygraph/README.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# Dygraph
-
-Bindings to dygraphs, a javascript graphing library, using gen_js_api.
-
- Dygraphs: http://dygraphs.com/
- API: http://dygraphs.com/jsdoc/symbols/Dygraph.html
- Options Reference: http://dygraphs.com/options.html
-
-## High level overview
-
-- Graph: A dygraph. This API is actually surprisingly small since
- almost all options live in...
-
-- Options: Where you can control almost any aspect of the graph. Each
- option should be documented, which is copied from
- http://dygraphs.com/options.html.
-
-- Data: Dygraphs can take data of a few formats (the x-values can be
- floats, dates, or times). This module provides nice [create]
- functions for each of these options.
-
-- With_bonsai: **The recommended way to use a dygraph (with bonsai).**
-
-## Sharp corners
-
-### CSP (content security policy)
-
-The default content security policy for simple web server does not
-allow unsafe inline styles, even from self. Unfortunately, dygraphs
-does this. So in order to not have error messages in your console
-when using dygraphs, you should use
-`Content_security_policy.default_for_clientside_rendering_internal` in
-your web server.
-
-## Examples
-
-See lib/dygraph/examples for a few ocaml and javascript examples.
-`Stock chart` in particular is good because we have both the ocaml and
-javascript example so that you can compare.
-
-## References:
-
-- http://dygraphs.com/
-- http://dygraphs.com/jsdoc/symbols/Dygraph.html
-- http://dygraphs.com/options.html.
-- http://dygraphs.com/data.html
-- http://dygraphs.com/gallery
diff --git a/bindings/dygraph/dist/LICENSE-dygraph b/bindings/dygraph/dist/LICENSE-dygraph
deleted file mode 100644
index 536c0a8b..00000000
--- a/bindings/dygraph/dist/LICENSE-dygraph
+++ /dev/null
@@ -1,22 +0,0 @@
-Copyright (c) 2009 Dan Vanderkam
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
diff --git a/bindings/dygraph/dist/LICENSE-lodash b/bindings/dygraph/dist/LICENSE-lodash
deleted file mode 100644
index 4773fd8e..00000000
--- a/bindings/dygraph/dist/LICENSE-lodash
+++ /dev/null
@@ -1,49 +0,0 @@
-The MIT License
-
-Copyright JS Foundation and other contributors
alert(point);
}",
- "default": "null",
- "labels": ["Callbacks", "Interactive Elements"],
- "type": "function(e, point)",
- "parameters": [["e", "the event object for the click"], ["point", "the point that was clicked See Point properties for details"]],
- "description": "A function to call when a data point is clicked. and the point that was clicked."
- },
- "color": {
- "default": "(see description)",
- "labels": ["Data Series Colors"],
- "type": "string",
- "example": "red",
- "description": "A per-series color definition. Used in conjunction with, and overrides, the colors option."
- },
- "colors": {
- "default": "(see description)",
- "labels": ["Data Series Colors"],
- "type": "array[ {name: 'series', yval: y-value}, … ]
"], ["row", "integer index of the highlighted row in the data table, starting from 0"], ["seriesName", "name of the highlighted series, only present if highlightSeriesOpts is set."]]
- },
- "drawHighlightPointCallback": {
- "default": "null",
- "labels": ["Data Line display"],
- "type": "function(g, seriesName, canvasContext, cx, cy, color, pointSize)",
- "parameters": [["g", "the reference graph"], ["seriesName", "the name of the series"], ["canvasContext", "the canvas to draw on"], ["cx", "center x coordinate"], ["cy", "center y coordinate"], ["color", "series color"], ["pointSize", "the radius of the image."], ["idx", "the row-index of the point in the data."]],
- "description": "Draw a custom item when a point is highlighted. Default is a small dot matching the series color. This method should constrain drawing to within pointSize pixels from (cx, cy) Also see drawPointCallback"
- },
- "highlightSeriesOpts": {
- "default": "null",
- "labels": ["Interactive Elements"],
- "type": "Object",
- "description": "When set, the options from this object are applied to the timeseries closest to the mouse pointer for interactive highlighting. See also 'highlightCallback'. Example: highlightSeriesOpts: { strokeWidth: 3 }."
- },
- "highlightSeriesBackgroundAlpha": {
- "default": "0.5",
- "labels": ["Interactive Elements"],
- "type": "float",
- "description": "Fade the background while highlighting series. 1=fully visible background (disable fading), 0=hiddden background (show highlighted series only)."
- },
- "highlightSeriesBackgroundColor": {
- "default": "rgb(255, 255, 255)",
- "labels": ["Interactive Elements"],
- "type": "string",
- "description": "Sets the background color used to fade out the series in conjunction with 'highlightSeriesBackgroundAlpha'."
- },
- "includeZero": {
- "default": "false",
- "labels": ["Axis display"],
- "type": "boolean",
- "description": "Usually, dygraphs will use the range of the data plus some padding to set the range of the y-axis. If this option is set, the y-axis will always include zero, typically as the lowest value. This can be used to avoid exaggerating the variance in the data"
- },
- "rollPeriod": {
- "default": "1",
- "labels": ["Error Bars", "Rolling Averages"],
- "type": "integer >= 1",
- "description": "Number of days over which to average data. Discussed extensively above."
- },
- "unhighlightCallback": {
- "default": "null",
- "labels": ["Callbacks"],
- "type": "function(event)",
- "parameters": [["event", "the mouse event"]],
- "description": "When set, this callback gets called every time the user stops highlighting any point by mousing out of the graph."
- },
- "axisTickSize": {
- "default": "3.0",
- "labels": ["Axis display"],
- "type": "number",
- "description": "The size of the line to display next to each tick mark on x- or y-axes."
- },
- "labelsSeparateLines": {
- "default": "false",
- "labels": ["Legend"],
- "type": "boolean",
- "description": "Put <br/>
between lines in the label string. Often used in conjunction with labelsDiv."
- },
- "valueFormatter": {
- "default": "Depends on the type of your data.",
- "labels": ["Legend", "Value display/formatting"],
- "type": "function(num or millis, opts, seriesName, dygraph, row, col)",
- "description": "Function to provide a custom display format for the values displayed on mouseover. This does not affect the values that appear on tick marks next to the axes. To format those, see axisLabelFormatter. This is usually set on a per-axis basis. .",
- "parameters": [["num_or_millis", "The value to be formatted. This is always a number. For date axes, it's millis since epoch. You can call new Date(millis) to get a Date object."], ["opts", "This is a function you can call to access various options (e.g. opts('labelsKMB')). It returns per-axis values for the option when available."], ["seriesName", "The name of the series from which the point came, e.g. 'X', 'Y', 'A', etc."], ["dygraph", "The dygraph object for which the formatting is being done"], ["row", "The row of the data from which this point comes. g.getValue(row, 0) will return the x-value for this point."], ["col", "The column of the data from which this point comes. g.getValue(row, col) will return the original y-value for this point. This can be used to get the full confidence interval for the point, or access un-rolled values for the point."]]
- },
- "annotationMouseOverHandler": {
- "default": "null",
- "labels": ["Annotations"],
- "type": "function(annotation, point, dygraph, event)",
- "description": "If provided, this function is called whenever the user mouses over an annotation."
- },
- "annotationMouseOutHandler": {
- "default": "null",
- "labels": ["Annotations"],
- "type": "function(annotation, point, dygraph, event)",
- "parameters": [["annotation", "the annotation left"], ["point", "the point associated with the annotation"], ["dygraph", "the reference graph"], ["event", "the mouse event"]],
- "description": "If provided, this function is called whenever the user mouses out of an annotation."
- },
- "annotationClickHandler": {
- "default": "null",
- "labels": ["Annotations"],
- "type": "function(annotation, point, dygraph, event)",
- "parameters": [["annotation", "the annotation left"], ["point", "the point associated with the annotation"], ["dygraph", "the reference graph"], ["event", "the mouse event"]],
- "description": "If provided, this function is called whenever the user clicks on an annotation."
- },
- "annotationDblClickHandler": {
- "default": "null",
- "labels": ["Annotations"],
- "type": "function(annotation, point, dygraph, event)",
- "parameters": [["annotation", "the annotation left"], ["point", "the point associated with the annotation"], ["dygraph", "the reference graph"], ["event", "the mouse event"]],
- "description": "If provided, this function is called whenever the user double-clicks on an annotation."
- },
- "drawCallback": {
- "default": "null",
- "labels": ["Callbacks"],
- "type": "function(dygraph, is_initial)",
- "parameters": [["dygraph", "The graph being drawn"], ["is_initial", "True if this is the initial draw, false for subsequent draws."]],
- "description": "When set, this callback gets called every time the dygraph is drawn. This includes the initial draw, after zooming and repeatedly while panning."
- },
- "labelsKMG2": {
- "default": "false",
- "labels": ["Value display/formatting"],
- "type": "boolean",
- "description": "Show k/M/G for kilo/Mega/Giga on y-axis. This is different than labelsKMB
in that it uses base 2, not 10."
- },
- "delimiter": {
- "default": ",",
- "labels": ["CSV parsing"],
- "type": "string",
- "description": "The delimiter to look for when separating fields of a CSV file. Setting this to a tab is not usually necessary, since tab-delimited data is auto-detected."
- },
- "axisLabelFontSize": {
- "default": "14",
- "labels": ["Axis display"],
- "type": "integer",
- "description": "Size of the font (in pixels) to use in the axis labels, both x- and y-axis."
- },
- "underlayCallback": {
- "default": "null",
- "labels": ["Callbacks"],
- "type": "function(context, area, dygraph)",
- "parameters": [["context", "the canvas drawing context on which to draw"], ["area", "An object with {x,y,w,h} properties describing the drawing area."], ["dygraph", "the reference graph"]],
- "description": "When set, this callback gets called before the chart is drawn. It details on how to use this."
- },
- "width": {
- "default": "480",
- "labels": ["Overall display"],
- "type": "integer",
- "description": "Width, in pixels, of the chart. If the container div has been explicitly sized, this will be ignored."
- },
- "pixelRatio": {
- "default": "(devicePixelRatio / context.backingStoreRatio)",
- "labels": ["Overall display"],
- "type": "float",
- "description": "Overrides the pixel ratio scaling factor for the canvas's 2d context. Ordinarily, this is set to the devicePixelRatio / (context.backingStoreRatio || 1), so on mobile devices, where the devicePixelRatio can be somewhere around 3, performance can be improved by overriding this value to something less precise, like 1, at the expense of resolution."
- },
- "interactionModel": {
- "default": "...",
- "labels": ["Interactive Elements"],
- "type": "Object",
- "description": "TODO(konigsberg): document this"
- },
- "ticker": {
- "default": "Dygraph.dateTicker or Dygraph.numericTicks",
- "labels": ["Axis display"],
- "type": "function(min, max, pixels, opts, dygraph, vals) -> [{v: ..., label: ...}, ...]",
- "parameters": [["min", ""], ["max", ""], ["pixels", ""], ["opts", ""], ["dygraph", "the reference graph"], ["vals", ""]],
- "description": "This lets you specify an arbitrary function to generate tick marks on an axis. The tick marks are an array of (value, label) pairs. The built-in functions go to great lengths to choose good tick marks so, if you set this option, you'll most likely want to call one of them and modify the result. See dygraph-tickers.js for an extensive discussion. This is set on a per-axis basis."
- },
- "xAxisHeight": {
- "default": "(null)",
- "labels": ["Axis display"],
- "type": "integer",
- "description": "Height, in pixels, of the x-axis. If not set explicitly, this is computed based on axisLabelFontSize and axisTickSize."
- },
- "showLabelsOnHighlight": {
- "default": "true",
- "labels": ["Interactive Elements", "Legend"],
- "type": "boolean",
- "description": "Whether to show the legend upon mouseover."
- },
- "axis": {
- "default": "(none)",
- "labels": ["Axis display"],
- "type": "string",
- "description": "Set to either 'y1' or 'y2' to assign a series to a y-axis (primary or secondary). Must be set per-series."
- },
- "pixelsPerLabel": {
- "default": "70 (x-axis) or 30 (y-axes)",
- "labels": ["Axis display", "Grid"],
- "type": "integer",
- "description": "Number of pixels to require between each x- and y-label. Larger values will yield a sparser axis with fewer ticks. This is set on a per-axis basis."
- },
- "labelsDiv": {
- "default": "null",
- "labels": ["Legend"],
- "type": "DOM element or string",
- "example": "document.getElementById('foo')
or'foo'",
- "description": "Show data labels in an external div, rather than on the graph. This value can either be a div element or a div id."
- },
- "fractions": {
- "default": "false",
- "labels": ["CSV parsing", "Error Bars"],
- "type": "boolean",
- "description": "When set, attempt to parse each cell in the CSV file as \"a/b\", where a and b are integers. The ratio will be plotted. This allows computation of Wilson confidence intervals (see below)."
- },
- "logscale": {
- "default": "false",
- "labels": ["Axis display"],
- "type": "boolean",
- "description": "When set for the y-axis or x-axis, the graph shows that axis in log scale. Any values less than or equal to zero are not displayed. Showing log scale with ranges that go below zero will result in an unviewable graph.\n\n Not compatible with showZero. connectSeparatedPoints is ignored. This is ignored for date-based x-axes."
- },
- "strokeWidth": {
- "default": "1.0",
- "labels": ["Data Line display"],
- "type": "float",
- "example": "0.5, 2.0",
- "description": "The width of the lines connecting data points. This can be used to increase the contrast or some graphs."
- },
- "strokePattern": {
- "default": "null",
- "labels": ["Data Line display"],
- "type": "array
visibility
and setVisibility
methods."
- },
- "valueRange": {
- "default": "Full range of the input is shown",
- "labels": ["Axis display"],
- "type": "Array of two numbers",
- "example": "[10, 110]",
- "description": "Explicitly set the vertical range of the graph to [low, high]. This may be set on a per-axis basis to define each y-axis separately. If either limit is unspecified, it will be calculated automatically (e.g. [null, 30] to automatically calculate just the lower bound)"
- },
- "colorSaturation": {
- "default": "1.0",
- "labels": ["Data Series Colors"],
- "type": "float (0.0 - 1.0)",
- "description": "If colors is not specified, saturation of the automatically-generated data series colors."
- },
- "hideOverlayOnMouseOut": {
- "default": "true",
- "labels": ["Interactive Elements", "Legend"],
- "type": "boolean",
- "description": "Whether to hide the legend when the mouse leaves the chart area."
- },
- "legend": {
- "default": "onmouseover",
- "labels": ["Legend"],
- "type": "string",
- "description": "When to display the legend. By default, it only appears when a user mouses over the chart. Set it to \"always\" to always display a legend of some sort. When set to \"follow\", legend follows highlighted points."
- },
- "legendFormatter": {
- "default": "null",
- "labels": ["Legend"],
- "type": "function(data): string",
- "params": [["data", "An object containing information about the selection (or lack of a selection). This includes formatted values and series information. See here for sample values."]],
- "description": "Set this to supply a custom formatter for the legend. See this comment and the legendFormatter demo for usage."
- },
- "labelsShowZeroValues": {
- "default": "true",
- "labels": ["Legend"],
- "type": "boolean",
- "description": "Show zero value labels in the labelsDiv."
- },
- "stepPlot": {
- "default": "false",
- "labels": ["Data Line display"],
- "type": "boolean",
- "description": "When set, display the graph as a step plot instead of a line plot. This option may either be set for the whole graph or for single series."
- },
- "labelsUTC": {
- "default": "false",
- "labels": ["Value display/formatting", "Axis display"],
- "type": "boolean",
- "description": "Show date/time labels according to UTC (instead of local time)."
- },
- "labelsKMB": {
- "default": "false",
- "labels": ["Value display/formatting"],
- "type": "boolean",
- "description": "Show K/M/B for thousands/millions/billions on y-axis."
- },
- "rightGap": {
- "default": "5",
- "labels": ["Overall display"],
- "type": "integer",
- "description": "Number of pixels to leave blank at the right edge of the Dygraph. This makes it easier to highlight the right-most data point."
- },
- "drawAxesAtZero": {
- "default": "false",
- "labels": ["Axis display"],
- "type": "boolean",
- "description": "When set, draw the X axis at the Y=0 position and the Y axis at the X=0 position if those positions are inside the graph's visible area. Otherwise, draw the axes at the bottom or left graph edge as usual."
- },
- "xRangePad": {
- "default": "0",
- "labels": ["Axis display"],
- "type": "float",
- "description": "Add the specified amount of extra space (in pixels) around the X-axis value range to ensure points at the edges remain visible."
- },
- "yRangePad": {
- "default": "null",
- "labels": ["Axis display"],
- "type": "float",
- "description": "If set, add the specified amount of extra space (in pixels) around the Y-axis value range to ensure points at the edges remain visible. If unset, use the traditional Y padding algorithm."
- },
- "axisLabelFormatter": {
- "default": "Depends on the data type",
- "labels": ["Axis display"],
- "type": "function(number or Date, granularity, opts, dygraph)",
- "parameters": [["number or date", "Either a number (for a numeric axis) or a Date object (for a date axis)"], ["granularity", "specifies how fine-grained the axis is. For date axes, this is a reference to the time granularity enumeration, defined in dygraph-tickers.js, e.g. Dygraph.WEEKLY."], ["opts", "a function which provides access to various options on the dygraph, e.g. opts('labelsKMB')."], ["dygraph", "the referenced graph"]],
- "description": "Function to call to format the tick values that appear along an axis. This is usually set on a per-axis basis."
- },
- "clickCallback": {
- "snippet": "function(e, date_millis){
alert(new Date(date_millis));
}",
- "default": "null",
- "labels": ["Callbacks"],
- "type": "function(e, x, points)",
- "parameters": [["e", "The event object for the click"], ["x", "The x value that was clicked (for dates, this is milliseconds since epoch)"], ["points", "The closest points along that date. See Point properties for details."]],
- "description": "A function to call when the canvas is clicked."
- },
- "labels": {
- "default": "[\"X\", \"Y1\", \"Y2\", ...]*",
- "labels": ["Legend"],
- "type": "array
Date.parse('2006-01-01'),
(new Date()).valueOf()
]",
- "description": "Initially zoom in on a section of the graph. Is of the form [earliest, latest], where earliest/latest are milliseconds since epoch. If the data for the x-axis is numeric, the values in dateWindow must also be numbers."
- },
- "showRoller": {
- "default": "false",
- "labels": ["Interactive Elements", "Rolling Averages"],
- "type": "boolean",
- "description": "If the rolling average period text box should be shown."
- },
- "sigma": {
- "default": "2.0",
- "labels": ["Error Bars"],
- "type": "float",
- "description": "When errorBars is set, shade this many standard deviations above/below each point."
- },
- "customBars": {
- "default": "false",
- "labels": ["CSV parsing", "Error Bars"],
- "type": "boolean",
- "description": "When set, parse each CSV cell as \"low;middle;high\". Error bars will be drawn for each point between low and high, with the series itself going through middle."
- },
- "colorValue": {
- "default": "1.0",
- "labels": ["Data Series Colors"],
- "type": "float (0.0 - 1.0)",
- "description": "If colors is not specified, value of the data series colors, as in hue/saturation/value. (0.0-1.0, default 0.5)"
- },
- "errorBars": {
- "default": "false",
- "labels": ["CSV parsing", "Error Bars"],
- "type": "boolean",
- "description": "Does the data contain standard deviations? Setting this to true alters the input format (see above)."
- },
- "displayAnnotations": {
- "default": "false",
- "labels": ["Annotations"],
- "type": "boolean",
- "description": "Only applies when Dygraphs is used as a GViz chart. Causes string columns following a data series to be interpreted as annotations on points in that series. This is the same format used by Google's AnnotatedTimeLine chart."
- },
- "panEdgeFraction": {
- "default": "null",
- "labels": ["Axis display", "Interactive Elements"],
- "type": "float",
- "description": "A value representing the farthest a graph may be panned, in percent of the display. For example, a value of 0.1 means that the graph can only be panned 10% passed the edges of the displayed values. null means no bounds."
- },
- "title": {
- "labels": ["Chart labels"],
- "type": "string",
- "default": "null",
- "description": "Text to display above the chart. You can supply any HTML for this value, not just text. If you wish to style it using CSS, use the 'dygraph-label' or 'dygraph-title' classes."
- },
- "titleHeight": {
- "default": "18",
- "labels": ["Chart labels"],
- "type": "integer",
- "description": "Height of the chart title, in pixels. This also controls the default font size of the title. If you style the title on your own, this controls how much space is set aside above the chart for the title's div."
- },
- "xlabel": {
- "labels": ["Chart labels"],
- "type": "string",
- "default": "null",
- "description": "Text to display below the chart's x-axis. You can supply any HTML for this value, not just text. If you wish to style it using CSS, use the 'dygraph-label' or 'dygraph-xlabel' classes."
- },
- "xLabelHeight": {
- "labels": ["Chart labels"],
- "type": "integer",
- "default": "18",
- "description": "Height of the x-axis label, in pixels. This also controls the default font size of the x-axis label. If you style the label on your own, this controls how much space is set aside below the chart for the x-axis label's div."
- },
- "ylabel": {
- "labels": ["Chart labels"],
- "type": "string",
- "default": "null",
- "description": "Text to display to the left of the chart's y-axis. You can supply any HTML for this value, not just text. If you wish to style it using CSS, use the 'dygraph-label' or 'dygraph-ylabel' classes. The text will be rotated 90 degrees by default, so CSS rules may behave in unintuitive ways. No additional space is set aside for a y-axis label. If you need more space, increase the width of the y-axis tick labels using the yAxisLabelWidth option. If you need a wider div for the y-axis label, either style it that way with CSS (but remember that it's rotated, so width is controlled by the 'height' property) or set the yLabelWidth option."
- },
- "y2label": {
- "labels": ["Chart labels"],
- "type": "string",
- "default": "null",
- "description": "Text to display to the right of the chart's secondary y-axis. This label is only displayed if a secondary y-axis is present. See this test for an example of how to do this. The comments for the 'ylabel' option generally apply here as well. This label gets a 'dygraph-y2label' instead of a 'dygraph-ylabel' class."
- },
- "yLabelWidth": {
- "labels": ["Chart labels"],
- "type": "integer",
- "default": "18",
- "description": "Width of the div which contains the y-axis label. Since the y-axis label appears rotated 90 degrees, this actually affects the height of its div."
- },
- "drawGrid": {
- "default": "true for x and y, false for y2",
- "labels": ["Grid"],
- "type": "boolean",
- "description": "Whether to display gridlines in the chart. This may be set on a per-axis basis to define the visibility of each axis' grid separately."
- },
- "independentTicks": {
- "default": "true for y, false for y2",
- "labels": ["Axis display", "Grid"],
- "type": "boolean",
- "description": "Only valid for y and y2, has no effect on x: This option defines whether the y axes should align their ticks or if they should be independent. Possible combinations: 1.) y=true, y2=false (default): y is the primary axis and the y2 ticks are aligned to the the ones of y. (only 1 grid) 2.) y=false, y2=true: y2 is the primary axis and the y ticks are aligned to the the ones of y2. (only 1 grid) 3.) y=true, y2=true: Both axis are independent and have their own ticks. (2 grids) 4.) y=false, y2=false: Invalid configuration causes an error."
- },
- "drawAxis": {
- "default": "true for x and y, false for y2",
- "labels": ["Axis display"],
- "type": "boolean",
- "description": "Whether to draw the specified axis. This may be set on a per-axis basis to define the visibility of each axis separately. Setting this to false also prevents axis ticks from being drawn and reclaims the space for the chart grid/lines."
- },
- "gridLineWidth": {
- "default": "0.3",
- "labels": ["Grid"],
- "type": "float",
- "description": "Thickness (in pixels) of the gridlines drawn under the chart. The vertical/horizontal gridlines can be turned off entirely by using the drawGrid option. This may be set on a per-axis basis to define each axis' grid separately."
- },
- "axisLineWidth": {
- "default": "0.3",
- "labels": ["Axis display"],
- "type": "float",
- "description": "Thickness (in pixels) of the x- and y-axis lines."
- },
- "axisLineColor": {
- "default": "black",
- "labels": ["Axis display"],
- "type": "string",
- "description": "Color of the x- and y-axis lines. Accepts any value which the HTML canvas strokeStyle attribute understands, e.g. 'black' or 'rgb(0, 100, 255)'."
- },
- "fillAlpha": {
- "default": "0.15",
- "labels": ["Error Bars", "Data Series Colors"],
- "type": "float (0.0 - 1.0)",
- "description": "Error bars (or custom bars) for each series are drawn in the same color as the series, but with partial transparency. This sets the transparency. A value of 0.0 means that the error bars will not be drawn, whereas a value of 1.0 means that the error bars will be as dark as the line for the series itself. This can be used to produce chart lines whose thickness varies at each point."
- },
- "axisLabelWidth": {
- "default": "50 (y-axis), 60 (x-axis)",
- "labels": ["Axis display", "Chart labels"],
- "type": "integer",
- "description": "Width (in pixels) of the containing divs for x- and y-axis labels. For the y-axis, this also controls the width of the y-axis. Note that for the x-axis, this is independent from pixelsPerLabel, which controls the spacing between labels."
- },
- "sigFigs": {
- "default": "null",
- "labels": ["Value display/formatting"],
- "type": "integer",
- "description": "By default, dygraphs displays numbers with a fixed number of digits after the decimal point. If you'd prefer to have a fixed number of significant figures, set this option to that number of sig figs. A value of 2, for instance, would cause 1 to be display as 1.0 and 1234 to be displayed as 1.23e+3."
- },
- "digitsAfterDecimal": {
- "default": "2",
- "labels": ["Value display/formatting"],
- "type": "integer",
- "description": "Unless it's run in scientific mode (see the sigFigs
option), dygraphs displays numbers with digitsAfterDecimal
digits after the decimal point. Trailing zeros are not displayed, so with a value of 2 you'll get '0', '0.1', '0.12', '123.45' but not '123.456' (it will be rounded to '123.46'). Numbers with absolute value less than 0.1^digitsAfterDecimal (i.e. those which would show up as '0.00') will be displayed in scientific notation."
- },
- "maxNumberWidth": {
- "default": "6",
- "labels": ["Value display/formatting"],
- "type": "integer",
- "description": "When displaying numbers in normal (not scientific) mode, large numbers will be displayed with many trailing zeros (e.g. 100000000 instead of 1e9). This can lead to unwieldy y-axis labels. If there are more than maxNumberWidth
digits to the left of the decimal in a number, dygraphs will switch to scientific notation, even when not operating in scientific mode. If you'd like to see all those digits, set this to something large, like 20 or 30."
- },
- "file": {
- "default": "(set when constructed)",
- "labels": ["Data"],
- "type": "string (URL of CSV or CSV), GViz DataTable or 2D Array",
- "description": "Sets the data being displayed in the chart. This can only be set when calling updateOptions; it cannot be set from the constructor. For a full description of valid data formats, see the Data Formats page."
- },
- "timingName": {
- "default": "null",
- "labels": ["Debugging", "Deprecated"],
- "type": "string",
- "description": "Set this option to log timing information. The value of the option will be logged along with the timimg, so that you can distinguish multiple dygraphs on the same page."
- },
- "showRangeSelector": {
- "default": "false",
- "labels": ["Range Selector"],
- "type": "boolean",
- "description": "Show or hide the range selector widget."
- },
- "rangeSelectorHeight": {
- "default": "40",
- "labels": ["Range Selector"],
- "type": "integer",
- "description": "Height, in pixels, of the range selector widget. This option can only be specified at Dygraph creation time."
- },
- "rangeSelectorPlotStrokeColor": {
- "default": "#808FAB",
- "labels": ["Range Selector"],
- "type": "string",
- "description": "The range selector mini plot stroke color. This can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"yellow\". You can also specify null or \"\" to turn off stroke."
- },
- "rangeSelectorPlotFillColor": {
- "default": "#A7B1C4",
- "labels": ["Range Selector"],
- "type": "string",
- "description": "The range selector mini plot fill color. This can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"yellow\". You can also specify null or \"\" to turn off fill."
- },
- "rangeSelectorPlotFillGradientColor": {
- "default": "white",
- "labels": ["Range Selector"],
- "type": "string",
- "description": "The top color for the range selector mini plot fill color gradient. This can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"rgba(255,100,200,42)\" or \"yellow\". You can also specify null or \"\" to disable the gradient and fill with one single color."
- },
- "rangeSelectorBackgroundStrokeColor": {
- "default": "gray",
- "labels": ["Range Selector"],
- "type": "string",
- "description": "The color of the lines below and on both sides of the range selector mini plot. This can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"yellow\"."
- },
- "rangeSelectorBackgroundLineWidth": {
- "default": "1",
- "labels": ["Range Selector"],
- "type": "float",
- "description": "The width of the lines below and on both sides of the range selector mini plot."
- },
- "rangeSelectorPlotLineWidth": {
- "default": "1.5",
- "labels": ["Range Selector"],
- "type": "float",
- "description": "The width of the range selector mini plot line."
- },
- "rangeSelectorForegroundStrokeColor": {
- "default": "black",
- "labels": ["Range Selector"],
- "type": "string",
- "description": "The color of the lines in the interactive layer of the range selector. This can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"yellow\"."
- },
- "rangeSelectorForegroundLineWidth": {
- "default": "1",
- "labels": ["Range Selector"],
- "type": "float",
- "description": "The width the lines in the interactive layer of the range selector."
- },
- "rangeSelectorAlpha": {
- "default": "0.6",
- "labels": ["Range Selector"],
- "type": "float (0.0 - 1.0)",
- "description": "The transparency of the veil that is drawn over the unselected portions of the range selector mini plot. A value of 0 represents full transparency and the unselected portions of the mini plot will appear as normal. A value of 1 represents full opacity and the unselected portions of the mini plot will be hidden."
- },
- "showInRangeSelector": {
- "default": "null",
- "labels": ["Range Selector"],
- "type": "boolean",
- "description": "Mark this series for inclusion in the range selector. The mini plot curve will be an average of all such series. If this is not specified for any series, the default behavior is to average all the visible series. Setting it for one series will result in that series being charted alone in the range selector. Once it's set for a single series, it needs to be set for all series which should be included (regardless of visibility)."
- },
- "animatedZooms": {
- "default": "false",
- "labels": ["Interactive Elements"],
- "type": "boolean",
- "description": "Set this option to animate the transition between zoom windows. Applies to programmatic and interactive zooms. Note that if you also set a drawCallback, it will be called several times on each zoom. If you set a zoomCallback, it will only be called after the animation is complete."
- },
- "plotter": {
- "default": "[DygraphCanvasRenderer.Plotters.fillPlotter, DygraphCanvasRenderer.Plotters.errorPlotter, DygraphCanvasRenderer.Plotters.linePlotter]",
- "labels": ["Data Line display"],
- "type": "array or function",
- "description": "A function (or array of functions) which plot each data series on the chart. TODO(danvk): more details! May be set per-series."
- },
- "axes": {
- "default": "null",
- "labels": ["Configuration"],
- "type": "Object",
- "description": "Defines per-axis options. Valid keys are 'x', 'y' and 'y2'. Only some options may be set on a per-axis basis. If an option may be set in this way, it will be noted on this page. See also documentation on per-series and per-axis options."
- },
- "series": {
- "default": "null",
- "labels": ["Series"],
- "type": "Object",
- "description": "Defines per-series options. Its keys match the y-axis label names, and the values are dictionaries themselves that contain options specific to that series."
- },
- "plugins": {
- "default": "[]",
- "labels": ["Configuration"],
- "type": "Array
- *
- *
- * There's a huge variety of options that can be passed to this method. For a
- * full list, see http://dygraphs.com/options.html.
- *
- * @param {Object} input_attrs The new properties and values
- * @param {boolean} block_redraw Usually the chart is redrawn after every
- * call to updateOptions(). If you know better, you can pass true to
- * explicitly block the redraw. This can be useful for chaining
- * updateOptions() calls, avoiding the occasional infinite loop and
- * preventing redraws when it's not necessary (e.g. when updating a
- * callback).
- */Dygraph.prototype.updateOptions = function(input_attrs,block_redraw){if(typeof block_redraw == 'undefined')block_redraw = false; // copyUserAttrs_ drops the "file" parameter as a convenience to us.
-var file=input_attrs.file;var attrs=Dygraph.copyUserAttrs_(input_attrs); // TODO(danvk): this is a mess. Move these options into attr_.
-if('rollPeriod' in attrs){this.rollPeriod_ = attrs.rollPeriod;}if('dateWindow' in attrs){this.dateWindow_ = attrs.dateWindow;} // TODO(danvk): validate per-series options.
-// Supported:
-// strokeWidth
-// pointSize
-// drawPoints
-// highlightCircleSize
-// Check if this set options will require new points.
-var requiresNewPoints=utils.isPixelChangingOptionList(this.attr_("labels"),attrs);utils.updateDeep(this.user_attrs_,attrs);this.attributes_.reparseSeries();if(file){ // This event indicates that the data is about to change, but hasn't yet.
-// TODO(danvk): support cancellation of the update via this event.
-this.cascadeEvents_('dataWillUpdate',{});this.file_ = file;if(!block_redraw)this.start_();}else {if(!block_redraw){if(requiresNewPoints){this.predraw_();}else {this.renderGraph_(false);}}}}; /**
- * Make a copy of input attributes, removing file as a convenience.
- * @private
- */Dygraph.copyUserAttrs_ = function(attrs){var my_attrs={};for(var k in attrs) {if(!attrs.hasOwnProperty(k))continue;if(k == 'file')continue;if(attrs.hasOwnProperty(k))my_attrs[k] = attrs[k];}return my_attrs;}; /**
- * Resizes the dygraph. If no parameters are specified, resizes to fill the
- * containing div (which has presumably changed size since the dygraph was
- * instantiated. If the width/height are specified, the div will be resized.
- *
- * This is far more efficient than destroying and re-instantiating a
- * Dygraph, since it doesn't have to reparse the underlying data.
- *
- * @param {number} width Width (in pixels)
- * @param {number} height Height (in pixels)
- */Dygraph.prototype.resize = function(width,height){if(this.resize_lock){return;}this.resize_lock = true;if(width === null != (height === null)){console.warn("Dygraph.resize() should be called with zero parameters or " + "two non-NULL parameters. Pretending it was zero.");width = height = null;}var old_width=this.width_;var old_height=this.height_;if(width){this.maindiv_.style.width = width + "px";this.maindiv_.style.height = height + "px";this.width_ = width;this.height_ = height;}else {this.width_ = this.maindiv_.clientWidth;this.height_ = this.maindiv_.clientHeight;}if(old_width != this.width_ || old_height != this.height_){ // Resizing a canvas erases it, even when the size doesn't change, so
-// any resize needs to be followed by a redraw.
-this.resizeElements_();this.predraw_();}this.resize_lock = false;}; /**
- * Adjusts the number of points in the rolling average. Updates the graph to
- * reflect the new averaging period.
- * @param {number} length Number of points over which to average the data.
- */Dygraph.prototype.adjustRoll = function(length){this.rollPeriod_ = length;this.predraw_();}; /**
- * Returns a boolean array of visibility statuses.
- */Dygraph.prototype.visibility = function(){ // Do lazy-initialization, so that this happens after we know the number of
-// data series.
-if(!this.getOption("visibility")){this.attrs_.visibility = [];} // TODO(danvk): it looks like this could go into an infinite loop w/ user_attrs.
-while(this.getOption("visibility").length < this.numColumns() - 1) {this.attrs_.visibility.push(true);}return this.getOption("visibility");}; /**
- * Changes the visibility of one or more series.
- *
- * @param {number|number[]|object} num the series index or an array of series indices
- * or a boolean array of visibility states by index
- * or an object mapping series numbers, as keys, to
- * visibility state (boolean values)
- * @param {boolean} value the visibility state expressed as a boolean
- */Dygraph.prototype.setVisibility = function(num,value){var x=this.visibility();var numIsObject=false;if(!Array.isArray(num)){if(num !== null && typeof num === 'object'){numIsObject = true;}else {num = [num];}}if(numIsObject){for(var i in num) {if(num.hasOwnProperty(i)){if(i < 0 || i >= x.length){console.warn("Invalid series number in setVisibility: " + i);}else {x[i] = num[i];}}}}else {for(var i=0;i < num.length;i++) {if(typeof num[i] === 'boolean'){if(i >= x.length){console.warn("Invalid series number in setVisibility: " + i);}else {x[i] = num[i];}}else {if(num[i] < 0 || num[i] >= x.length){console.warn("Invalid series number in setVisibility: " + num[i]);}else {x[num[i]] = value;}}}}this.predraw_();}; /**
- * How large of an area will the dygraph render itself in?
- * This is used for testing.
- * @return A {width: w, height: h} object.
- * @private
- */Dygraph.prototype.size = function(){return {width:this.width_,height:this.height_};}; /**
- * Update the list of annotations and redraw the chart.
- * See dygraphs.com/annotations.html for more info on how to use annotations.
- * @param ann {Array} An array of annotation objects.
- * @param suppressDraw {Boolean} Set to "true" to block chart redraw (optional).
- */Dygraph.prototype.setAnnotations = function(ann,suppressDraw){ // Only add the annotation CSS rule once we know it will be used.
-this.annotations_ = ann;if(!this.layout_){console.warn("Tried to setAnnotations before dygraph was ready. " + "Try setting them in a ready() block. See " + "dygraphs.com/tests/annotation.html");return;}this.layout_.setAnnotations(this.annotations_);if(!suppressDraw){this.predraw_();}}; /**
- * Return the list of annotations.
- */Dygraph.prototype.annotations = function(){return this.annotations_;}; /**
- * Get the list of label names for this graph. The first column is the
- * x-axis, so the data series names start at index 1.
- *
- * Returns null when labels have not yet been defined.
- */Dygraph.prototype.getLabels = function(){var labels=this.attr_("labels");return labels?labels.slice():null;}; /**
- * Get the index of a series (column) given its name. The first column is the
- * x-axis, so the data series start with index 1.
- */Dygraph.prototype.indexFromSetName = function(name){return this.setIndexByName_[name];}; /**
- * Find the row number corresponding to the given x-value.
- * Returns null if there is no such x-value in the data.
- * If there are multiple rows with the same x-value, this will return the
- * first one.
- * @param {number} xVal The x-value to look for (e.g. millis since epoch).
- * @return {?number} The row number, which you can pass to getValue(), or null.
- */Dygraph.prototype.getRowForX = function(xVal){var low=0,high=this.numRows() - 1;while(low <= high) {var idx=high + low >> 1;var x=this.getValue(idx,0);if(x < xVal){low = idx + 1;}else if(x > xVal){high = idx - 1;}else if(low != idx){ // equal, but there may be an earlier match.
-high = idx;}else {return idx;}}return null;}; /**
- * Trigger a callback when the dygraph has drawn itself and is ready to be
- * manipulated. This is primarily useful when dygraphs has to do an XHR for the
- * data (i.e. a URL is passed as the data source) and the chart is drawn
- * asynchronously. If the chart has already drawn, the callback will fire
- * immediately.
- *
- * This is a good place to call setAnnotation().
- *
- * @param {function(!Dygraph)} callback The callback to trigger when the chart
- * is ready.
- */Dygraph.prototype.ready = function(callback){if(this.is_initial_draw_){this.readyFns_.push(callback);}else {callback.call(this,this);}}; /**
- * Add an event handler. This event handler is kept until the graph is
- * destroyed with a call to graph.destroy().
- *
- * @param {!Node} elem The element to add the event to.
- * @param {string} type The type of the event, e.g. 'click' or 'mousemove'.
- * @param {function(Event):(boolean|undefined)} fn The function to call
- * on the event. The function takes one parameter: the event object.
- * @private
- */Dygraph.prototype.addAndTrackEvent = function(elem,type,fn){utils.addEvent(elem,type,fn);this.registeredEvents_.push({elem:elem,type:type,fn:fn});};Dygraph.prototype.removeTrackedEvents_ = function(){if(this.registeredEvents_){for(var idx=0;idx < this.registeredEvents_.length;idx++) {var reg=this.registeredEvents_[idx];utils.removeEvent(reg.elem,reg.type,reg.fn);}}this.registeredEvents_ = [];}; // Installed plugins, in order of precedence (most-general to most-specific).
-Dygraph.PLUGINS = [_pluginsLegend2['default'],_pluginsAxes2['default'],_pluginsRangeSelector2['default'], // Has to be before ChartLabels so that its callbacks are called after ChartLabels' callbacks.
-_pluginsChartLabels2['default'],_pluginsAnnotations2['default'],_pluginsGrid2['default']]; // There are many symbols which have historically been available through the
-// Dygraph class. These are exported here for backwards compatibility.
-Dygraph.GVizChart = _dygraphGviz2['default'];Dygraph.DASHED_LINE = utils.DASHED_LINE;Dygraph.DOT_DASH_LINE = utils.DOT_DASH_LINE;Dygraph.dateAxisLabelFormatter = utils.dateAxisLabelFormatter;Dygraph.toRGB_ = utils.toRGB_;Dygraph.findPos = utils.findPos;Dygraph.pageX = utils.pageX;Dygraph.pageY = utils.pageY;Dygraph.dateString_ = utils.dateString_;Dygraph.defaultInteractionModel = _dygraphInteractionModel2['default'].defaultModel;Dygraph.nonInteractiveModel = Dygraph.nonInteractiveModel_ = _dygraphInteractionModel2['default'].nonInteractiveModel_;Dygraph.Circles = utils.Circles;Dygraph.Plugins = {Legend:_pluginsLegend2['default'],Axes:_pluginsAxes2['default'],Annotations:_pluginsAnnotations2['default'],ChartLabels:_pluginsChartLabels2['default'],Grid:_pluginsGrid2['default'],RangeSelector:_pluginsRangeSelector2['default']};Dygraph.DataHandlers = {DefaultHandler:_datahandlerDefault2['default'],BarsHandler:_datahandlerBars2['default'],CustomBarsHandler:_datahandlerBarsCustom2['default'],DefaultFractionHandler:_datahandlerDefaultFractions2['default'],ErrorBarsHandler:_datahandlerBarsError2['default'],FractionsBarsHandler:_datahandlerBarsFractions2['default']};Dygraph.startPan = _dygraphInteractionModel2['default'].startPan;Dygraph.startZoom = _dygraphInteractionModel2['default'].startZoom;Dygraph.movePan = _dygraphInteractionModel2['default'].movePan;Dygraph.moveZoom = _dygraphInteractionModel2['default'].moveZoom;Dygraph.endPan = _dygraphInteractionModel2['default'].endPan;Dygraph.endZoom = _dygraphInteractionModel2['default'].endZoom;Dygraph.numericLinearTicks = DygraphTickers.numericLinearTicks;Dygraph.numericTicks = DygraphTickers.numericTicks;Dygraph.dateTicker = DygraphTickers.dateTicker;Dygraph.Granularity = DygraphTickers.Granularity;Dygraph.getDateAxis = DygraphTickers.getDateAxis;Dygraph.floatFormat = utils.floatFormat;exports['default'] = Dygraph;module.exports = exports['default'];
-
-}).call(this,require('_process'))
-
-},{"./datahandler/bars":5,"./datahandler/bars-custom":2,"./datahandler/bars-error":3,"./datahandler/bars-fractions":4,"./datahandler/default":8,"./datahandler/default-fractions":7,"./dygraph-canvas":9,"./dygraph-default-attrs":10,"./dygraph-gviz":11,"./dygraph-interaction-model":12,"./dygraph-layout":13,"./dygraph-options":15,"./dygraph-options-reference":14,"./dygraph-tickers":16,"./dygraph-utils":17,"./iframe-tarp":19,"./plugins/annotations":20,"./plugins/axes":21,"./plugins/chart-labels":22,"./plugins/grid":23,"./plugins/legend":24,"./plugins/range-selector":25,"_process":1}],19:[function(require,module,exports){
-/**
- * To create a "drag" interaction, you typically register a mousedown event
- * handler on the element where the drag begins. In that handler, you register a
- * mouseup handler on the window to determine when the mouse is released,
- * wherever that release happens. This works well, except when the user releases
- * the mouse over an off-domain iframe. In that case, the mouseup event is
- * handled by the iframe and never bubbles up to the window handler.
- *
- * To deal with this issue, we cover iframes with high z-index divs to make sure
- * they don't capture mouseup.
- *
- * Usage:
- * element.addEventListener('mousedown', function() {
- * var tarper = new IFrameTarp();
- * tarper.cover();
- * var mouseUpHandler = function() {
- * ...
- * window.removeEventListener(mouseUpHandler);
- * tarper.uncover();
- * };
- * window.addEventListener('mouseup', mouseUpHandler);
- * };
- *
- * @constructor
- */
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-
-function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
-
-var _dygraphUtils = require('./dygraph-utils');
-
-var utils = _interopRequireWildcard(_dygraphUtils);
-
-function IFrameTarp() {
- /** @type {Array.} */
- this.tarps = [];
-};
-
-/**
- * Find all the iframes in the document and cover them with high z-index
- * transparent divs.
- */
-IFrameTarp.prototype.cover = function () {
- var iframes = document.getElementsByTagName("iframe");
- for (var i = 0; i < iframes.length; i++) {
- var iframe = iframes[i];
- var pos = utils.findPos(iframe),
- x = pos.x,
- y = pos.y,
- width = iframe.offsetWidth,
- height = iframe.offsetHeight;
-
- var div = document.createElement("div");
- div.style.position = "absolute";
- div.style.left = x + 'px';
- div.style.top = y + 'px';
- div.style.width = width + 'px';
- div.style.height = height + 'px';
- div.style.zIndex = 999;
- document.body.appendChild(div);
- this.tarps.push(div);
- }
-};
-
-/**
- * Remove all the iframe covers. You should call this in a mouseup handler.
- */
-IFrameTarp.prototype.uncover = function () {
- for (var i = 0; i < this.tarps.length; i++) {
- this.tarps[i].parentNode.removeChild(this.tarps[i]);
- }
- this.tarps = [];
-};
-
-exports["default"] = IFrameTarp;
-module.exports = exports["default"];
-
-},{"./dygraph-utils":17}],20:[function(require,module,exports){
-/**
- * @license
- * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)
- * MIT-licensed (http://opensource.org/licenses/MIT)
- */
-
-/*global Dygraph:false */
-
-"use strict";
-
-/**
-Current bits of jankiness:
-- Uses dygraph.layout_ to get the parsed annotations.
-- Uses dygraph.plotter_.area
-
-It would be nice if the plugin didn't require so much special support inside
-the core dygraphs classes, but annotations involve quite a bit of parsing and
-layout.
-
-TODO(danvk): cache DOM elements.
-*/
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-var annotations = function annotations() {
- this.annotations_ = [];
-};
-
-annotations.prototype.toString = function () {
- return "Annotations Plugin";
-};
-
-annotations.prototype.activate = function (g) {
- return {
- clearChart: this.clearChart,
- didDrawChart: this.didDrawChart
- };
-};
-
-annotations.prototype.detachLabels = function () {
- for (var i = 0; i < this.annotations_.length; i++) {
- var a = this.annotations_[i];
- if (a.parentNode) a.parentNode.removeChild(a);
- this.annotations_[i] = null;
- }
- this.annotations_ = [];
-};
-
-annotations.prototype.clearChart = function (e) {
- this.detachLabels();
-};
-
-annotations.prototype.didDrawChart = function (e) {
- var g = e.dygraph;
-
- // Early out in the (common) case of zero annotations.
- var points = g.layout_.annotated_points;
- if (!points || points.length === 0) return;
-
- var containerDiv = e.canvas.parentNode;
-
- var bindEvt = function bindEvt(eventName, classEventName, pt) {
- return function (annotation_event) {
- var a = pt.annotation;
- if (a.hasOwnProperty(eventName)) {
- a[eventName](a, pt, g, annotation_event);
- } else if (g.getOption(classEventName)) {
- g.getOption(classEventName)(a, pt, g, annotation_event);
- }
- };
- };
-
- // Add the annotations one-by-one.
- var area = e.dygraph.getArea();
-
- // x-coord to sum of previous annotation's heights (used for stacking).
- var xToUsedHeight = {};
-
- for (var i = 0; i < points.length; i++) {
- var p = points[i];
- if (p.canvasx < area.x || p.canvasx > area.x + area.w || p.canvasy < area.y || p.canvasy > area.y + area.h) {
- continue;
- }
-
- var a = p.annotation;
- var tick_height = 6;
- if (a.hasOwnProperty("tickHeight")) {
- tick_height = a.tickHeight;
- }
-
- // TODO: deprecate axisLabelFontSize in favor of CSS
- var div = document.createElement("div");
- div.style['fontSize'] = g.getOption('axisLabelFontSize') + "px";
- var className = 'dygraph-annotation';
- if (!a.hasOwnProperty('icon')) {
- // camelCase class names are deprecated.
- className += ' dygraphDefaultAnnotation dygraph-default-annotation';
- }
- if (a.hasOwnProperty('cssClass')) {
- className += " " + a.cssClass;
- }
- div.className = className;
-
- var width = a.hasOwnProperty('width') ? a.width : 16;
- var height = a.hasOwnProperty('height') ? a.height : 16;
- if (a.hasOwnProperty('icon')) {
- var img = document.createElement("img");
- img.src = a.icon;
- img.width = width;
- img.height = height;
- div.appendChild(img);
- } else if (p.annotation.hasOwnProperty('shortText')) {
- div.appendChild(document.createTextNode(p.annotation.shortText));
- }
- var left = p.canvasx - width / 2;
- div.style.left = left + "px";
- var divTop = 0;
- if (a.attachAtBottom) {
- var y = area.y + area.h - height - tick_height;
- if (xToUsedHeight[left]) {
- y -= xToUsedHeight[left];
- } else {
- xToUsedHeight[left] = 0;
- }
- xToUsedHeight[left] += tick_height + height;
- divTop = y;
- } else {
- divTop = p.canvasy - height - tick_height;
- }
- div.style.top = divTop + "px";
- div.style.width = width + "px";
- div.style.height = height + "px";
- div.title = p.annotation.text;
- div.style.color = g.colorsMap_[p.name];
- div.style.borderColor = g.colorsMap_[p.name];
- a.div = div;
-
- g.addAndTrackEvent(div, 'click', bindEvt('clickHandler', 'annotationClickHandler', p, this));
- g.addAndTrackEvent(div, 'mouseover', bindEvt('mouseOverHandler', 'annotationMouseOverHandler', p, this));
- g.addAndTrackEvent(div, 'mouseout', bindEvt('mouseOutHandler', 'annotationMouseOutHandler', p, this));
- g.addAndTrackEvent(div, 'dblclick', bindEvt('dblClickHandler', 'annotationDblClickHandler', p, this));
-
- containerDiv.appendChild(div);
- this.annotations_.push(div);
-
- var ctx = e.drawingContext;
- ctx.save();
- ctx.strokeStyle = a.hasOwnProperty('tickColor') ? a.tickColor : g.colorsMap_[p.name];
- ctx.lineWidth = a.hasOwnProperty('tickWidth') ? a.tickWidth : g.getOption('strokeWidth');
- ctx.beginPath();
- if (!a.attachAtBottom) {
- ctx.moveTo(p.canvasx, p.canvasy);
- ctx.lineTo(p.canvasx, p.canvasy - 2 - tick_height);
- } else {
- var y = divTop + height;
- ctx.moveTo(p.canvasx, y);
- ctx.lineTo(p.canvasx, y + tick_height);
- }
- ctx.closePath();
- ctx.stroke();
- ctx.restore();
- }
-};
-
-annotations.prototype.destroy = function () {
- this.detachLabels();
-};
-
-exports["default"] = annotations;
-module.exports = exports["default"];
-
-},{}],21:[function(require,module,exports){
-/**
- * @license
- * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)
- * MIT-licensed (http://opensource.org/licenses/MIT)
- */
-
-/*global Dygraph:false */
-
-'use strict';
-
-/*
-Bits of jankiness:
-- Direct layout access
-- Direct area access
-- Should include calculation of ticks, not just the drawing.
-
-Options left to make axis-friendly.
- ('drawAxesAtZero')
- ('xAxisHeight')
-*/
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
-
-var _dygraphUtils = require('../dygraph-utils');
-
-var utils = _interopRequireWildcard(_dygraphUtils);
-
-/**
- * Draws the axes. This includes the labels on the x- and y-axes, as well
- * as the tick marks on the axes.
- * It does _not_ draw the grid lines which span the entire chart.
- */
-var axes = function axes() {
- this.xlabels_ = [];
- this.ylabels_ = [];
-};
-
-axes.prototype.toString = function () {
- return 'Axes Plugin';
-};
-
-axes.prototype.activate = function (g) {
- return {
- layout: this.layout,
- clearChart: this.clearChart,
- willDrawChart: this.willDrawChart
- };
-};
-
-axes.prototype.layout = function (e) {
- var g = e.dygraph;
-
- if (g.getOptionForAxis('drawAxis', 'y')) {
- var w = g.getOptionForAxis('axisLabelWidth', 'y') + 2 * g.getOptionForAxis('axisTickSize', 'y');
- e.reserveSpaceLeft(w);
- }
-
- if (g.getOptionForAxis('drawAxis', 'x')) {
- var h;
- // NOTE: I think this is probably broken now, since g.getOption() now
- // hits the dictionary. (That is, g.getOption('xAxisHeight') now always
- // has a value.)
- if (g.getOption('xAxisHeight')) {
- h = g.getOption('xAxisHeight');
- } else {
- h = g.getOptionForAxis('axisLabelFontSize', 'x') + 2 * g.getOptionForAxis('axisTickSize', 'x');
- }
- e.reserveSpaceBottom(h);
- }
-
- if (g.numAxes() == 2) {
- if (g.getOptionForAxis('drawAxis', 'y2')) {
- var w = g.getOptionForAxis('axisLabelWidth', 'y2') + 2 * g.getOptionForAxis('axisTickSize', 'y2');
- e.reserveSpaceRight(w);
- }
- } else if (g.numAxes() > 2) {
- g.error('Only two y-axes are supported at this time. (Trying ' + 'to use ' + g.numAxes() + ')');
- }
-};
-
-axes.prototype.detachLabels = function () {
- function removeArray(ary) {
- for (var i = 0; i < ary.length; i++) {
- var el = ary[i];
- if (el.parentNode) el.parentNode.removeChild(el);
- }
- }
-
- removeArray(this.xlabels_);
- removeArray(this.ylabels_);
- this.xlabels_ = [];
- this.ylabels_ = [];
-};
-
-axes.prototype.clearChart = function (e) {
- this.detachLabels();
-};
-
-axes.prototype.willDrawChart = function (e) {
- var _this = this;
-
- var g = e.dygraph;
-
- if (!g.getOptionForAxis('drawAxis', 'x') && !g.getOptionForAxis('drawAxis', 'y') && !g.getOptionForAxis('drawAxis', 'y2')) {
- return;
- }
-
- // Round pixels to half-integer boundaries for crisper drawing.
- function halfUp(x) {
- return Math.round(x) + 0.5;
- }
- function halfDown(y) {
- return Math.round(y) - 0.5;
- }
-
- var context = e.drawingContext;
- var containerDiv = e.canvas.parentNode;
- var canvasWidth = g.width_; // e.canvas.width is affected by pixel ratio.
- var canvasHeight = g.height_;
-
- var label, x, y, tick, i;
-
- var makeLabelStyle = function makeLabelStyle(axis) {
- return {
- position: 'absolute',
- fontSize: g.getOptionForAxis('axisLabelFontSize', axis) + 'px',
- width: g.getOptionForAxis('axisLabelWidth', axis) + 'px'
- };
- };
-
- var labelStyles = {
- x: makeLabelStyle('x'),
- y: makeLabelStyle('y'),
- y2: makeLabelStyle('y2')
- };
-
- var makeDiv = function makeDiv(txt, axis, prec_axis) {
- /*
- * This seems to be called with the following three sets of axis/prec_axis:
- * x: undefined
- * y: y1
- * y: y2
- */
- var div = document.createElement('div');
- var labelStyle = labelStyles[prec_axis == 'y2' ? 'y2' : axis];
- utils.update(div.style, labelStyle);
- // TODO: combine outer & inner divs
- var inner_div = document.createElement('div');
- inner_div.className = 'dygraph-axis-label' + ' dygraph-axis-label-' + axis + (prec_axis ? ' dygraph-axis-label-' + prec_axis : '');
- inner_div.innerHTML = txt;
- div.appendChild(inner_div);
- return div;
- };
-
- // axis lines
- context.save();
-
- var layout = g.layout_;
- var area = e.dygraph.plotter_.area;
-
- // Helper for repeated axis-option accesses.
- var makeOptionGetter = function makeOptionGetter(axis) {
- return function (option) {
- return g.getOptionForAxis(option, axis);
- };
- };
-
- if (g.getOptionForAxis('drawAxis', 'y')) {
- if (layout.yticks && layout.yticks.length > 0) {
- var num_axes = g.numAxes();
- var getOptions = [makeOptionGetter('y'), makeOptionGetter('y2')];
- layout.yticks.forEach(function (tick) {
- if (tick.label === undefined) return; // this tick only has a grid line.
- x = area.x;
- var sgn = 1;
- var prec_axis = 'y1';
- var getAxisOption = getOptions[0];
- if (tick.axis == 1) {
- // right-side y-axis
- x = area.x + area.w;
- sgn = -1;
- prec_axis = 'y2';
- getAxisOption = getOptions[1];
- }
- var fontSize = getAxisOption('axisLabelFontSize');
- y = area.y + tick.pos * area.h;
-
- /* Tick marks are currently clipped, so don't bother drawing them.
- context.beginPath();
- context.moveTo(halfUp(x), halfDown(y));
- context.lineTo(halfUp(x - sgn * this.attr_('axisTickSize')), halfDown(y));
- context.closePath();
- context.stroke();
- */
-
- label = makeDiv(tick.label, 'y', num_axes == 2 ? prec_axis : null);
- var top = y - fontSize / 2;
- if (top < 0) top = 0;
-
- if (top + fontSize + 3 > canvasHeight) {
- label.style.bottom = '0';
- } else {
- label.style.top = top + 'px';
- }
- // TODO: replace these with css classes?
- if (tick.axis === 0) {
- label.style.left = area.x - getAxisOption('axisLabelWidth') - getAxisOption('axisTickSize') + 'px';
- label.style.textAlign = 'right';
- } else if (tick.axis == 1) {
- label.style.left = area.x + area.w + getAxisOption('axisTickSize') + 'px';
- label.style.textAlign = 'left';
- }
- label.style.width = getAxisOption('axisLabelWidth') + 'px';
- containerDiv.appendChild(label);
- _this.ylabels_.push(label);
- });
-
- // The lowest tick on the y-axis often overlaps with the leftmost
- // tick on the x-axis. Shift the bottom tick up a little bit to
- // compensate if necessary.
- var bottomTick = this.ylabels_[0];
- // Interested in the y2 axis also?
- var fontSize = g.getOptionForAxis('axisLabelFontSize', 'y');
- var bottom = parseInt(bottomTick.style.top, 10) + fontSize;
- if (bottom > canvasHeight - fontSize) {
- bottomTick.style.top = parseInt(bottomTick.style.top, 10) - fontSize / 2 + 'px';
- }
- }
-
- // draw a vertical line on the left to separate the chart from the labels.
- var axisX;
- if (g.getOption('drawAxesAtZero')) {
- var r = g.toPercentXCoord(0);
- if (r > 1 || r < 0 || isNaN(r)) r = 0;
- axisX = halfUp(area.x + r * area.w);
- } else {
- axisX = halfUp(area.x);
- }
-
- context.strokeStyle = g.getOptionForAxis('axisLineColor', 'y');
- context.lineWidth = g.getOptionForAxis('axisLineWidth', 'y');
-
- context.beginPath();
- context.moveTo(axisX, halfDown(area.y));
- context.lineTo(axisX, halfDown(area.y + area.h));
- context.closePath();
- context.stroke();
-
- // if there's a secondary y-axis, draw a vertical line for that, too.
- if (g.numAxes() == 2) {
- context.strokeStyle = g.getOptionForAxis('axisLineColor', 'y2');
- context.lineWidth = g.getOptionForAxis('axisLineWidth', 'y2');
- context.beginPath();
- context.moveTo(halfDown(area.x + area.w), halfDown(area.y));
- context.lineTo(halfDown(area.x + area.w), halfDown(area.y + area.h));
- context.closePath();
- context.stroke();
- }
- }
-
- if (g.getOptionForAxis('drawAxis', 'x')) {
- if (layout.xticks) {
- var getAxisOption = makeOptionGetter('x');
- layout.xticks.forEach(function (tick) {
- if (tick.label === undefined) return; // this tick only has a grid line.
- x = area.x + tick.pos * area.w;
- y = area.y + area.h;
-
- /* Tick marks are currently clipped, so don't bother drawing them.
- context.beginPath();
- context.moveTo(halfUp(x), halfDown(y));
- context.lineTo(halfUp(x), halfDown(y + this.attr_('axisTickSize')));
- context.closePath();
- context.stroke();
- */
-
- label = makeDiv(tick.label, 'x');
- label.style.textAlign = 'center';
- label.style.top = y + getAxisOption('axisTickSize') + 'px';
-
- var left = x - getAxisOption('axisLabelWidth') / 2;
- if (left + getAxisOption('axisLabelWidth') > canvasWidth) {
- left = canvasWidth - getAxisOption('axisLabelWidth');
- label.style.textAlign = 'right';
- }
- if (left < 0) {
- left = 0;
- label.style.textAlign = 'left';
- }
-
- label.style.left = left + 'px';
- label.style.width = getAxisOption('axisLabelWidth') + 'px';
- containerDiv.appendChild(label);
- _this.xlabels_.push(label);
- });
- }
-
- context.strokeStyle = g.getOptionForAxis('axisLineColor', 'x');
- context.lineWidth = g.getOptionForAxis('axisLineWidth', 'x');
- context.beginPath();
- var axisY;
- if (g.getOption('drawAxesAtZero')) {
- var r = g.toPercentYCoord(0, 0);
- if (r > 1 || r < 0) r = 1;
- axisY = halfDown(area.y + r * area.h);
- } else {
- axisY = halfDown(area.y + area.h);
- }
- context.moveTo(halfUp(area.x), axisY);
- context.lineTo(halfUp(area.x + area.w), axisY);
- context.closePath();
- context.stroke();
- }
-
- context.restore();
-};
-
-exports['default'] = axes;
-module.exports = exports['default'];
-
-},{"../dygraph-utils":17}],22:[function(require,module,exports){
-/**
- * @license
- * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)
- * MIT-licensed (http://opensource.org/licenses/MIT)
- */
-/*global Dygraph:false */
-
-"use strict";
-
-// TODO(danvk): move chart label options out of dygraphs and into the plugin.
-// TODO(danvk): only tear down & rebuild the DIVs when it's necessary.
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-var chart_labels = function chart_labels() {
- this.title_div_ = null;
- this.xlabel_div_ = null;
- this.ylabel_div_ = null;
- this.y2label_div_ = null;
-};
-
-chart_labels.prototype.toString = function () {
- return "ChartLabels Plugin";
-};
-
-chart_labels.prototype.activate = function (g) {
- return {
- layout: this.layout,
- // clearChart: this.clearChart,
- didDrawChart: this.didDrawChart
- };
-};
-
-// QUESTION: should there be a plugin-utils.js?
-var createDivInRect = function createDivInRect(r) {
- var div = document.createElement('div');
- div.style.position = 'absolute';
- div.style.left = r.x + 'px';
- div.style.top = r.y + 'px';
- div.style.width = r.w + 'px';
- div.style.height = r.h + 'px';
- return div;
-};
-
-// Detach and null out any existing nodes.
-chart_labels.prototype.detachLabels_ = function () {
- var els = [this.title_div_, this.xlabel_div_, this.ylabel_div_, this.y2label_div_];
- for (var i = 0; i < els.length; i++) {
- var el = els[i];
- if (!el) continue;
- if (el.parentNode) el.parentNode.removeChild(el);
- }
-
- this.title_div_ = null;
- this.xlabel_div_ = null;
- this.ylabel_div_ = null;
- this.y2label_div_ = null;
-};
-
-var createRotatedDiv = function createRotatedDiv(g, box, axis, classes, html) {
- // TODO(danvk): is this outer div actually necessary?
- var div = document.createElement("div");
- div.style.position = 'absolute';
- if (axis == 1) {
- // NOTE: this is cheating. Should be positioned relative to the box.
- div.style.left = '0px';
- } else {
- div.style.left = box.x + 'px';
- }
- div.style.top = box.y + 'px';
- div.style.width = box.w + 'px';
- div.style.height = box.h + 'px';
- div.style.fontSize = g.getOption('yLabelWidth') - 2 + 'px';
-
- var inner_div = document.createElement("div");
- inner_div.style.position = 'absolute';
- inner_div.style.width = box.h + 'px';
- inner_div.style.height = box.w + 'px';
- inner_div.style.top = box.h / 2 - box.w / 2 + 'px';
- inner_div.style.left = box.w / 2 - box.h / 2 + 'px';
- // TODO: combine inner_div and class_div.
- inner_div.className = 'dygraph-label-rotate-' + (axis == 1 ? 'right' : 'left');
-
- var class_div = document.createElement("div");
- class_div.className = classes;
- class_div.innerHTML = html;
-
- inner_div.appendChild(class_div);
- div.appendChild(inner_div);
- return div;
-};
-
-chart_labels.prototype.layout = function (e) {
- this.detachLabels_();
-
- var g = e.dygraph;
- var div = e.chart_div;
- if (g.getOption('title')) {
- // QUESTION: should this return an absolutely-positioned div instead?
- var title_rect = e.reserveSpaceTop(g.getOption('titleHeight'));
- this.title_div_ = createDivInRect(title_rect);
- this.title_div_.style.fontSize = g.getOption('titleHeight') - 8 + 'px';
-
- var class_div = document.createElement("div");
- class_div.className = 'dygraph-label dygraph-title';
- class_div.innerHTML = g.getOption('title');
- this.title_div_.appendChild(class_div);
- div.appendChild(this.title_div_);
- }
-
- if (g.getOption('xlabel')) {
- var x_rect = e.reserveSpaceBottom(g.getOption('xLabelHeight'));
- this.xlabel_div_ = createDivInRect(x_rect);
- this.xlabel_div_.style.fontSize = g.getOption('xLabelHeight') - 2 + 'px';
-
- var class_div = document.createElement("div");
- class_div.className = 'dygraph-label dygraph-xlabel';
- class_div.innerHTML = g.getOption('xlabel');
- this.xlabel_div_.appendChild(class_div);
- div.appendChild(this.xlabel_div_);
- }
-
- if (g.getOption('ylabel')) {
- // It would make sense to shift the chart here to make room for the y-axis
- // label, but the default yAxisLabelWidth is large enough that this results
- // in overly-padded charts. The y-axis label should fit fine. If it
- // doesn't, the yAxisLabelWidth option can be increased.
- var y_rect = e.reserveSpaceLeft(0);
-
- this.ylabel_div_ = createRotatedDiv(g, y_rect, 1, // primary (left) y-axis
- 'dygraph-label dygraph-ylabel', g.getOption('ylabel'));
- div.appendChild(this.ylabel_div_);
- }
-
- if (g.getOption('y2label') && g.numAxes() == 2) {
- // same logic applies here as for ylabel.
- var y2_rect = e.reserveSpaceRight(0);
- this.y2label_div_ = createRotatedDiv(g, y2_rect, 2, // secondary (right) y-axis
- 'dygraph-label dygraph-y2label', g.getOption('y2label'));
- div.appendChild(this.y2label_div_);
- }
-};
-
-chart_labels.prototype.didDrawChart = function (e) {
- var g = e.dygraph;
- if (this.title_div_) {
- this.title_div_.children[0].innerHTML = g.getOption('title');
- }
- if (this.xlabel_div_) {
- this.xlabel_div_.children[0].innerHTML = g.getOption('xlabel');
- }
- if (this.ylabel_div_) {
- this.ylabel_div_.children[0].children[0].innerHTML = g.getOption('ylabel');
- }
- if (this.y2label_div_) {
- this.y2label_div_.children[0].children[0].innerHTML = g.getOption('y2label');
- }
-};
-
-chart_labels.prototype.clearChart = function () {};
-
-chart_labels.prototype.destroy = function () {
- this.detachLabels_();
-};
-
-exports["default"] = chart_labels;
-module.exports = exports["default"];
-
-},{}],23:[function(require,module,exports){
-/**
- * @license
- * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)
- * MIT-licensed (http://opensource.org/licenses/MIT)
- */
-/*global Dygraph:false */
-
-/*
-
-Current bits of jankiness:
-- Direct layout access
-- Direct area access
-
-*/
-
-"use strict";
-
-/**
- * Draws the gridlines, i.e. the gray horizontal & vertical lines running the
- * length of the chart.
- *
- * @constructor
- */
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-var grid = function grid() {};
-
-grid.prototype.toString = function () {
- return "Gridline Plugin";
-};
-
-grid.prototype.activate = function (g) {
- return {
- willDrawChart: this.willDrawChart
- };
-};
-
-grid.prototype.willDrawChart = function (e) {
- // Draw the new X/Y grid. Lines appear crisper when pixels are rounded to
- // half-integers. This prevents them from drawing in two rows/cols.
- var g = e.dygraph;
- var ctx = e.drawingContext;
- var layout = g.layout_;
- var area = e.dygraph.plotter_.area;
-
- function halfUp(x) {
- return Math.round(x) + 0.5;
- }
- function halfDown(y) {
- return Math.round(y) - 0.5;
- }
-
- var x, y, i, ticks;
- if (g.getOptionForAxis('drawGrid', 'y')) {
- var axes = ["y", "y2"];
- var strokeStyles = [],
- lineWidths = [],
- drawGrid = [],
- stroking = [],
- strokePattern = [];
- for (var i = 0; i < axes.length; i++) {
- drawGrid[i] = g.getOptionForAxis('drawGrid', axes[i]);
- if (drawGrid[i]) {
- strokeStyles[i] = g.getOptionForAxis('gridLineColor', axes[i]);
- lineWidths[i] = g.getOptionForAxis('gridLineWidth', axes[i]);
- strokePattern[i] = g.getOptionForAxis('gridLinePattern', axes[i]);
- stroking[i] = strokePattern[i] && strokePattern[i].length >= 2;
- }
- }
- ticks = layout.yticks;
- ctx.save();
- // draw grids for the different y axes
- ticks.forEach(function (tick) {
- if (!tick.has_tick) return;
- var axis = tick.axis;
- if (drawGrid[axis]) {
- ctx.save();
- if (stroking[axis]) {
- if (ctx.setLineDash) ctx.setLineDash(strokePattern[axis]);
- }
- ctx.strokeStyle = strokeStyles[axis];
- ctx.lineWidth = lineWidths[axis];
-
- x = halfUp(area.x);
- y = halfDown(area.y + tick.pos * area.h);
- ctx.beginPath();
- ctx.moveTo(x, y);
- ctx.lineTo(x + area.w, y);
- ctx.stroke();
-
- ctx.restore();
- }
- });
- ctx.restore();
- }
-
- // draw grid for x axis
- if (g.getOptionForAxis('drawGrid', 'x')) {
- ticks = layout.xticks;
- ctx.save();
- var strokePattern = g.getOptionForAxis('gridLinePattern', 'x');
- var stroking = strokePattern && strokePattern.length >= 2;
- if (stroking) {
- if (ctx.setLineDash) ctx.setLineDash(strokePattern);
- }
- ctx.strokeStyle = g.getOptionForAxis('gridLineColor', 'x');
- ctx.lineWidth = g.getOptionForAxis('gridLineWidth', 'x');
- ticks.forEach(function (tick) {
- if (!tick.has_tick) return;
- x = halfUp(area.x + tick.pos * area.w);
- y = halfDown(area.y + area.h);
- ctx.beginPath();
- ctx.moveTo(x, y);
- ctx.lineTo(x, area.y);
- ctx.closePath();
- ctx.stroke();
- });
- if (stroking) {
- if (ctx.setLineDash) ctx.setLineDash([]);
- }
- ctx.restore();
- }
-};
-
-grid.prototype.destroy = function () {};
-
-exports["default"] = grid;
-module.exports = exports["default"];
-
-},{}],24:[function(require,module,exports){
-/**
- * @license
- * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)
- * MIT-licensed (http://opensource.org/licenses/MIT)
- */
-/*global Dygraph:false */
-
-/*
-Current bits of jankiness:
-- Uses two private APIs:
- 1. Dygraph.optionsViewForAxis_
- 2. dygraph.plotter_.area
-- Registers for a "predraw" event, which should be renamed.
-- I call calculateEmWidthInDiv more often than needed.
-*/
-
-/*global Dygraph:false */
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-
-function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
-
-var _dygraphUtils = require('../dygraph-utils');
-
-var utils = _interopRequireWildcard(_dygraphUtils);
-
-/**
- * Creates the legend, which appears when the user hovers over the chart.
- * The legend can be either a user-specified or generated div.
- *
- * @constructor
- */
-var Legend = function Legend() {
- this.legend_div_ = null;
- this.is_generated_div_ = false; // do we own this div, or was it user-specified?
-};
-
-Legend.prototype.toString = function () {
- return "Legend Plugin";
-};
-
-/**
- * This is called during the dygraph constructor, after options have been set
- * but before the data is available.
- *
- * Proper tasks to do here include:
- * - Reading your own options
- * - DOM manipulation
- * - Registering event listeners
- *
- * @param {Dygraph} g Graph instance.
- * @return {object.
' : ' ';
- html += "" + series.dashHTML + " " + series.labelHTML + "";
- }
- return html;
- }
-
- html = data.xHTML + ':';
- for (var i = 0; i < data.series.length; i++) {
- var series = data.series[i];
- if (!series.isVisible) continue;
- if (sepLines) html += '
';
- var cls = series.isHighlighted ? ' class="highlight"' : '';
- html += " " + series.labelHTML + ": " + series.yHTML + "";
- }
- return html;
-};
-
-/**
- * Generates html for the "dash" displayed on the legend when using "legend: always".
- * In particular, this works for dashed lines with any stroke pattern. It will
- * try to scale the pattern to fit in 1em width. Or if small enough repeat the
- * pattern for 1em width.
- *
- * @param strokePattern The pattern
- * @param color The color of the series.
- * @param oneEmWidth The width in pixels of 1em in the legend.
- * @private
- */
-// TODO(danvk): cache the results of this
-function generateLegendDashHTML(strokePattern, color, oneEmWidth) {
- // Easy, common case: a solid line
- if (!strokePattern || strokePattern.length <= 1) {
- return "";
- }
-
- var i, j, paddingLeft, marginRight;
- var strokePixelLength = 0,
- segmentLoop = 0;
- var normalizedPattern = [];
- var loop;
-
- // Compute the length of the pixels including the first segment twice,
- // since we repeat it.
- for (i = 0; i <= strokePattern.length; i++) {
- strokePixelLength += strokePattern[i % strokePattern.length];
- }
-
- // See if we can loop the pattern by itself at least twice.
- loop = Math.floor(oneEmWidth / (strokePixelLength - strokePattern[0]));
- if (loop > 1) {
- // This pattern fits at least two times, no scaling just convert to em;
- for (i = 0; i < strokePattern.length; i++) {
- normalizedPattern[i] = strokePattern[i] / oneEmWidth;
- }
- // Since we are repeating the pattern, we don't worry about repeating the
- // first segment in one draw.
- segmentLoop = normalizedPattern.length;
- } else {
- // If the pattern doesn't fit in the legend we scale it to fit.
- loop = 1;
- for (i = 0; i < strokePattern.length; i++) {
- normalizedPattern[i] = strokePattern[i] / strokePixelLength;
- }
- // For the scaled patterns we do redraw the first segment.
- segmentLoop = normalizedPattern.length + 1;
- }
-
- // Now make the pattern.
- var dash = "";
- for (j = 0; j < loop; j++) {
- for (i = 0; i < segmentLoop; i += 2) {
- // The padding is the drawn segment.
- paddingLeft = normalizedPattern[i % normalizedPattern.length];
- if (i < strokePattern.length) {
- // The margin is the space segment.
- marginRight = normalizedPattern[(i + 1) % normalizedPattern.length];
- } else {
- // The repeated first segment has no right margin.
- marginRight = 0;
- }
- dash += "";
- }
- }
- return dash;
-};
-
-exports["default"] = Legend;
-module.exports = exports["default"];
-
-},{"../dygraph-utils":17}],25:[function(require,module,exports){
-/**
- * @license
- * Copyright 2011 Paul Felix (paul.eric.felix@gmail.com)
- * MIT-licensed (http://opensource.org/licenses/MIT)
- */
-/*global Dygraph:false,TouchEvent:false */
-
-/**
- * @fileoverview This file contains the RangeSelector plugin used to provide
- * a timeline range selector widget for dygraphs.
- */
-
-/*global Dygraph:false */
-"use strict";
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
-
-var _dygraphUtils = require('../dygraph-utils');
-
-var utils = _interopRequireWildcard(_dygraphUtils);
-
-var _dygraphInteractionModel = require('../dygraph-interaction-model');
-
-var _dygraphInteractionModel2 = _interopRequireDefault(_dygraphInteractionModel);
-
-var _iframeTarp = require('../iframe-tarp');
-
-var _iframeTarp2 = _interopRequireDefault(_iframeTarp);
-
-var rangeSelector = function rangeSelector() {
- this.hasTouchInterface_ = typeof TouchEvent != 'undefined';
- this.isMobileDevice_ = /mobile|android/gi.test(navigator.appVersion);
- this.interfaceCreated_ = false;
-};
-
-rangeSelector.prototype.toString = function () {
- return "RangeSelector Plugin";
-};
-
-rangeSelector.prototype.activate = function (dygraph) {
- this.dygraph_ = dygraph;
- if (this.getOption_('showRangeSelector')) {
- this.createInterface_();
- }
- return {
- layout: this.reserveSpace_,
- predraw: this.renderStaticLayer_,
- didDrawChart: this.renderInteractiveLayer_
- };
-};
-
-rangeSelector.prototype.destroy = function () {
- this.bgcanvas_ = null;
- this.fgcanvas_ = null;
- this.leftZoomHandle_ = null;
- this.rightZoomHandle_ = null;
-};
-
-//------------------------------------------------------------------
-// Private methods
-//------------------------------------------------------------------
-
-rangeSelector.prototype.getOption_ = function (name, opt_series) {
- return this.dygraph_.getOption(name, opt_series);
-};
-
-rangeSelector.prototype.setDefaultOption_ = function (name, value) {
- this.dygraph_.attrs_[name] = value;
-};
-
-/**
- * @private
- * Creates the range selector elements and adds them to the graph.
- */
-rangeSelector.prototype.createInterface_ = function () {
- this.createCanvases_();
- this.createZoomHandles_();
- this.initInteraction_();
-
- // Range selector and animatedZooms have a bad interaction. See issue 359.
- if (this.getOption_('animatedZooms')) {
- console.warn('Animated zooms and range selector are not compatible; disabling animatedZooms.');
- this.dygraph_.updateOptions({ animatedZooms: false }, true);
- }
-
- this.interfaceCreated_ = true;
- this.addToGraph_();
-};
-
-/**
- * @private
- * Adds the range selector to the graph.
- */
-rangeSelector.prototype.addToGraph_ = function () {
- var graphDiv = this.graphDiv_ = this.dygraph_.graphDiv;
- graphDiv.appendChild(this.bgcanvas_);
- graphDiv.appendChild(this.fgcanvas_);
- graphDiv.appendChild(this.leftZoomHandle_);
- graphDiv.appendChild(this.rightZoomHandle_);
-};
-
-/**
- * @private
- * Removes the range selector from the graph.
- */
-rangeSelector.prototype.removeFromGraph_ = function () {
- var graphDiv = this.graphDiv_;
- graphDiv.removeChild(this.bgcanvas_);
- graphDiv.removeChild(this.fgcanvas_);
- graphDiv.removeChild(this.leftZoomHandle_);
- graphDiv.removeChild(this.rightZoomHandle_);
- this.graphDiv_ = null;
-};
-
-/**
- * @private
- * Called by Layout to allow range selector to reserve its space.
- */
-rangeSelector.prototype.reserveSpace_ = function (e) {
- if (this.getOption_('showRangeSelector')) {
- e.reserveSpaceBottom(this.getOption_('rangeSelectorHeight') + 4);
- }
-};
-
-/**
- * @private
- * Renders the static portion of the range selector at the predraw stage.
- */
-rangeSelector.prototype.renderStaticLayer_ = function () {
- if (!this.updateVisibility_()) {
- return;
- }
- this.resize_();
- this.drawStaticLayer_();
-};
-
-/**
- * @private
- * Renders the interactive portion of the range selector after the chart has been drawn.
- */
-rangeSelector.prototype.renderInteractiveLayer_ = function () {
- if (!this.updateVisibility_() || this.isChangingRange_) {
- return;
- }
- this.placeZoomHandles_();
- this.drawInteractiveLayer_();
-};
-
-/**
- * @private
- * Check to see if the range selector is enabled/disabled and update visibility accordingly.
- */
-rangeSelector.prototype.updateVisibility_ = function () {
- var enabled = this.getOption_('showRangeSelector');
- if (enabled) {
- if (!this.interfaceCreated_) {
- this.createInterface_();
- } else if (!this.graphDiv_ || !this.graphDiv_.parentNode) {
- this.addToGraph_();
- }
- } else if (this.graphDiv_) {
- this.removeFromGraph_();
- var dygraph = this.dygraph_;
- setTimeout(function () {
- dygraph.width_ = 0;dygraph.resize();
- }, 1);
- }
- return enabled;
-};
-
-/**
- * @private
- * Resizes the range selector.
- */
-rangeSelector.prototype.resize_ = function () {
- function setElementRect(canvas, context, rect, pixelRatioOption) {
- var canvasScale = pixelRatioOption || utils.getContextPixelRatio(context);
-
- canvas.style.top = rect.y + 'px';
- canvas.style.left = rect.x + 'px';
- canvas.width = rect.w * canvasScale;
- canvas.height = rect.h * canvasScale;
- canvas.style.width = rect.w + 'px';
- canvas.style.height = rect.h + 'px';
-
- if (canvasScale != 1) {
- context.scale(canvasScale, canvasScale);
- }
- }
-
- var plotArea = this.dygraph_.layout_.getPlotArea();
-
- var xAxisLabelHeight = 0;
- if (this.dygraph_.getOptionForAxis('drawAxis', 'x')) {
- xAxisLabelHeight = this.getOption_('xAxisHeight') || this.getOption_('axisLabelFontSize') + 2 * this.getOption_('axisTickSize');
- }
- this.canvasRect_ = {
- x: plotArea.x,
- y: plotArea.y + plotArea.h + xAxisLabelHeight + 4,
- w: plotArea.w,
- h: this.getOption_('rangeSelectorHeight')
- };
-
- var pixelRatioOption = this.dygraph_.getNumericOption('pixelRatio');
- setElementRect(this.bgcanvas_, this.bgcanvas_ctx_, this.canvasRect_, pixelRatioOption);
- setElementRect(this.fgcanvas_, this.fgcanvas_ctx_, this.canvasRect_, pixelRatioOption);
-};
-
-/**
- * @private
- * Creates the background and foreground canvases.
- */
-rangeSelector.prototype.createCanvases_ = function () {
- this.bgcanvas_ = utils.createCanvas();
- this.bgcanvas_.className = 'dygraph-rangesel-bgcanvas';
- this.bgcanvas_.style.position = 'absolute';
- this.bgcanvas_.style.zIndex = 9;
- this.bgcanvas_ctx_ = utils.getContext(this.bgcanvas_);
-
- this.fgcanvas_ = utils.createCanvas();
- this.fgcanvas_.className = 'dygraph-rangesel-fgcanvas';
- this.fgcanvas_.style.position = 'absolute';
- this.fgcanvas_.style.zIndex = 9;
- this.fgcanvas_.style.cursor = 'default';
- this.fgcanvas_ctx_ = utils.getContext(this.fgcanvas_);
-};
-
-/**
- * @private
- * Creates the zoom handle elements.
- */
-rangeSelector.prototype.createZoomHandles_ = function () {
- var img = new Image();
- img.className = 'dygraph-rangesel-zoomhandle';
- img.style.position = 'absolute';
- img.style.zIndex = 10;
- img.style.visibility = 'hidden'; // Initially hidden so they don't show up in the wrong place.
- img.style.cursor = 'col-resize';
- // TODO: change image to more options
- img.width = 9;
- img.height = 16;
- img.src = 'data:image/png;base64,' + 'iVBORw0KGgoAAAANSUhEUgAAAAkAAAAQCAYAAADESFVDAAAAAXNSR0IArs4c6QAAAAZiS0dEANAA' + 'zwDP4Z7KegAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB9sHGw0cMqdt1UwAAAAZdEVYdENv' + 'bW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAaElEQVQoz+3SsRFAQBCF4Z9WJM8KCDVwownl' + '6YXsTmCUsyKGkZzcl7zkz3YLkypgAnreFmDEpHkIwVOMfpdi9CEEN2nGpFdwD03yEqDtOgCaun7s' + 'qSTDH32I1pQA2Pb9sZecAxc5r3IAb21d6878xsAAAAAASUVORK5CYII=';
-
- if (this.isMobileDevice_) {
- img.width *= 2;
- img.height *= 2;
- }
-
- this.leftZoomHandle_ = img;
- this.rightZoomHandle_ = img.cloneNode(false);
-};
-
-/**
- * @private
- * Sets up the interaction for the range selector.
- */
-rangeSelector.prototype.initInteraction_ = function () {
- var self = this;
- var topElem = document;
- var clientXLast = 0;
- var handle = null;
- var isZooming = false;
- var isPanning = false;
- var dynamic = !this.isMobileDevice_;
-
- // We cover iframes during mouse interactions. See comments in
- // dygraph-utils.js for more info on why this is a good idea.
- var tarp = new _iframeTarp2['default']();
-
- // functions, defined below. Defining them this way (rather than with
- // "function foo() {...}" makes JSHint happy.
- var toXDataWindow, onZoomStart, onZoom, onZoomEnd, doZoom, isMouseInPanZone, onPanStart, onPan, onPanEnd, doPan, onCanvasHover;
-
- // Touch event functions
- var onZoomHandleTouchEvent, onCanvasTouchEvent, addTouchEvents;
-
- toXDataWindow = function (zoomHandleStatus) {
- var xDataLimits = self.dygraph_.xAxisExtremes();
- var fact = (xDataLimits[1] - xDataLimits[0]) / self.canvasRect_.w;
- var xDataMin = xDataLimits[0] + (zoomHandleStatus.leftHandlePos - self.canvasRect_.x) * fact;
- var xDataMax = xDataLimits[0] + (zoomHandleStatus.rightHandlePos - self.canvasRect_.x) * fact;
- return [xDataMin, xDataMax];
- };
-
- onZoomStart = function (e) {
- utils.cancelEvent(e);
- isZooming = true;
- clientXLast = e.clientX;
- handle = e.target ? e.target : e.srcElement;
- if (e.type === 'mousedown' || e.type === 'dragstart') {
- // These events are removed manually.
- utils.addEvent(topElem, 'mousemove', onZoom);
- utils.addEvent(topElem, 'mouseup', onZoomEnd);
- }
- self.fgcanvas_.style.cursor = 'col-resize';
- tarp.cover();
- return true;
- };
-
- onZoom = function (e) {
- if (!isZooming) {
- return false;
- }
- utils.cancelEvent(e);
-
- var delX = e.clientX - clientXLast;
- if (Math.abs(delX) < 4) {
- return true;
- }
- clientXLast = e.clientX;
-
- // Move handle.
- var zoomHandleStatus = self.getZoomHandleStatus_();
- var newPos;
- if (handle == self.leftZoomHandle_) {
- newPos = zoomHandleStatus.leftHandlePos + delX;
- newPos = Math.min(newPos, zoomHandleStatus.rightHandlePos - handle.width - 3);
- newPos = Math.max(newPos, self.canvasRect_.x);
- } else {
- newPos = zoomHandleStatus.rightHandlePos + delX;
- newPos = Math.min(newPos, self.canvasRect_.x + self.canvasRect_.w);
- newPos = Math.max(newPos, zoomHandleStatus.leftHandlePos + handle.width + 3);
- }
- var halfHandleWidth = handle.width / 2;
- handle.style.left = newPos - halfHandleWidth + 'px';
- self.drawInteractiveLayer_();
-
- // Zoom on the fly.
- if (dynamic) {
- doZoom();
- }
- return true;
- };
-
- onZoomEnd = function (e) {
- if (!isZooming) {
- return false;
- }
- isZooming = false;
- tarp.uncover();
- utils.removeEvent(topElem, 'mousemove', onZoom);
- utils.removeEvent(topElem, 'mouseup', onZoomEnd);
- self.fgcanvas_.style.cursor = 'default';
-
- // If on a slower device, zoom now.
- if (!dynamic) {
- doZoom();
- }
- return true;
- };
-
- doZoom = function () {
- try {
- var zoomHandleStatus = self.getZoomHandleStatus_();
- self.isChangingRange_ = true;
- if (!zoomHandleStatus.isZoomed) {
- self.dygraph_.resetZoom();
- } else {
- var xDataWindow = toXDataWindow(zoomHandleStatus);
- self.dygraph_.doZoomXDates_(xDataWindow[0], xDataWindow[1]);
- }
- } finally {
- self.isChangingRange_ = false;
- }
- };
-
- isMouseInPanZone = function (e) {
- var rect = self.leftZoomHandle_.getBoundingClientRect();
- var leftHandleClientX = rect.left + rect.width / 2;
- rect = self.rightZoomHandle_.getBoundingClientRect();
- var rightHandleClientX = rect.left + rect.width / 2;
- return e.clientX > leftHandleClientX && e.clientX < rightHandleClientX;
- };
-
- onPanStart = function (e) {
- if (!isPanning && isMouseInPanZone(e) && self.getZoomHandleStatus_().isZoomed) {
- utils.cancelEvent(e);
- isPanning = true;
- clientXLast = e.clientX;
- if (e.type === 'mousedown') {
- // These events are removed manually.
- utils.addEvent(topElem, 'mousemove', onPan);
- utils.addEvent(topElem, 'mouseup', onPanEnd);
- }
- return true;
- }
- return false;
- };
-
- onPan = function (e) {
- if (!isPanning) {
- return false;
- }
- utils.cancelEvent(e);
-
- var delX = e.clientX - clientXLast;
- if (Math.abs(delX) < 4) {
- return true;
- }
- clientXLast = e.clientX;
-
- // Move range view
- var zoomHandleStatus = self.getZoomHandleStatus_();
- var leftHandlePos = zoomHandleStatus.leftHandlePos;
- var rightHandlePos = zoomHandleStatus.rightHandlePos;
- var rangeSize = rightHandlePos - leftHandlePos;
- if (leftHandlePos + delX <= self.canvasRect_.x) {
- leftHandlePos = self.canvasRect_.x;
- rightHandlePos = leftHandlePos + rangeSize;
- } else if (rightHandlePos + delX >= self.canvasRect_.x + self.canvasRect_.w) {
- rightHandlePos = self.canvasRect_.x + self.canvasRect_.w;
- leftHandlePos = rightHandlePos - rangeSize;
- } else {
- leftHandlePos += delX;
- rightHandlePos += delX;
- }
- var halfHandleWidth = self.leftZoomHandle_.width / 2;
- self.leftZoomHandle_.style.left = leftHandlePos - halfHandleWidth + 'px';
- self.rightZoomHandle_.style.left = rightHandlePos - halfHandleWidth + 'px';
- self.drawInteractiveLayer_();
-
- // Do pan on the fly.
- if (dynamic) {
- doPan();
- }
- return true;
- };
-
- onPanEnd = function (e) {
- if (!isPanning) {
- return false;
- }
- isPanning = false;
- utils.removeEvent(topElem, 'mousemove', onPan);
- utils.removeEvent(topElem, 'mouseup', onPanEnd);
- // If on a slower device, do pan now.
- if (!dynamic) {
- doPan();
- }
- return true;
- };
-
- doPan = function () {
- try {
- self.isChangingRange_ = true;
- self.dygraph_.dateWindow_ = toXDataWindow(self.getZoomHandleStatus_());
- self.dygraph_.drawGraph_(false);
- } finally {
- self.isChangingRange_ = false;
- }
- };
-
- onCanvasHover = function (e) {
- if (isZooming || isPanning) {
- return;
- }
- var cursor = isMouseInPanZone(e) ? 'move' : 'default';
- if (cursor != self.fgcanvas_.style.cursor) {
- self.fgcanvas_.style.cursor = cursor;
- }
- };
-
- onZoomHandleTouchEvent = function (e) {
- if (e.type == 'touchstart' && e.targetTouches.length == 1) {
- if (onZoomStart(e.targetTouches[0])) {
- utils.cancelEvent(e);
- }
- } else if (e.type == 'touchmove' && e.targetTouches.length == 1) {
- if (onZoom(e.targetTouches[0])) {
- utils.cancelEvent(e);
- }
- } else {
- onZoomEnd(e);
- }
- };
-
- onCanvasTouchEvent = function (e) {
- if (e.type == 'touchstart' && e.targetTouches.length == 1) {
- if (onPanStart(e.targetTouches[0])) {
- utils.cancelEvent(e);
- }
- } else if (e.type == 'touchmove' && e.targetTouches.length == 1) {
- if (onPan(e.targetTouches[0])) {
- utils.cancelEvent(e);
- }
- } else {
- onPanEnd(e);
- }
- };
-
- addTouchEvents = function (elem, fn) {
- var types = ['touchstart', 'touchend', 'touchmove', 'touchcancel'];
- for (var i = 0; i < types.length; i++) {
- self.dygraph_.addAndTrackEvent(elem, types[i], fn);
- }
- };
-
- this.setDefaultOption_('interactionModel', _dygraphInteractionModel2['default'].dragIsPanInteractionModel);
- this.setDefaultOption_('panEdgeFraction', 0.0001);
-
- var dragStartEvent = window.opera ? 'mousedown' : 'dragstart';
- this.dygraph_.addAndTrackEvent(this.leftZoomHandle_, dragStartEvent, onZoomStart);
- this.dygraph_.addAndTrackEvent(this.rightZoomHandle_, dragStartEvent, onZoomStart);
-
- this.dygraph_.addAndTrackEvent(this.fgcanvas_, 'mousedown', onPanStart);
- this.dygraph_.addAndTrackEvent(this.fgcanvas_, 'mousemove', onCanvasHover);
-
- // Touch events
- if (this.hasTouchInterface_) {
- addTouchEvents(this.leftZoomHandle_, onZoomHandleTouchEvent);
- addTouchEvents(this.rightZoomHandle_, onZoomHandleTouchEvent);
- addTouchEvents(this.fgcanvas_, onCanvasTouchEvent);
- }
-};
-
-/**
- * @private
- * Draws the static layer in the background canvas.
- */
-rangeSelector.prototype.drawStaticLayer_ = function () {
- var ctx = this.bgcanvas_ctx_;
- ctx.clearRect(0, 0, this.canvasRect_.w, this.canvasRect_.h);
- try {
- this.drawMiniPlot_();
- } catch (ex) {
- console.warn(ex);
- }
-
- var margin = 0.5;
- this.bgcanvas_ctx_.lineWidth = this.getOption_('rangeSelectorBackgroundLineWidth');
- ctx.strokeStyle = this.getOption_('rangeSelectorBackgroundStrokeColor');
- ctx.beginPath();
- ctx.moveTo(margin, margin);
- ctx.lineTo(margin, this.canvasRect_.h - margin);
- ctx.lineTo(this.canvasRect_.w - margin, this.canvasRect_.h - margin);
- ctx.lineTo(this.canvasRect_.w - margin, margin);
- ctx.stroke();
-};
-
-/**
- * @private
- * Draws the mini plot in the background canvas.
- */
-rangeSelector.prototype.drawMiniPlot_ = function () {
- var fillStyle = this.getOption_('rangeSelectorPlotFillColor');
- var fillGradientStyle = this.getOption_('rangeSelectorPlotFillGradientColor');
- var strokeStyle = this.getOption_('rangeSelectorPlotStrokeColor');
- if (!fillStyle && !strokeStyle) {
- return;
- }
-
- var stepPlot = this.getOption_('stepPlot');
-
- var combinedSeriesData = this.computeCombinedSeriesAndLimits_();
- var yRange = combinedSeriesData.yMax - combinedSeriesData.yMin;
-
- // Draw the mini plot.
- var ctx = this.bgcanvas_ctx_;
- var margin = 0.5;
-
- var xExtremes = this.dygraph_.xAxisExtremes();
- var xRange = Math.max(xExtremes[1] - xExtremes[0], 1.e-30);
- var xFact = (this.canvasRect_.w - margin) / xRange;
- var yFact = (this.canvasRect_.h - margin) / yRange;
- var canvasWidth = this.canvasRect_.w - margin;
- var canvasHeight = this.canvasRect_.h - margin;
-
- var prevX = null,
- prevY = null;
-
- ctx.beginPath();
- ctx.moveTo(margin, canvasHeight);
- for (var i = 0; i < combinedSeriesData.data.length; i++) {
- var dataPoint = combinedSeriesData.data[i];
- var x = dataPoint[0] !== null ? (dataPoint[0] - xExtremes[0]) * xFact : NaN;
- var y = dataPoint[1] !== null ? canvasHeight - (dataPoint[1] - combinedSeriesData.yMin) * yFact : NaN;
-
- // Skip points that don't change the x-value. Overly fine-grained points
- // can cause major slowdowns with the ctx.fill() call below.
- if (!stepPlot && prevX !== null && Math.round(x) == Math.round(prevX)) {
- continue;
- }
-
- if (isFinite(x) && isFinite(y)) {
- if (prevX === null) {
- ctx.lineTo(x, canvasHeight);
- } else if (stepPlot) {
- ctx.lineTo(x, prevY);
- }
- ctx.lineTo(x, y);
- prevX = x;
- prevY = y;
- } else {
- if (prevX !== null) {
- if (stepPlot) {
- ctx.lineTo(x, prevY);
- ctx.lineTo(x, canvasHeight);
- } else {
- ctx.lineTo(prevX, canvasHeight);
- }
- }
- prevX = prevY = null;
- }
- }
- ctx.lineTo(canvasWidth, canvasHeight);
- ctx.closePath();
-
- if (fillStyle) {
- var lingrad = this.bgcanvas_ctx_.createLinearGradient(0, 0, 0, canvasHeight);
- if (fillGradientStyle) {
- lingrad.addColorStop(0, fillGradientStyle);
- }
- lingrad.addColorStop(1, fillStyle);
- this.bgcanvas_ctx_.fillStyle = lingrad;
- ctx.fill();
- }
-
- if (strokeStyle) {
- this.bgcanvas_ctx_.strokeStyle = strokeStyle;
- this.bgcanvas_ctx_.lineWidth = this.getOption_('rangeSelectorPlotLineWidth');
- ctx.stroke();
- }
-};
-
-/**
- * @private
- * Computes and returns the combined series data along with min/max for the mini plot.
- * The combined series consists of averaged values for all series.
- * When series have error bars, the error bars are ignored.
- * @return {Object} An object containing combined series array, ymin, ymax.
- */
-rangeSelector.prototype.computeCombinedSeriesAndLimits_ = function () {
- var g = this.dygraph_;
- var logscale = this.getOption_('logscale');
- var i;
-
- // Select series to combine. By default, all series are combined.
- var numColumns = g.numColumns();
- var labels = g.getLabels();
- var includeSeries = new Array(numColumns);
- var anySet = false;
- var visibility = g.visibility();
- var inclusion = [];
-
- for (i = 1; i < numColumns; i++) {
- var include = this.getOption_('showInRangeSelector', labels[i]);
- inclusion.push(include);
- if (include !== null) anySet = true; // it's set explicitly for this series
- }
-
- if (anySet) {
- for (i = 1; i < numColumns; i++) {
- includeSeries[i] = inclusion[i - 1];
- }
- } else {
- for (i = 1; i < numColumns; i++) {
- includeSeries[i] = visibility[i - 1];
- }
- }
-
- // Create a combined series (average of selected series values).
- // TODO(danvk): short-circuit if there's only one series.
- var rolledSeries = [];
- var dataHandler = g.dataHandler_;
- var options = g.attributes_;
- for (i = 1; i < g.numColumns(); i++) {
- if (!includeSeries[i]) continue;
- var series = dataHandler.extractSeries(g.rawData_, i, options);
- if (g.rollPeriod() > 1) {
- series = dataHandler.rollingAverage(series, g.rollPeriod(), options);
- }
-
- rolledSeries.push(series);
- }
-
- var combinedSeries = [];
- for (i = 0; i < rolledSeries[0].length; i++) {
- var sum = 0;
- var count = 0;
- for (var j = 0; j < rolledSeries.length; j++) {
- var y = rolledSeries[j][i][1];
- if (y === null || isNaN(y)) continue;
- count++;
- sum += y;
- }
- combinedSeries.push([rolledSeries[0][i][0], sum / count]);
- }
-
- // Compute the y range.
- var yMin = Number.MAX_VALUE;
- var yMax = -Number.MAX_VALUE;
- for (i = 0; i < combinedSeries.length; i++) {
- var yVal = combinedSeries[i][1];
- if (yVal !== null && isFinite(yVal) && (!logscale || yVal > 0)) {
- yMin = Math.min(yMin, yVal);
- yMax = Math.max(yMax, yVal);
- }
- }
-
- // Convert Y data to log scale if needed.
- // Also, expand the Y range to compress the mini plot a little.
- var extraPercent = 0.25;
- if (logscale) {
- yMax = utils.log10(yMax);
- yMax += yMax * extraPercent;
- yMin = utils.log10(yMin);
- for (i = 0; i < combinedSeries.length; i++) {
- combinedSeries[i][1] = utils.log10(combinedSeries[i][1]);
- }
- } else {
- var yExtra;
- var yRange = yMax - yMin;
- if (yRange <= Number.MIN_VALUE) {
- yExtra = yMax * extraPercent;
- } else {
- yExtra = yRange * extraPercent;
- }
- yMax += yExtra;
- yMin -= yExtra;
- }
-
- return { data: combinedSeries, yMin: yMin, yMax: yMax };
-};
-
-/**
- * @private
- * Places the zoom handles in the proper position based on the current X data window.
- */
-rangeSelector.prototype.placeZoomHandles_ = function () {
- var xExtremes = this.dygraph_.xAxisExtremes();
- var xWindowLimits = this.dygraph_.xAxisRange();
- var xRange = xExtremes[1] - xExtremes[0];
- var leftPercent = Math.max(0, (xWindowLimits[0] - xExtremes[0]) / xRange);
- var rightPercent = Math.max(0, (xExtremes[1] - xWindowLimits[1]) / xRange);
- var leftCoord = this.canvasRect_.x + this.canvasRect_.w * leftPercent;
- var rightCoord = this.canvasRect_.x + this.canvasRect_.w * (1 - rightPercent);
- var handleTop = Math.max(this.canvasRect_.y, this.canvasRect_.y + (this.canvasRect_.h - this.leftZoomHandle_.height) / 2);
- var halfHandleWidth = this.leftZoomHandle_.width / 2;
- this.leftZoomHandle_.style.left = leftCoord - halfHandleWidth + 'px';
- this.leftZoomHandle_.style.top = handleTop + 'px';
- this.rightZoomHandle_.style.left = rightCoord - halfHandleWidth + 'px';
- this.rightZoomHandle_.style.top = this.leftZoomHandle_.style.top;
-
- this.leftZoomHandle_.style.visibility = 'visible';
- this.rightZoomHandle_.style.visibility = 'visible';
-};
-
-/**
- * @private
- * Draws the interactive layer in the foreground canvas.
- */
-rangeSelector.prototype.drawInteractiveLayer_ = function () {
- var ctx = this.fgcanvas_ctx_;
- ctx.clearRect(0, 0, this.canvasRect_.w, this.canvasRect_.h);
- var margin = 1;
- var width = this.canvasRect_.w - margin;
- var height = this.canvasRect_.h - margin;
- var zoomHandleStatus = this.getZoomHandleStatus_();
-
- ctx.strokeStyle = this.getOption_('rangeSelectorForegroundStrokeColor');
- ctx.lineWidth = this.getOption_('rangeSelectorForegroundLineWidth');
- if (!zoomHandleStatus.isZoomed) {
- ctx.beginPath();
- ctx.moveTo(margin, margin);
- ctx.lineTo(margin, height);
- ctx.lineTo(width, height);
- ctx.lineTo(width, margin);
- ctx.stroke();
- } else {
- var leftHandleCanvasPos = Math.max(margin, zoomHandleStatus.leftHandlePos - this.canvasRect_.x);
- var rightHandleCanvasPos = Math.min(width, zoomHandleStatus.rightHandlePos - this.canvasRect_.x);
-
- ctx.fillStyle = 'rgba(240, 240, 240, ' + this.getOption_('rangeSelectorAlpha').toString() + ')';
- ctx.fillRect(0, 0, leftHandleCanvasPos, this.canvasRect_.h);
- ctx.fillRect(rightHandleCanvasPos, 0, this.canvasRect_.w - rightHandleCanvasPos, this.canvasRect_.h);
-
- ctx.beginPath();
- ctx.moveTo(margin, margin);
- ctx.lineTo(leftHandleCanvasPos, margin);
- ctx.lineTo(leftHandleCanvasPos, height);
- ctx.lineTo(rightHandleCanvasPos, height);
- ctx.lineTo(rightHandleCanvasPos, margin);
- ctx.lineTo(width, margin);
- ctx.stroke();
- }
-};
-
-/**
- * @private
- * Returns the current zoom handle position information.
- * @return {Object} The zoom handle status.
- */
-rangeSelector.prototype.getZoomHandleStatus_ = function () {
- var halfHandleWidth = this.leftZoomHandle_.width / 2;
- var leftHandlePos = parseFloat(this.leftZoomHandle_.style.left) + halfHandleWidth;
- var rightHandlePos = parseFloat(this.rightZoomHandle_.style.left) + halfHandleWidth;
- return {
- leftHandlePos: leftHandlePos,
- rightHandlePos: rightHandlePos,
- isZoomed: leftHandlePos - 1 > this.canvasRect_.x || rightHandlePos + 1 < this.canvasRect_.x + this.canvasRect_.w
- };
-};
-
-exports['default'] = rangeSelector;
-module.exports = exports['default'];
-
-},{"../dygraph-interaction-model":12,"../dygraph-utils":17,"../iframe-tarp":19}]},{},[18])(18)
-});
-//# sourceMappingURL=dygraph.js.map
diff --git a/bindings/dygraph/dist/dygraph.min.js b/bindings/dygraph/dist/dygraph.min.js
deleted file mode 100644
index e24af99e..00000000
--- a/bindings/dygraph/dist/dygraph.min.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/*! @license Copyright 2017 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */
-!function(t){var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Dygraph=function(){return function t(e,a,i){function n(o,s){if(!a[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(r)return r(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var u=a[o]={exports:{}};e[o][0].call(u.exports,function(t){var a=e[o][1][t];return n(a||t)},u,u.exports,t,e,a,i)}return a[o].exports}for(var r="function"==typeof require&&require,o=0;os?(e.push(u),e.push(h)):e.push(h)}}},o=function(a){r(a);for(var o=0,s=e.length;o1,h=s-a>1;o(l||h),a=s}e.push([t,n,r])};return{moveTo:function(t,e){s(2,t,e)},lineTo:function(t,e){s(1,t,e)},stroke:function(){o(!0),t.stroke()},fill:function(){o(!0),t.fill()},beginPath:function(){o(!0),t.beginPath()},closePath:function(){o(!0),t.closePath()},_count:function(){return n}}},s._fillPlotter=function(t){if(!t.singleSeriesName&&0===t.seriesIndex){for(var e=t.dygraph,a=e.getLabels().slice(1),i=a.length;i>=0;i--)e.visibility()[i]||a.splice(i,1);if(function(){for(var t=0;t=10&&a.dragDirection==n.VERTICAL){var l=Math.min(a.dragStartY,a.dragEndY),h=Math.max(a.dragStartY,a.dragEndY);l=Math.max(l,i.y),h=Math.min(h,i.y+i.h),l0&&"e"!=t[a-1]&&"E"!=t[a-1]||t.indexOf("/")>=0||isNaN(parseFloat(t))?e=!0:8==t.length&&t>"19700101"&&t<"20371231"&&(e=!0),this.setXAxisOptions_(e)},Q.prototype.setXAxisOptions_=function(t){t?(this.attrs_.xValueParser=x.dateParser,this.attrs_.axes.x.valueFormatter=x.dateValueFormatter,this.attrs_.axes.x.ticker=_.dateTicker,this.attrs_.axes.x.axisLabelFormatter=x.dateAxisLabelFormatter):(this.attrs_.xValueParser=function(t){return parseFloat(t)},this.attrs_.axes.x.valueFormatter=function(t){return t},this.attrs_.axes.x.ticker=_.numericTicks,this.attrs_.axes.x.axisLabelFormatter=this.attrs_.axes.x.valueFormatter)},Q.prototype.parseCSV_=function(t){var e,a,i=[],n=x.detectLineDelimiter(t),r=t.split(n||"\n"),o=this.getStringOption("delimiter");-1==r[0].indexOf(o)&&r[0].indexOf("\t")>=0&&(o="\t");var s=0;"labels"in this.user_attrs_||(s=1,this.attrs_.labels=r[0].split(o),this.attributes_.reparseSeries());for(var l,h=!1,u=this.attr_("labels").length,d=!1,c=s;c0&&f[0]
between lines in the label string. Often used in
- conjunction with labelsDiv.
-
- Type: boolean
- Default: false
- *)
- -> ?labelsShowZeroValues:bool
- (** labelsShowZeroValues http://dygraphs.com/options.html#labelsShowZeroValues
-
- Show zero value labels in the labelsDiv.
-
- Type: boolean
- Default: true
- *)
- -> ?legend:Legend.t
- (** legend http://dygraphs.com/options.html#legend
-
- When to display the legend. By default, it only appears when a user mouses
- over the chart. Set it to "always" to always display a legend of some
- sort. When set to "follow", legend follows highlighted points.
-
- Type: string
- Default: onmouseover
- *)
- -> ?legendFormatter:(Legend_data.t -> string)
- (** legendFormatter http://dygraphs.com/options.html#legendFormatter
-
- Set this to supply a custom formatter for the legend. See this comment and the
- legendFormatter demo for usage.
-
- Type: function(data): string
- Default: null
- *)
- -> ?showLabelsOnHighlight:bool
- (** showLabelsOnHighlight http://dygraphs.com/options.html#showLabelsOnHighlight
-
- Whether to show the legend upon mouseover.
-
- Type: boolean
- Default: true
- *)
- -> ?height:int
- (** height http://dygraphs.com/options.html#height
-
- Height, in pixels, of the chart. If the container div has been explicitly
- sized, this will be ignored.
-
- Type: integer
- Default: 320
- *)
- -> ?clickCallback:(evt:Ojs.t -> x:float -> points:Point.t array -> unit)
- (** clickCallback http://dygraphs.com/options.html#clickCallback
-
- A function to call when the canvas is clicked.
-
- Type: function(e, x, points)
- e: The event object for the click
- x: The x value that was clicked (for dates, this is milliseconds since epoch)
- points: The closest points along that date. See Point properties for details.
- Default: null
- Gallery Samples: callbacks highlighted-series
- Other Examples: callback
- *)
- -> ?highlightCallback:(evt:Ojs.t -> x:float -> points:Point.t array -> row:int -> seriesName:string option -> unit)
- (** highlightCallback http://dygraphs.com/options.html#highlightCallback
-
- When set, this callback gets called every time a new point is highlighted.
-
- Type: function(event, x, points, row, seriesName)
- event: the JavaScript mousemove event
- x: the x-coordinate of the highlighted points
- points: an array of highlighted points: [ {name: 'series', yval: y-value}, … ]
- row: integer index of the highlighted row in the data table, starting from 0
- seriesName: name of the highlighted series, only present if highlightSeriesOpts is set.
- Default: null
- *)
- -> ?unhighlightCallback:(evt:Ojs.t -> unit)
- (** unhighlightCallback http://dygraphs.com/options.html#unhighlightCallback
-
- When set, this callback gets called every time the user stops highlighting any
- point by mousing out of the graph.
-
- Type: function(event)
- event: the mouse event
- Default: null
- *)
- -> ?pointClickCallback:(evt:Ojs.t -> point:Point.t -> unit)
- (** pointClickCallback http://dygraphs.com/options.html#pointClickCallback
-
- A function to call when a data point is clicked. and the point that was
- clicked.
-
- Type: function(e, point)
- e: the event object for the click
- point: the point that was clicked See Point properties for details
- Default: null
- *)
- -> ?underlayCallback:(context:Canvas_rendering_context_2D.t -> area:Area.t -> dygraph:Ojs.t -> unit)
- (** underlayCallback http://dygraphs.com/options.html#underlayCallback
-
- When set, this callback gets called before the chart is drawn. It details on how
- to use this.
-
- Type: function(context, area, dygraph)
- context: the canvas drawing context on which to draw
- area: An object with {x,y,w,h} properties describing the drawing area.
- dygraph: the reference graph
- Default: null
- *)
- -> ?drawCallback:(graph:Ojs.t -> isInitial:bool -> unit)
- (**
- When set, this callback gets called every time the dygraph is drawn. This includes
- the initial draw, after zooming and repeatedly while panning.
-
- Type: function(dygraph, is_initial)
- dygraph: The graph being drawn
- is_initial: True if this is the initial draw, false for subsequent draws.
- Default: null
- *)
- -> ?zoomCallback:(xmin:float -> xmax:float -> yRanges:Range.t array -> unit)
- (** zoomCallback http://dygraphs.com/options.html#zoomCallback
-
- A function to call when the zoom window is changed (either by zooming in or
- out). When animatedZooms is set, zoomCallback is called once at the end of the
- transition (it will not be called for intermediate frames).
-
- Type: function(minDate, maxDate, yRanges)
- minDate: milliseconds since epoch
- maxDate: milliseconds since epoch.
- yRanges: is an array of [bottom, top] pairs, one for each y-axis.
- Default: null
- *)
- -> ?pixelRatio:float
- (** pixelRatio http://dygraphs.com/options.html#pixelRatio
-
- Overrides the pixel ratio scaling factor for the canvas's 2d
- context. Ordinarily, this is set to the devicePixelRatio /
- (context.backingStoreRatio || 1), so on mobile devices, where the
- devicePixelRatio can be somewhere around 3, performance can be improved by
- overriding this value to something less precise, like 1, at the expense of
- resolution.
-
- Type: float
- Default: (devicePixelRatio / context.backingStoreRatio)
- *)
- -> ?plotter:(Plotter.t list)
- (** plotter https://dygraphs.com/options.html#plotter
- A function (or array of functions) which plot each data series on the chart.
-
- Type: array or function
- Default: [DygraphCanvasRenderer.Plotters.fillPlotter, DygraphCanvasRenderer.Plotters.errorPlotter, DygraphCanvasRenderer.Plotters.linePlotter]
-
- Gallery Samples: NONE
- Other Examples: plotters; smooth-plots
- *)
- -> ?rightGap:int
- (** rightGap http://dygraphs.com/options.html#rightGap
-
- Number of pixels to leave blank at the right edge of the Dygraph. This makes
- it easier to highlight the right-most data point.
-
- Type: integer
- Default: 5
- *)
- -> ?width:int
- (** width http://dygraphs.com/options.html#width
-
- Width, in pixels, of the chart. If the container div has been explicitly
- sized, this will be ignored.
-
- Type: integer
- Default: 480
- *)
- -> ?rangeSelectorAlpha:float
- (** rangeSelectorAlpha http://dygraphs.com/options.html#rangeSelectorAlpha
-
- The transparency of the veil that is drawn over the unselected portions of
- the range selector mini plot. A value of 0 represents full transparency and
- the unselected portions of the mini plot will appear as normal. A value of 1
- represents full opacity and the unselected portions of the mini plot will be
- hidden.
-
- Type: float (0.0 - 1.0)
- Default: 0.6
- *)
- -> ?rangeSelectorBackgroundLineWidth:float
- (** rangeSelectorBackgroundLineWidth http://dygraphs.com/options.html#rangeSelectorBackgroundLineWidth
-
- The width of the lines below and on both sides of the range selector mini
- plot.
-
- Type: float
- Default: 1
- *)
- -> ?rangeSelectorBackgroundStrokeColor:Color.t
- (** rangeSelectorBackgroundStrokeColor http://dygraphs.com/options.html#rangeSelectorBackgroundStrokeColor
-
- The color of the lines below and on both sides of the range selector mini
- plot. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow".
-
- Type: string
- Default: gray
- *)
- -> ?rangeSelectorForegroundLineWidth:float
- (** rangeSelectorForegroundLineWidth http://dygraphs.com/options.html#rangeSelectorForegroundLineWidth
-
- The width the lines in the interactive layer of the range selector.
-
- Type: float
- Default: 1
- *)
- -> ?rangeSelectorForegroundStrokeColor:Color.t
- (** rangeSelectorForegroundStrokeColor http://dygraphs.com/options.html#rangeSelectorForegroundStrokeColor
-
- The color of the lines in the interactive layer of the range selector. This
- can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow".
-
- Type: string
- Default: black
- *)
- -> ?rangeSelectorHeight:int
- (** rangeSelectorHeight http://dygraphs.com/options.html#rangeSelectorHeight
-
- Height, in pixels, of the range selector widget. This option can only be
- specified at Dygraph creation time.
-
- Type: integer
- Default: 40
- *)
- -> ?rangeSelectorPlotFillColor:Color.t
- (** rangeSelectorPlotFillColor http://dygraphs.com/options.html#rangeSelectorPlotFillColor
-
- The range selector mini plot fill color. This can be of the form "#AABBCC" or
- "rgb(255,100,200)" or "yellow". You can also specify null or "" to turn off
- fill.
-
- Type: string
- Default: #A7B1C4
- *)
- -> ?rangeSelectorPlotFillGradientColor:Color.t
- (** rangeSelectorPlotFillGradientColor http://dygraphs.com/options.html#rangeSelectorPlotFillGradientColor
-
- The top color for the range selector mini plot fill color gradient. This can
- be of the form "#AABBCC" or "rgb(255,100,200)" or "rgba(255,100,200,42)" or
- "yellow". You can also specify null or "" to disable the gradient and fill
- with one single color.
-
- Type: string
- Default: white
- *)
- -> ?rangeSelectorPlotLineWidth:float
- (** rangeSelectorPlotLineWidth http://dygraphs.com/options.html#rangeSelectorPlotLineWidth
-
- The width of the range selector mini plot line.
-
- Type: float
- Default: 1.5
- *)
- -> ?rangeSelectorPlotStrokeColor:Color.t
- (** rangeSelectorPlotStrokeColor http://dygraphs.com/options.html#rangeSelectorPlotStrokeColor
-
- The range selector mini plot stroke color. This can be of the form "#AABBCC"
- or "rgb(255,100,200)" or "yellow". You can also specify null or "" to turn
- off stroke.
-
- Type: string
- Default: #808FAB
- *)
- -> ?showRangeSelector:bool
- (** showRangeSelector http://dygraphs.com/options.html#showRangeSelector
-
- Show or hide the range selector widget.
-
- Type: boolean
- Default: false
- *)
- -> ?series:Series.t
- (** series http://dygraphs.com/options.html#series
-
- Defines per-series options. Its keys match the y-axis label names, and the values
- are dictionaries themselves that contain options specific to that series.
-
- Type: Object
- Default: null
- *)
- -> ?digitsAfterDecimal:int
- (** digitsAfterDecimal http://dygraphs.com/options.html#digitsAfterDecimal
-
- Unless it's run in scientific mode (see the sigFigs option), dygraphs
- displays numbers with digitsAfterDecimal digits after the decimal
- point. Trailing zeros are not displayed, so with a value of 2 you'll
- get '0', '0.1', '0.12', '123.45' but not '123.456' (it will be
- rounded to '123.46'). Numbers with absolute value less than
- 0.1^digitsAfterDecimal (i.e. those which would show up as '0.00')
- will be displayed in scientific notation.
-
- Type: integer
- Default: 2
- *)
- -> ?labelsKMB:bool
- (** labelsKMB http://dygraphs.com/options.html#labelsKMB
-
- Show K/M/B for thousands/millions/billions on y-axis.
-
- Type: boolean
- Default: false
- *)
- -> ?labelsKMG2:bool
- (** labelsKMG2 http://dygraphs.com/options.html#labelsKMG2
-
- Show k/M/G for kilo/Mega/Giga on y-axis. This is different than labelsKMB in
- that it uses base 2, not 10.
-
- Type: boolean
- Default: false
- *)
- -> ?labelsUTC:bool
- (** labelsUTC http://dygraphs.com/options.html#labelsUTC
-
- Show date/time labels according to UTC (instead of local time).
-
- Type: boolean
- Default: false
- *)
- -> ?maxNumberWidth:int
- (** maxNumberWidth http://dygraphs.com/options.html#maxNumberWidth
-
- When displaying numbers in normal (not scientific) mode, large numbers will
- be displayed with many trailing zeros (e.g. 100000000 instead of 1e9). This
- can lead to unwieldy y-axis labels. If there are more than maxNumberWidth
- digits to the left of the decimal in a number, dygraphs will switch to
- scientific notation, even when not operating in scientific mode. If you'd
- like to see all those digits, set this to something large, like 20 or 30.
-
- Type: integer
- Default: 6
- *)
- -> ?sigFigs:int
- (** sigFigs http://dygraphs.com/options.html#sigFigs
-
- By default, dygraphs displays numbers with a fixed number of digits after the
- decimal point. If you'd prefer to have a fixed number of significant figures,
- set this option to that number of sig figs. A value of 2, for instance, would
- cause 1 to be display as 1.0 and 1234 to be displayed as 1.23e+3.
-
- Type: integer
- Default: null
- *)
- -> unit
- -> t
-[@@js.builder ]
-[@@@ocamlformat "enable"]
-
-val legendFormatter : t -> (Legend_data.t -> string) option [@@js.get]
-
-val zoomCallback : t -> (xmin:float -> xmax:float -> yRanges:Range.t array -> unit) option
- [@@js.get]
-
-val height : t -> int option [@@js.get]
-val width : t -> int option [@@js.get]
-
-(** This is the lodash.js deep-merge implementation *)
-val merge_internal : t -> prefer:t -> t
- [@@js.global "_.merge"]
-
-(* [merge_internal] actually mutably changes the first [t] (and returns it) *)
-
-(** merge two [t]s, preferring options in [prefer] *)
-val merge : t -> prefer:t -> t
- [@@js.custom
- let merge t ~prefer = create () |> merge_internal ~prefer:t |> merge_internal ~prefer]
diff --git a/bindings/dygraph/src/per_series_info.ml b/bindings/dygraph/src/per_series_info.ml
deleted file mode 100644
index 5e63a304..00000000
--- a/bindings/dygraph/src/per_series_info.ml
+++ /dev/null
@@ -1,18 +0,0 @@
-open Core
-open! Import
-
-type t =
- { label : string
- ; override_label_for_visibility : string option
- ; visible_by_default : bool
- }
-[@@deriving fields ~getters]
-
-let create ?override_label_for_visibility label ~visible_by_default =
- { label; override_label_for_visibility; visible_by_default }
-;;
-
-let create_all_visible labels =
- List.map labels ~f:(fun label ->
- { label; override_label_for_visibility = None; visible_by_default = true })
-;;
diff --git a/bindings/dygraph/src/per_series_info.mli b/bindings/dygraph/src/per_series_info.mli
deleted file mode 100644
index d6f35ed7..00000000
--- a/bindings/dygraph/src/per_series_info.mli
+++ /dev/null
@@ -1,27 +0,0 @@
-open! Core
-open! Import
-
-type t =
- { label : string
- ; override_label_for_visibility : string option
- (** It may be helpful to distinguish the series label from the "label for visibility".
-
- For example, in some graphs we encode information about the symbol we are looking at
- in the series label. That information changes as you look at different symbols.
- However, the second series always semantically means the same thing as you move from
- symbol to symbol. If you uncheck the second series to disable visibility, you may
- want to remember that change even if the series label changes.
-
- If you want to just use the [label] as the semantic identifier for persisting
- visilibity, then just set [override_label_for_visibility] to None. *)
- ; visible_by_default : bool
- }
-[@@deriving fields ~getters]
-
-val create
- : ?override_label_for_visibility:string
- -> string
- -> visible_by_default:bool
- -> t
-
-val create_all_visible : string list -> t list
diff --git a/bindings/dygraph/src/plotter.ml b/bindings/dygraph/src/plotter.ml
deleted file mode 100644
index 372ae642..00000000
--- a/bindings/dygraph/src/plotter.ml
+++ /dev/null
@@ -1,39 +0,0 @@
-[@@@js.dummy "!! This code has been generated by gen_js_api !!"]
-[@@@ocaml.warning "-7-32-39"]
-
-open! Core
-open! Import
-open! Gen_js_api
-
-type t = Ojs.t
-
-let rec t_of_js : Ojs.t -> t = fun (x2 : Ojs.t) -> x2
-and t_to_js : t -> Ojs.t = fun (x1 : Ojs.t) -> x1
-
-let line_plotter : t =
- t_of_js
- (Ojs.get_prop_ascii
- (Ojs.get_prop_ascii (Ojs.get_prop_ascii Ojs.global "Dygraph") "Plotters")
- "linePlotter")
-;;
-
-let fill_plotter : t =
- t_of_js
- (Ojs.get_prop_ascii
- (Ojs.get_prop_ascii (Ojs.get_prop_ascii Ojs.global "Dygraph") "Plotters")
- "fillPlotter")
-;;
-
-let error_bar_plotter : t =
- t_of_js
- (Ojs.get_prop_ascii
- (Ojs.get_prop_ascii (Ojs.get_prop_ascii Ojs.global "Dygraph") "Plotters")
- "errorPlotter")
-;;
-
-let point_plotter : t =
- t_of_js
- (Ojs.get_prop_ascii
- (Ojs.get_prop_ascii (Ojs.get_prop_ascii Ojs.global "Dygraph") "Plotters")
- "pointPlotter")
-;;
diff --git a/bindings/dygraph/src/plotter.mli b/bindings/dygraph/src/plotter.mli
deleted file mode 100644
index fd491d33..00000000
--- a/bindings/dygraph/src/plotter.mli
+++ /dev/null
@@ -1,12 +0,0 @@
-open! Core
-open! Import
-open! Gen_js_api
-
-type t
-
-val t_to_js : t -> Ojs.t
-val t_of_js : Ojs.t -> t
-val line_plotter : t [@@js.global "Dygraph.Plotters.linePlotter"]
-val fill_plotter : t [@@js.global "Dygraph.Plotters.fillPlotter"]
-val error_bar_plotter : t [@@js.global "Dygraph.Plotters.errorPlotter"]
-val point_plotter : t [@@js.global "Dygraph.Plotters.pointPlotter"]
diff --git a/bindings/dygraph/src/point.ml b/bindings/dygraph/src/point.ml
deleted file mode 100644
index 94ab4b46..00000000
--- a/bindings/dygraph/src/point.ml
+++ /dev/null
@@ -1,37 +0,0 @@
-[@@@js.dummy "!! This code has been generated by gen_js_api !!"]
-[@@@ocaml.warning "-7-32-39"]
-
-open! Core
-open! Import
-open Gen_js_api
-
-type t =
- { xval : float
- ; yval : float
- ; canvasx : float
- ; canvasy : float
- ; name : string
- ; idx : int
- }
-
-let rec t_of_js : Ojs.t -> t =
- fun (x2 : Ojs.t) ->
- { xval = Ojs.float_of_js (Ojs.get_prop_ascii x2 "xval")
- ; yval = Ojs.float_of_js (Ojs.get_prop_ascii x2 "yval")
- ; canvasx = Ojs.float_of_js (Ojs.get_prop_ascii x2 "canvasx")
- ; canvasy = Ojs.float_of_js (Ojs.get_prop_ascii x2 "canvasy")
- ; name = Ojs.string_of_js (Ojs.get_prop_ascii x2 "name")
- ; idx = Ojs.int_of_js (Ojs.get_prop_ascii x2 "idx")
- }
-
-and t_to_js : t -> Ojs.t =
- fun (x1 : t) ->
- Ojs.obj
- [| "xval", Ojs.float_to_js x1.xval
- ; "yval", Ojs.float_to_js x1.yval
- ; "canvasx", Ojs.float_to_js x1.canvasx
- ; "canvasy", Ojs.float_to_js x1.canvasy
- ; "name", Ojs.string_to_js x1.name
- ; "idx", Ojs.int_to_js x1.idx
- |]
-;;
diff --git a/bindings/dygraph/src/point.mli b/bindings/dygraph/src/point.mli
deleted file mode 100644
index 033b8fc7..00000000
--- a/bindings/dygraph/src/point.mli
+++ /dev/null
@@ -1,17 +0,0 @@
-open! Core
-open! Import
-open Gen_js_api
-
-(** http://dygraphs.com/options.html#point_properties *)
-
-type t =
- { xval : float
- ; yval : float
- ; canvasx : float
- ; canvasy : float
- ; name : string
- ; idx : int
- }
-
-val t_to_js : t -> Ojs.t
-val t_of_js : Ojs.t -> t
diff --git a/bindings/dygraph/src/range.ml b/bindings/dygraph/src/range.ml
deleted file mode 100644
index 30fb8614..00000000
--- a/bindings/dygraph/src/range.ml
+++ /dev/null
@@ -1,29 +0,0 @@
-open Core
-open! Import
-open Gen_js_api
-
-type t =
- { low : float
- ; high : float
- }
-[@@deriving sexp, equal]
-
-(* ranges in dygraphs are represented as [| low; high |]. *)
-let t_to_js { low; high } = Ojs.array_to_js Ojs.float_to_js [| low; high |]
-
-let t_of_js ojs =
- let data = Ojs.array_of_js Ojs.float_of_js ojs in
- { low = data.(0); high = data.(1) }
-;;
-
-module Spec = struct
- type nonrec t =
- | Infer
- | Specified of t
- [@@deriving sexp, equal]
-
- let t_to_js = function
- | Infer -> Ojs.null
- | Specified t -> t_to_js t
- ;;
-end
diff --git a/bindings/dygraph/src/range.mli b/bindings/dygraph/src/range.mli
deleted file mode 100644
index e6b5178f..00000000
--- a/bindings/dygraph/src/range.mli
+++ /dev/null
@@ -1,24 +0,0 @@
-open! Core
-open! Import
-open Gen_js_api
-
-(** Ranges in dygraphs are represented as a number array with two elements. This makes
- them a bit easier to work with. *)
-type t =
- { low : float
- ; high : float
- }
-[@@deriving sexp, equal]
-
-val t_to_js : t -> Ojs.t
-val t_of_js : Ojs.t -> t
-
-module Spec : sig
- (** This is used when specifying a range as an input. *)
- type nonrec t =
- | Infer
- | Specified of t
- [@@deriving sexp, equal]
-
- val t_to_js : t -> Ojs.t
-end
diff --git a/bindings/dygraph/src/raw_html.ml b/bindings/dygraph/src/raw_html.ml
deleted file mode 100644
index 217d4dac..00000000
--- a/bindings/dygraph/src/raw_html.ml
+++ /dev/null
@@ -1,17 +0,0 @@
-open Core
-open Import
-open Gen_js_api
-
-type t = string [@@deriving compare, equal, sexp]
-
-let t_to_js = Ojs.string_to_js
-let t_of_js = Ojs.string_of_js
-let of_string s = s
-
-let view ~tag t =
- Vdom.Node.inner_html
- ~tag
- ~attrs:[ Vdom.Attr.empty ]
- ~this_html_is_sanitized_and_is_totally_safe_trust_me:t
- ()
-;;
diff --git a/bindings/dygraph/src/raw_html.mli b/bindings/dygraph/src/raw_html.mli
deleted file mode 100644
index 20677fec..00000000
--- a/bindings/dygraph/src/raw_html.mli
+++ /dev/null
@@ -1,13 +0,0 @@
-open! Core
-open Import
-open Gen_js_api
-
-(** Dygraphs returns "raw html" as strings in some callbacks (see [Legend_data] and
- [legendFormatter]). We mint this type so that the types make it more clear which
- fields are just normal strings and which are html strings. *)
-type t [@@deriving compare, equal, sexp]
-
-val t_to_js : t -> Ojs.t
-val t_of_js : Ojs.t -> t
-val of_string : string -> t
-val view : tag:string -> t -> Vdom.Node.t
diff --git a/bindings/dygraph/src/update_options.ml b/bindings/dygraph/src/update_options.ml
deleted file mode 100644
index bbc399e2..00000000
--- a/bindings/dygraph/src/update_options.ml
+++ /dev/null
@@ -1,18 +0,0 @@
-open! Core
-open! Import
-open Gen_js_api
-
-type t = Ojs.t
-
-let t_to_js x = x
-let t_of_js x = x
-
-let create ?options ?data () =
- (* This is intentionally different than an object with a property "options". *)
- let options =
- let default = Ojs.empty_obj () in
- Option.value_map options ~default ~f:Options.t_to_js
- in
- Option.iter data ~f:(fun data -> Ojs.set_prop_ascii options "file" (Data.t_to_js data));
- options
-;;
diff --git a/bindings/dygraph/src/update_options.mli b/bindings/dygraph/src/update_options.mli
deleted file mode 100644
index 0bf8ffcd..00000000
--- a/bindings/dygraph/src/update_options.mli
+++ /dev/null
@@ -1,9 +0,0 @@
-open! Core
-open! Import
-open Gen_js_api
-
-type t
-
-val t_to_js : t -> Ojs.t
-val t_of_js : Ojs.t -> t
-val create : ?options:Options.t -> ?data:Data.t -> unit -> t
diff --git a/bindings/dygraph/src/which_y_axis.ml b/bindings/dygraph/src/which_y_axis.ml
deleted file mode 100644
index 11b73330..00000000
--- a/bindings/dygraph/src/which_y_axis.ml
+++ /dev/null
@@ -1,26 +0,0 @@
-[@@@js.dummy "!! This code has been generated by gen_js_api !!"]
-[@@@ocaml.warning "-7-32-39"]
-
-open! Core
-open! Import
-open Gen_js_api
-
-type t =
- [ `y1
- | `y2
- ]
-
-let rec t_of_js : Ojs.t -> t =
- fun (x2 : Ojs.t) ->
- let x3 = x2 in
- match Ojs.string_of_js x3 with
- | "y1" -> `y1
- | "y2" -> `y2
- | _ -> assert false
-
-and t_to_js : t -> Ojs.t =
- fun (x1 : [ `y1 | `y2 ]) ->
- match x1 with
- | `y1 -> Ojs.string_to_js "y1"
- | `y2 -> Ojs.string_to_js "y2"
-;;
diff --git a/bindings/dygraph/src/which_y_axis.mli b/bindings/dygraph/src/which_y_axis.mli
deleted file mode 100644
index 01cfcb29..00000000
--- a/bindings/dygraph/src/which_y_axis.mli
+++ /dev/null
@@ -1,11 +0,0 @@
-open! Core
-open! Import
-open Gen_js_api
-
-type t =
- ([ `y1
- | `y2
- ]
- [@js.enum])
-
-val t_to_js : t -> Ojs.t
diff --git a/bindings/dygraph/src/with_bonsai.ml b/bindings/dygraph/src/with_bonsai.ml
deleted file mode 100644
index af78199a..00000000
--- a/bindings/dygraph/src/with_bonsai.ml
+++ /dev/null
@@ -1,259 +0,0 @@
-open Core
-open Import
-module Mutable_state_tracker = Bonsai_web_ui_widget.Low_level
-
-(* This top-level side-effect installs the CSS for dygraphs.
- We need it in this file because if the side-effect lives
- in an otherwise-empty file, or in a file that only contains
- module aliases, then the dead-code-eliminator will remove
- the file (including your side-effect).
-
- By putting it here, anyone that uses the With_bonsai module
- will force the side-effect to be evaluated. *)
-let () = Css.install_css ()
-
-module Legend_model = struct
- type t = { visibility : bool list } [@@deriving equal, fields ~getters]
-end
-
-let id = Type_equal.Id.create ~name:"dygraph" [%sexp_of: opaque]
-
-(* Defaults come from Dygraph's documentation:
-
- https://dygraphs.com/options.html#height
- https://dygraphs.com/options.html#width
-*)
-let default_width = 480
-let default_height = 320
-
-let widget ?with_graph ?on_zoom data options ~graph_tracker =
- (* This function tells the graph to resize itself to fit its contents. This is
- required because at the point when the graph is created, the element [el]
- (created down below in [init]) hasn't yet been attached to the Dom, so it
- initially detects that it's size should be 0x0. When requestAnimationFrame
- completes, according to the semantics of Bonsai_web, our graph has been
- successfully inserted into the Dom, so we can trigger another resize and
- it'll compute the correct size. *)
- let resize_when_inserted_into_the_dom graph _time = Graph.resize graph in
- let override_zoom_callback ~graph options =
- match on_zoom with
- | None -> options
- | Some on_zoom ->
- let zoomCallback =
- let caller's_zoom_callback = Options.zoomCallback options in
- fun ~xmin ~xmax ~yRanges ->
- Option.iter caller's_zoom_callback ~f:(fun f -> f ~xmin ~xmax ~yRanges);
- Vdom.Effect.Expert.handle_non_dom_event_exn (on_zoom graph ~xmin ~xmax ~yRanges)
- in
- let our_options = Options.create ~zoomCallback () in
- Options.merge options ~prefer:our_options
- in
- let resize_if_width_or_height_changed graph ~old_options ~options =
- (* Updating the width and height via [updateOptions] does not work.
- We need to detect when the width/height change and call
- [Graph.resize_explicit].
- https://dygraphs.com/jsdoc/symbols/Dygraph.html#resize *)
- let old_width = Options.width old_options in
- let old_height = Options.height old_options in
- let width = Option.bind options ~f:Options.width in
- let height = Option.bind options ~f:Options.height in
- let pair_with_default w h =
- match w, h with
- | None, None -> None
- | Some w, Some h -> Some (w, h)
- | Some w, None -> Some (w, default_height)
- | None, Some h -> Some (default_width, h)
- in
- let old_width_and_height = pair_with_default old_width old_height in
- let new_width_and_height = pair_with_default width height in
- match old_width_and_height, new_width_and_height with
- | None, None -> ()
- | Some old_wh, Some new_wh when [%equal: int * int] old_wh new_wh -> ()
- | Some _, None -> Graph.resize graph
- | Some _, Some (width, height) | None, Some (width, height) ->
- Graph.resize_explicit graph ~width ~height
- in
- Vdom.Node.widget
- ()
- ~id
- ~destroy:(fun (_, _, _, graph, animation_id, graph_tracker_id) _el ->
- graph_tracker.Mutable_state_tracker.unsafe_destroy graph_tracker_id;
- (* Free resources allocated by the graph *)
- Graph.destroy graph;
- (* If for some reason the animation-frame never fired and we're already
- being removed, go ahead and cancel the callback. *)
- Dom_html.window##cancelAnimationFrame animation_id)
- ~init:(fun () ->
- let el = Dom_html.createDiv Dom_html.document in
- let graph = Graph.create el data options in
- let graph_tracker_id = graph_tracker.Mutable_state_tracker.unsafe_init graph in
- let () =
- let options = override_zoom_callback ~graph options in
- let updateOptions = Update_options.create ~options ?data:None () in
- Graph.updateOptions graph updateOptions
- in
- Option.iter with_graph ~f:(fun with_graph -> with_graph graph);
- let animation_id =
- Dom_html.window##requestAnimationFrame
- (Js.wrap_callback (resize_when_inserted_into_the_dom graph))
- in
- (data, options, on_zoom, graph, animation_id, graph_tracker_id), el)
- ~update:
- (fun
- (old_data, old_options, old_on_zoom, graph, animation_id, graph_tracker_id) el ->
- let () =
- let data = Option.some_if (not (phys_equal old_data data)) data in
- let options =
- match phys_equal old_options options, phys_equal old_on_zoom on_zoom with
- | true, true -> None
- | _ -> Some (override_zoom_callback ~graph options)
- in
- (match data, options with
- | None, None -> ()
- | _, options ->
- let updateOptions = Update_options.create ?options ?data () in
- Graph.updateOptions graph updateOptions);
- resize_if_width_or_height_changed graph ~old_options ~options
- in
- (data, options, on_zoom, graph, animation_id, graph_tracker_id), el)
-;;
-
-let create_graph ?with_graph ?on_zoom data options ~graph_tracker =
- let on_zoom =
- match on_zoom with
- | None -> Bonsai.Value.return None
- | Some on_zoom -> Bonsai.Value.map on_zoom ~f:Option.some
- in
- let%arr data = data
- and options = options
- and on_zoom = on_zoom
- and graph_tracker = graph_tracker in
- widget ?with_graph ?on_zoom data options ~graph_tracker
-;;
-
-let create_options ~x_label ~y_labels ~visibility ~legendFormatter =
- let labels = x_label :: y_labels in
- (* We create an element but never actually put it anywhere. *)
- let hidden_legend = Dom_html.createDiv Dom_html.document in
- Options.create
- ()
- ~xlabel:x_label
- ~labels
- ~visibility
- ~legend:`always (* If [legend:`never], then [legendFormatter] doesn't fire. *)
- ~labelsDiv_el:hidden_legend
- ~legendFormatter
-;;
-
-let create_default_legend ~x_label ~per_series_info =
- let%sub model, view, inject = Default_legend.create ~x_label ~per_series_info in
- (* project out visibility *)
- let model =
- let%map model = model in
- { Legend_model.visibility =
- List.map model.series ~f:Default_legend.Model.Series.is_visible
- }
- in
- let inject =
- let%map inject = inject in
- fun data -> inject Default_legend.Action.(From_graph data)
- in
- return (Bonsai.Value.map3 model view inject ~f:Tuple3.create)
-;;
-
-let format_legend inject_legend_data options data =
- let caller's_legend_formatter = Option.bind options ~f:Options.legendFormatter in
- (* we call the legendFormatter option set on [options] in case the caller is relying
- on it for side effects. *)
- Option.iter caller's_legend_formatter ~f:(fun f -> ignore (f data : string));
- Vdom.Effect.Expert.handle_non_dom_event_exn (inject_legend_data data);
- (* we are pointing the legend managed by dygraph to a hidden div (see
- [create_options]) so this should be invisible. *)
- "this should not be visible"
-;;
-
-let build_options options visibility legendFormatter x_label y_labels =
- let our_options = create_options ~x_label ~y_labels ~visibility ~legendFormatter in
- match options with
- | None -> our_options
- | Some options -> Options.merge options ~prefer:our_options
-;;
-
-let visibility ~legend_model ~num_series =
- let visibility =
- let%map.Bonsai visibility_from_legend = legend_model >>| Legend_model.visibility
- and num_series = num_series in
- let visibility_len = List.length visibility_from_legend in
- if visibility_len < num_series
- then (
- (* Dygraphs has a bug where it will throw an error if the length of [visibility] is
- ever less than the number of series in the data. To work around this, we pad
- [visibility] with trues. *)
- let padding = List.init (num_series - visibility_len) ~f:(Fn.const true) in
- visibility_from_legend @ padding)
- else visibility_from_legend
- in
- visibility |> Bonsai.Value.cutoff ~equal:[%equal: bool list]
-;;
-
-type t =
- { graph_view : Vdom.Node.t
- ; modify_graph : (Graph.t -> unit) -> unit Effect.t
- }
-
-let create
- ~key
- ~x_label
- ~per_series_info
- ?custom_legend
- ?options
- ?with_graph
- ?on_zoom
- ?(extra_attr = Value.return Vdom.Attr.empty)
- ~data
- ()
- =
- let options =
- Option.value_map
- options
- ~default:(Bonsai.Value.return None)
- ~f:(Bonsai.Value.map ~f:Option.some)
- in
- let%sub legend =
- match custom_legend with
- | Some legend -> Bonsai.read legend
- | None -> create_default_legend ~x_label ~per_series_info
- in
- let%pattern_bind legend_model, legend_view, inject_legend_data = legend in
- let inject_legend_data = Bonsai.Value.cutoff inject_legend_data ~equal:phys_equal in
- let y_labels =
- Bonsai.Value.map per_series_info ~f:(List.map ~f:Per_series_info.label)
- in
- let visibility =
- let num_series = Bonsai.Value.map per_series_info ~f:(List.length :> _ -> _) in
- visibility ~legend_model ~num_series
- in
- let legendFormatter = Bonsai.Value.map2 inject_legend_data options ~f:format_legend in
- let options =
- Bonsai.Value.map5 options visibility legendFormatter x_label y_labels ~f:build_options
- in
- let%sub graph_tracker = Mutable_state_tracker.component () in
- let%sub graph = create_graph ?with_graph ?on_zoom data options ~graph_tracker in
- let%arr graph = graph
- and legend_view = legend_view
- and key = key
- and graph_tracker = graph_tracker
- and extra_attr = extra_attr in
- let graph_view =
- Vdom.Node.div
- ~key
- ~attrs:
- [ Vdom.Attr.class_ "dygraph"
- ; Vdom.Attr.style (Css_gen.flex_container ())
- ; extra_attr
- ]
- [ graph; legend_view ]
- in
- let modify_graph = graph_tracker.Mutable_state_tracker.modify in
- { graph_view; modify_graph }
-;;
diff --git a/bindings/dygraph/src/with_bonsai.mli b/bindings/dygraph/src/with_bonsai.mli
deleted file mode 100644
index 48e872e8..00000000
--- a/bindings/dygraph/src/with_bonsai.mli
+++ /dev/null
@@ -1,56 +0,0 @@
-open! Core
-open Import
-
-(** The recommended way to create dygraphs (with bonsai). *)
-
-module Legend_model : sig
- type t = { visibility : bool list } [@@deriving equal, fields ~getters]
-end
-
-(** This is the legend that [create] will when nothing is passed to [custom_legend].
-
- Even if you intend to pass this into [create], it may be useful to create this
- yourself to gain access to the Legend_model.t.
-*)
-val create_default_legend
- : x_label:string Bonsai.Value.t
- -> per_series_info:Per_series_info.t list Bonsai.Value.t
- -> (Legend_model.t * Vdom.Node.t * (Legend_data.t -> unit Ui_effect.t))
- Bonsai.Computation.t
-
-type t =
- { graph_view : Vdom.Node.t
- ; modify_graph : (Graph.t -> unit) -> unit Effect.t
- }
-
-val create
- : key:string Bonsai.Value.t
- (** [key] is a virtualdom concept that allows it to identify which items in a list have
- changed. For more information, see
- https://reactjs.org/docs/lists-and-keys.html#keys.
-
- Every graph in your document should have a unique [key].
-
- For a given graph, [key] should be constant.
- *)
- -> x_label:string Bonsai.Value.t
- -> per_series_info:Per_series_info.t list Bonsai.Value.t
- -> ?custom_legend:
- (Legend_model.t * Vdom.Node.t * (Legend_data.t -> unit Ui_effect.t)) Bonsai.Value.t
- (** [custom_legend] defaults to Default_legend. If you don't want that legend, you're
- free to pass in your own bonsai computation. *)
- -> ?options:Options.t Bonsai.Value.t
- -> ?with_graph:(Graph.t -> unit)
- (** This hook may be useful if you want to, for example, bind the graph to some global
- variable on the window. That way you can poke at the graph in the console. *)
- -> ?on_zoom:
- (Graph.t
- -> xmin:float
- -> xmax:float
- -> yRanges:Range.t array
- -> unit Vdom.Effect.t)
- Bonsai.Value.t
- -> ?extra_attr:Vdom.Attr.t Bonsai.Value.t
- -> data:Data.t Bonsai.Value.t
- -> unit
- -> t Bonsai.Computation.t
diff --git a/bindings/dygraph/src/x_axis_mapping.ml b/bindings/dygraph/src/x_axis_mapping.ml
deleted file mode 100644
index c668f3c9..00000000
--- a/bindings/dygraph/src/x_axis_mapping.ml
+++ /dev/null
@@ -1,91 +0,0 @@
-open Core
-open Import
-
-(** How this works:
-
- The general idea here is that dygraphs does not have native support for putting
- "breaks" or "gaps" in the x-axis. It assumes the x-axis will be continuous in time
- (for time series).
-
- We don't want that. We want to hide overnights and weekends.
-
- In order to achieve that, we generate a (piecewise-linear) mapping between "real time"
- and "graph time" where we squash the overnight and weekend portions of "real time"
- into a tiny section of "graph time".
-
- This mapping is invertible, meaning that from any "real time" we can produce the
- corresponding "graph time" and vice versa. For a more precise description of how we
- produce this mapping, look below in [Time_mapping].
-
- So, given this mapping, we hook into the dygraphs library at the following points:
-
- - Before handing over our time series data, we map "real time" to "graph time"
-
- - Before dygraphs displays a time value in the legend (via [valueFormatter]), we map
- "graph time" back to "real time"
-
- - Before dygraphs display x-axis tick labels (via axisLabelFormatter), we map "graph
- time" back to "real time".
-
- This is based on this stack overflow question
- (https://stackoverflow.com/questions/17888989/how-to-skip-weekends-on-dygraps-x-axis)
- in which the author of dygraphs (danvk) agrees this is how you need to do it. *)
-
-let dygraphs_date_axis_label_formatter
- : unit -> Js.date Js.t -> Granularity.t -> Options.Opts.t -> Js.js_string Js.t
- =
- fun () -> Js.Unsafe.pure_js_expr {| Dygraph.dateAxisLabelFormatter |}
-;;
-
-let dygraphs_number_axis_label_formatter
- : unit -> Js.number Js.t -> Granularity.t -> Options.Opts.t -> Js.js_string Js.t
- =
- fun () -> Js.Unsafe.pure_js_expr {| Dygraph.numberAxisLabelFormatter |}
-;;
-
-let default_axis_label_formatter x gran opts =
- match x with
- | `number x ->
- let number = Js.number_of_float x in
- dygraphs_number_axis_label_formatter () number gran opts |> Js.to_string
- | `date d -> dygraphs_date_axis_label_formatter () d gran opts |> Js.to_string
-;;
-
-(* due to the floatness of the piecewise_linear math, timestamps come can out weird. I
- can't imagine anyone needs more precision than ms (and if they do, they can't get it
- anyways b/c of dates in javascript), so this rounding feels relatively
- uncontroversial and makes the output look a lot better. *)
-let round_time_nearest_ms time ~zone =
- let date, ofday = Time_ns.to_date_ofday time ~zone in
- let span = Time_ns.Ofday.to_span_since_start_of_day ofday in
- let ms = Time_ns.Span.to_ms span |> Float.iround_nearest_exn in
- let ofday = Time_ns.Span.of_int_ms ms |> Time_ns.Ofday.of_span_since_start_of_day_exn in
- Time_ns.of_date_ofday ~zone date ofday
-;;
-
-let default_value_formatter ~zone ms_since_epoch =
- let time = Time_ns.of_span_since_epoch (Time_ns.Span.of_ms ms_since_epoch) in
- Time_ns.to_string_trimmed (round_time_nearest_ms time ~zone) ~zone
-;;
-
-type t =
- { time_to_x_value : Time_ns.t -> Time_ns.t
- ; x_value_to_time : Time_ns.t -> Time_ns.t
- ; value_formatter : float -> Options.Opts.t -> string
- ; axis_label_formatter :
- Number_or_js_date.t -> Granularity.t -> Options.Opts.t -> string
- }
-
-let default ~zone =
- { time_to_x_value = Fn.id
- ; x_value_to_time = Fn.id
- ; value_formatter = (fun x _opts -> default_value_formatter x ~zone)
- ; axis_label_formatter = default_axis_label_formatter
- }
-;;
-
-module For_dygraph_libraries = struct
- let round_time_nearest_ms = round_time_nearest_ms
- let dygraphs_date_axis_label_formatter = dygraphs_date_axis_label_formatter
- let dygraphs_number_axis_label_formatter = dygraphs_number_axis_label_formatter
-end
diff --git a/bindings/dygraph/src/x_axis_mapping.mli b/bindings/dygraph/src/x_axis_mapping.mli
deleted file mode 100644
index 4eccf717..00000000
--- a/bindings/dygraph/src/x_axis_mapping.mli
+++ /dev/null
@@ -1,60 +0,0 @@
-open Core
-open! Import
-
-(** This module is a helper function designed to make it easy (easier) to make the spacing
- of the x-axis of a dygraphs graph differ from the x-values themselves. Currently,
- this module deals only with time x-values, but may be extended to deal with numeric
- x-values in the future.
-
- Dygraphs does not have native support for putting "breaks" or "gaps" in the x-axis.
- It assumes the x-axis will be continuous in time (for time series) and that the space
- on the x-axis between any two points in time should be proportional to the difference
- of those times.
-
- Although that's a very reasonable default, we don't always want that - for example, we
- may want to effectively hide overnights and weekends (i.e. give those very little
- space on the x-axis).
-
- In order to do this, you can generate a [t] which provides a mapping between "real
- time" and "x-axis time". To use a [t] correctly, you need to hook into dygraphs in
- the following three places:
-
- - Before handing over our time series data, use [time_to_x_value] to map your data's
- "real time" to the times we want to use for x-values.
-
- - Pass [valueFormatter] to [Dygraph.Options.Axis_options.create] to map x-values
- back to "real time" before displaying values in the legend.
-
- - Pass [axisLabelFormatter] to [Dygraph.Options.Axis_options.create] to map x-values
- back to "real time" before displaying x-axis tick labels.
-
- For an example usage, see [../examples/ocaml/hide_overnights.ml}
-*)
-
-type t =
- { time_to_x_value : Time_ns.t -> Time_ns.t
- ; x_value_to_time : Time_ns.t -> Time_ns.t
- ; value_formatter : float -> Options.Opts.t -> string
- ; axis_label_formatter :
- Number_or_js_date.t -> Granularity.t -> Options.Opts.t -> string
- }
-
-val default : zone:Time_float.Zone.t -> t
-
-module For_dygraph_libraries : sig
- val round_time_nearest_ms : Time_ns.t -> zone:Core_private.Time_zone.t -> Time_ns.t
-
- val dygraphs_date_axis_label_formatter
- : unit
- -> Js.date Js.t
- -> Granularity.t
- -> Options.Opts.t
- -> Js.js_string Js.t
-
- val dygraphs_number_axis_label_formatter
- : unit
- -> Js.number Js.t
- -> Granularity.t
- -> Options.Opts.t
- -> Js.js_string Js.t
-end
diff --git a/bindings/feather_icon/README.mdx b/bindings/feather_icon/README.mdx
deleted file mode 100644
index 9d0b858b..00000000
--- a/bindings/feather_icon/README.mdx
+++ /dev/null
@@ -1,30 +0,0 @@
-# Feather icons
-
-This is a port of [feathericons](https://feathericons.com/) for use in jsoo. Check
-out the bonsai demo [here](https://bonsai:8547/).
-
-To make one, it's as easy as:
-
-```ocaml skip
-Feather_icon.svg Alert_circle
-```
-
-`Alert_circle` is just one of 286 options. See the rest [here](https://bonsai:8547/).
-
-You can optionally specify the `size`, `stroke`, `stroke_width`, and
-`fill`. See the full `svg` function here:
-
-
-```ocaml
-val svg
- : ?size:[< Css_gen.Length.t ]
- -> ?stroke:[< Css_gen.Color.t ]
- -> ?fill:[< Css_gen.Color.t ]
- -> ?stroke_width:[< Css_gen.Length.t ]
- -> ?extra_attrs:Vdom.Attr.t list
- -> t
- -> Vdom.Node.t
-```
-
-
-
diff --git a/bindings/feather_icon/dist/LICENSE-feather b/bindings/feather_icon/dist/LICENSE-feather
deleted file mode 100644
index c2f512f4..00000000
--- a/bindings/feather_icon/dist/LICENSE-feather
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2013-2017 Cole Bemis
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/bindings/feather_icon/dune b/bindings/feather_icon/dune
deleted file mode 100644
index e69de29b..00000000
diff --git a/bindings/feather_icon/src/dune b/bindings/feather_icon/src/dune
deleted file mode 100644
index e096c890..00000000
--- a/bindings/feather_icon/src/dune
+++ /dev/null
@@ -1,96 +0,0 @@
-(library
- (name feather_icon)
- (public_name bonsai.feather_icon)
- (libraries core bonsai_web)
- (preprocess
- (pps ppx_jane)))
-
-(rule
- (targets paths.ml paths.mli)
- (deps %{bin:ocaml-embed-file} paths/activity.svg paths/corner-down-left.svg
- paths/link.svg paths/shopping-bag.svg paths/airplay.svg
- paths/corner-down-right.svg paths/list.svg paths/shopping-cart.svg
- paths/alert-circle.svg paths/corner-left-down.svg paths/loader.svg
- paths/shuffle.svg paths/alert-octagon.svg paths/corner-left-up.svg
- paths/lock.svg paths/sidebar.svg paths/alert-triangle.svg
- paths/corner-right-down.svg paths/log-in.svg paths/skip-back.svg
- paths/align-center.svg paths/corner-right-up.svg paths/log-out.svg
- paths/skip-forward.svg paths/align-justify.svg paths/corner-up-left.svg
- paths/mail.svg paths/slack.svg paths/align-left.svg
- paths/corner-up-right.svg paths/map-pin.svg paths/slash.svg
- paths/align-right.svg paths/cpu.svg paths/map.svg paths/sliders.svg
- paths/anchor.svg paths/credit-card.svg paths/maximize-2.svg
- paths/smartphone.svg paths/aperture.svg paths/crop.svg paths/maximize.svg
- paths/smile.svg paths/archive.svg paths/crosshair.svg paths/meh.svg
- paths/speaker.svg paths/arrow-down-circle.svg paths/database.svg
- paths/menu.svg paths/square.svg paths/arrow-down-left.svg paths/delete.svg
- paths/message-circle.svg paths/star.svg paths/arrow-down-right.svg
- paths/disc.svg paths/message-square.svg paths/stop-circle.svg
- paths/arrow-down.svg paths/divide-circle.svg paths/mic-off.svg
- paths/sunrise.svg paths/arrow-left-circle.svg paths/divide-square.svg
- paths/mic.svg paths/sunset.svg paths/arrow-left.svg paths/divide.svg
- paths/minimize-2.svg paths/sun.svg paths/arrow-right-circle.svg
- paths/dollar-sign.svg paths/minimize.svg paths/tablet.svg
- paths/arrow-right.svg paths/download-cloud.svg paths/minus-circle.svg
- paths/tag.svg paths/arrow-up-circle.svg paths/download.svg
- paths/minus-square.svg paths/target.svg paths/arrow-up-left.svg
- paths/dribbble.svg paths/minus.svg paths/terminal.svg
- paths/arrow-up-right.svg paths/droplet.svg paths/monitor.svg
- paths/thermometer.svg paths/arrow-up.svg paths/edit-2.svg paths/moon.svg
- paths/thumbs-down.svg paths/at-sign.svg paths/edit-3.svg
- paths/more-horizontal.svg paths/thumbs-up.svg paths/award.svg
- paths/edit.svg paths/more-vertical.svg paths/toggle-left.svg
- paths/bar-chart-2.svg paths/external-link.svg paths/mouse-pointer.svg
- paths/toggle-right.svg paths/bar-chart.svg paths/eye-off.svg
- paths/move.svg paths/tool.svg paths/battery-charging.svg paths/eye.svg
- paths/music.svg paths/trash-2.svg paths/battery.svg paths/facebook.svg
- paths/navigation-2.svg paths/trash.svg paths/bell-off.svg
- paths/fast-forward.svg paths/navigation.svg paths/trello.svg
- paths/bell.svg paths/feather.svg paths/octagon.svg paths/trending-down.svg
- paths/bluetooth.svg paths/figma.svg paths/package.svg
- paths/trending-up.svg paths/bold.svg paths/file-minus.svg
- paths/paperclip.svg paths/triangle.svg paths/bookmark.svg
- paths/file-plus.svg paths/pause-circle.svg paths/truck.svg
- paths/book-open.svg paths/file.svg paths/pause.svg paths/tv.svg
- paths/book.svg paths/file-text.svg paths/pen-tool.svg paths/twitch.svg
- paths/box.svg paths/film.svg paths/percent.svg paths/twitter.svg
- paths/briefcase.svg paths/filter.svg paths/phone-call.svg paths/type.svg
- paths/calendar.svg paths/flag.svg paths/phone-forwarded.svg
- paths/umbrella.svg paths/camera-off.svg paths/folder-minus.svg
- paths/phone-incoming.svg paths/underline.svg paths/camera.svg
- paths/folder-plus.svg paths/phone-missed.svg paths/unlock.svg
- paths/cast.svg paths/folder.svg paths/phone-off.svg paths/upload-cloud.svg
- paths/check-circle.svg paths/framer.svg paths/phone-outgoing.svg
- paths/upload.svg paths/check-square.svg paths/frown.svg paths/phone.svg
- paths/user-check.svg paths/check.svg paths/gift.svg paths/pie-chart.svg
- paths/user-minus.svg paths/chevron-down.svg paths/git-branch.svg
- paths/play-circle.svg paths/user-plus.svg paths/chevron-left.svg
- paths/git-commit.svg paths/play.svg paths/users.svg
- paths/chevron-right.svg paths/github.svg paths/plus-circle.svg
- paths/user.svg paths/chevrons-down.svg paths/gitlab.svg
- paths/plus-square.svg paths/user-x.svg paths/chevrons-left.svg
- paths/git-merge.svg paths/plus.svg paths/video-off.svg
- paths/chevrons-right.svg paths/git-pull-request.svg paths/pocket.svg
- paths/video.svg paths/chevrons-up.svg paths/globe.svg paths/power.svg
- paths/voicemail.svg paths/chevron-up.svg paths/grid.svg paths/printer.svg
- paths/volume-1.svg paths/chrome.svg paths/hard-drive.svg paths/radio.svg
- paths/volume-2.svg paths/circle.svg paths/hash.svg paths/refresh-ccw.svg
- paths/volume.svg paths/clipboard.svg paths/headphones.svg
- paths/refresh-cw.svg paths/volume-x.svg paths/clock.svg paths/heart.svg
- paths/repeat.svg paths/watch.svg paths/cloud-drizzle.svg
- paths/help-circle.svg paths/rewind.svg paths/wifi-off.svg
- paths/cloud-lightning.svg paths/hexagon.svg paths/rotate-ccw.svg
- paths/wifi.svg paths/cloud-off.svg paths/home.svg paths/rotate-cw.svg
- paths/wind.svg paths/cloud-rain.svg paths/image.svg paths/rss.svg
- paths/x-circle.svg paths/cloud-snow.svg paths/inbox.svg paths/save.svg
- paths/x-octagon.svg paths/cloud.svg paths/info.svg paths/scissors.svg
- paths/x-square.svg paths/codepen.svg paths/instagram.svg paths/search.svg
- paths/x.svg paths/codesandbox.svg paths/italic.svg paths/send.svg
- paths/youtube.svg paths/code.svg paths/key.svg paths/server.svg
- paths/zap-off.svg paths/coffee.svg paths/layers.svg paths/settings.svg
- paths/zap.svg paths/columns.svg paths/layout.svg paths/share-2.svg
- paths/zoom-in.svg paths/command.svg paths/life-buoy.svg paths/share.svg
- paths/zoom-out.svg paths/compass.svg paths/link-2.svg paths/shield-off.svg
- paths/copy.svg paths/linkedin.svg paths/shield.svg)
- (action
- (bash "%{deps} -output paths")))
diff --git a/bindings/feather_icon/src/feather_icon.ml b/bindings/feather_icon/src/feather_icon.ml
deleted file mode 100644
index 073db00f..00000000
--- a/bindings/feather_icon/src/feather_icon.ml
+++ /dev/null
@@ -1,652 +0,0 @@
-open! Core
-open! Import
-
-type t =
- | Activity
- | Corner_down_left
- | Link
- | Shopping_bag
- | Airplay
- | Corner_down_right
- | List
- | Shopping_cart
- | Alert_circle
- | Corner_left_down
- | Loader
- | Shuffle
- | Alert_octagon
- | Corner_left_up
- | Lock
- | Sidebar
- | Alert_triangle
- | Corner_right_down
- | Log_in
- | Skip_back
- | Align_center
- | Corner_right_up
- | Log_out
- | Skip_forward
- | Align_justify
- | Corner_up_left
- | Mail
- | Slack
- | Align_left
- | Corner_up_right
- | Map_pin
- | Slash
- | Align_right
- | Cpu
- | Map
- | Sliders
- | Anchor
- | Credit_card
- | Maximize_2
- | Smartphone
- | Aperture
- | Crop
- | Maximize
- | Smile
- | Archive
- | Crosshair
- | Meh
- | Speaker
- | Arrow_down_circle
- | Database
- | Menu
- | Square
- | Arrow_down_left
- | Delete
- | Message_circle
- | Star
- | Arrow_down_right
- | Disc
- | Message_square
- | Stop_circle
- | Arrow_down
- | Divide_circle
- | Mic_off
- | Sunrise
- | Arrow_left_circle
- | Divide_square
- | Mic
- | Sunset
- | Arrow_left
- | Divide
- | Minimize_2
- | Sun
- | Arrow_right_circle
- | Dollar_sign
- | Minimize
- | Tablet
- | Arrow_right
- | Download_cloud
- | Minus_circle
- | Tag
- | Arrow_up_circle
- | Download
- | Minus_square
- | Target
- | Arrow_up_left
- | Dribbble
- | Minus
- | Terminal
- | Arrow_up_right
- | Droplet
- | Monitor
- | Thermometer
- | Arrow_up
- | Edit_2
- | Moon
- | Thumbs_down
- | At_sign
- | Edit_3
- | More_horizontal
- | Thumbs_up
- | Award
- | Edit
- | More_vertical
- | Toggle_left
- | Bar_chart_2
- | External_link
- | Mouse_pointer
- | Toggle_right
- | Bar_chart
- | Eye_off
- | Move
- | Tool
- | Battery_charging
- | Eye
- | Music
- | Trash_2
- | Battery
- | Facebook
- | Navigation_2
- | Trash
- | Bell_off
- | Fast_forward
- | Navigation
- | Trello
- | Bell
- | Feather
- | Octagon
- | Trending_down
- | Bluetooth
- | Figma
- | Package
- | Trending_up
- | Bold
- | File_minus
- | Paperclip
- | Triangle
- | Bookmark
- | File_plus
- | Pause_circle
- | Truck
- | Book_open
- | File
- | Pause
- | Tv
- | Book
- | File_text
- | Pen_tool
- | Twitch
- | Box
- | Film
- | Percent
- | Twitter
- | Briefcase
- | Filter
- | Phone_call
- | Type
- | Calendar
- | Flag
- | Phone_forwarded
- | Umbrella
- | Camera_off
- | Folder_minus
- | Phone_incoming
- | Underline
- | Camera
- | Folder_plus
- | Phone_missed
- | Unlock
- | Cast
- | Folder
- | Phone_off
- | Upload_cloud
- | Check_circle
- | Framer
- | Phone_outgoing
- | Upload
- | Check_square
- | Frown
- | Phone
- | User_check
- | Check
- | Gift
- | Pie_chart
- | User_minus
- | Chevron_down
- | Git_branch
- | Play_circle
- | User_plus
- | Chevron_left
- | Git_commit
- | Play
- | Users
- | Chevron_right
- | Github
- | Plus_circle
- | User
- | Chevrons_down
- | Gitlab
- | Plus_square
- | User_x
- | Chevrons_left
- | Git_merge
- | Plus
- | Video_off
- | Chevrons_right
- | Git_pull_request
- | Pocket
- | Video
- | Chevrons_up
- | Globe
- | Power
- | Voicemail
- | Chevron_up
- | Grid
- | Printer
- | Volume_1
- | Chrome
- | Hard_drive
- | Radio
- | Volume_2
- | Circle
- | Hash
- | Refresh_ccw
- | Volume
- | Clipboard
- | Headphones
- | Refresh_cw
- | Volume_x
- | Clock
- | Heart
- | Repeat
- | Watch
- | Cloud_drizzle
- | Help_circle
- | Rewind
- | Wifi_off
- | Cloud_lightning
- | Hexagon
- | Rotate_ccw
- | Wifi
- | Cloud_off
- | Home
- | Rotate_cw
- | Wind
- | Cloud_rain
- | Image
- | Rss
- | X_circle
- | Cloud_snow
- | Inbox
- | Save
- | X_octagon
- | Cloud
- | Info
- | Scissors
- | X_square
- | Codepen
- | Instagram
- | Search
- | X
- | Codesandbox
- | Italic
- | Send
- | Youtube
- | Code
- | Key
- | Server
- | Zap_off
- | Coffee
- | Layers
- | Settings
- | Zap
- | Columns
- | Layout
- | Share_2
- | Zoom_in
- | Command
- | Life_buoy
- | Share
- | Zoom_out
- | Compass
- | Link_2
- | Shield_off
- | Copy
- | Linkedin
- | Shield
-[@@deriving compare, enumerate, equal, sexp, sexp_grammar]
-
-let path = function
- | Activity -> Paths.activity_dot_svg
- | Corner_down_left -> Paths.corner_down_left_dot_svg
- | Link -> Paths.link_dot_svg
- | Shopping_bag -> Paths.shopping_bag_dot_svg
- | Airplay -> Paths.airplay_dot_svg
- | Corner_down_right -> Paths.corner_down_right_dot_svg
- | List -> Paths.list_dot_svg
- | Shopping_cart -> Paths.shopping_cart_dot_svg
- | Alert_circle -> Paths.alert_circle_dot_svg
- | Corner_left_down -> Paths.corner_left_down_dot_svg
- | Loader -> Paths.loader_dot_svg
- | Shuffle -> Paths.shuffle_dot_svg
- | Alert_octagon -> Paths.alert_octagon_dot_svg
- | Corner_left_up -> Paths.corner_left_up_dot_svg
- | Lock -> Paths.lock_dot_svg
- | Sidebar -> Paths.sidebar_dot_svg
- | Alert_triangle -> Paths.alert_triangle_dot_svg
- | Corner_right_down -> Paths.corner_right_down_dot_svg
- | Log_in -> Paths.log_in_dot_svg
- | Skip_back -> Paths.skip_back_dot_svg
- | Align_center -> Paths.align_center_dot_svg
- | Corner_right_up -> Paths.corner_right_up_dot_svg
- | Log_out -> Paths.log_out_dot_svg
- | Skip_forward -> Paths.skip_forward_dot_svg
- | Align_justify -> Paths.align_justify_dot_svg
- | Corner_up_left -> Paths.corner_up_left_dot_svg
- | Mail -> Paths.mail_dot_svg
- | Slack -> Paths.slack_dot_svg
- | Align_left -> Paths.align_left_dot_svg
- | Corner_up_right -> Paths.corner_up_right_dot_svg
- | Map_pin -> Paths.map_pin_dot_svg
- | Slash -> Paths.slash_dot_svg
- | Align_right -> Paths.align_right_dot_svg
- | Cpu -> Paths.cpu_dot_svg
- | Map -> Paths.map_dot_svg
- | Sliders -> Paths.sliders_dot_svg
- | Anchor -> Paths.anchor_dot_svg
- | Credit_card -> Paths.credit_card_dot_svg
- | Maximize_2 -> Paths.maximize_2_dot_svg
- | Smartphone -> Paths.smartphone_dot_svg
- | Aperture -> Paths.aperture_dot_svg
- | Crop -> Paths.crop_dot_svg
- | Maximize -> Paths.maximize_dot_svg
- | Smile -> Paths.smile_dot_svg
- | Archive -> Paths.archive_dot_svg
- | Crosshair -> Paths.crosshair_dot_svg
- | Meh -> Paths.meh_dot_svg
- | Speaker -> Paths.speaker_dot_svg
- | Arrow_down_circle -> Paths.arrow_down_circle_dot_svg
- | Database -> Paths.database_dot_svg
- | Menu -> Paths.menu_dot_svg
- | Square -> Paths.square_dot_svg
- | Arrow_down_left -> Paths.arrow_down_left_dot_svg
- | Delete -> Paths.delete_dot_svg
- | Message_circle -> Paths.message_circle_dot_svg
- | Star -> Paths.star_dot_svg
- | Arrow_down_right -> Paths.arrow_down_right_dot_svg
- | Disc -> Paths.disc_dot_svg
- | Message_square -> Paths.message_square_dot_svg
- | Stop_circle -> Paths.stop_circle_dot_svg
- | Arrow_down -> Paths.arrow_down_dot_svg
- | Divide_circle -> Paths.divide_circle_dot_svg
- | Mic_off -> Paths.mic_off_dot_svg
- | Sunrise -> Paths.sunrise_dot_svg
- | Arrow_left_circle -> Paths.arrow_left_circle_dot_svg
- | Divide_square -> Paths.divide_square_dot_svg
- | Mic -> Paths.mic_dot_svg
- | Sunset -> Paths.sunset_dot_svg
- | Arrow_left -> Paths.arrow_left_dot_svg
- | Divide -> Paths.divide_dot_svg
- | Minimize_2 -> Paths.minimize_2_dot_svg
- | Sun -> Paths.sun_dot_svg
- | Arrow_right_circle -> Paths.arrow_right_circle_dot_svg
- | Dollar_sign -> Paths.dollar_sign_dot_svg
- | Minimize -> Paths.minimize_dot_svg
- | Tablet -> Paths.tablet_dot_svg
- | Arrow_right -> Paths.arrow_right_dot_svg
- | Download_cloud -> Paths.download_cloud_dot_svg
- | Minus_circle -> Paths.minus_circle_dot_svg
- | Tag -> Paths.tag_dot_svg
- | Arrow_up_circle -> Paths.arrow_up_circle_dot_svg
- | Download -> Paths.download_dot_svg
- | Minus_square -> Paths.minus_square_dot_svg
- | Target -> Paths.target_dot_svg
- | Arrow_up_left -> Paths.arrow_up_left_dot_svg
- | Dribbble -> Paths.dribbble_dot_svg
- | Minus -> Paths.minus_dot_svg
- | Terminal -> Paths.terminal_dot_svg
- | Arrow_up_right -> Paths.arrow_up_right_dot_svg
- | Droplet -> Paths.droplet_dot_svg
- | Monitor -> Paths.monitor_dot_svg
- | Thermometer -> Paths.thermometer_dot_svg
- | Arrow_up -> Paths.arrow_up_dot_svg
- | Edit_2 -> Paths.edit_2_dot_svg
- | Moon -> Paths.moon_dot_svg
- | Thumbs_down -> Paths.thumbs_down_dot_svg
- | At_sign -> Paths.at_sign_dot_svg
- | Edit_3 -> Paths.edit_3_dot_svg
- | More_horizontal -> Paths.more_horizontal_dot_svg
- | Thumbs_up -> Paths.thumbs_up_dot_svg
- | Award -> Paths.award_dot_svg
- | Edit -> Paths.edit_dot_svg
- | More_vertical -> Paths.more_vertical_dot_svg
- | Toggle_left -> Paths.toggle_left_dot_svg
- | Bar_chart_2 -> Paths.bar_chart_2_dot_svg
- | External_link -> Paths.external_link_dot_svg
- | Mouse_pointer -> Paths.mouse_pointer_dot_svg
- | Toggle_right -> Paths.toggle_right_dot_svg
- | Bar_chart -> Paths.bar_chart_dot_svg
- | Eye_off -> Paths.eye_off_dot_svg
- | Move -> Paths.move_dot_svg
- | Tool -> Paths.tool_dot_svg
- | Battery_charging -> Paths.battery_charging_dot_svg
- | Eye -> Paths.eye_dot_svg
- | Music -> Paths.music_dot_svg
- | Trash_2 -> Paths.trash_2_dot_svg
- | Battery -> Paths.battery_dot_svg
- | Facebook -> Paths.facebook_dot_svg
- | Navigation_2 -> Paths.navigation_2_dot_svg
- | Trash -> Paths.trash_dot_svg
- | Bell_off -> Paths.bell_off_dot_svg
- | Fast_forward -> Paths.fast_forward_dot_svg
- | Navigation -> Paths.navigation_dot_svg
- | Trello -> Paths.trello_dot_svg
- | Bell -> Paths.bell_dot_svg
- | Feather -> Paths.feather_dot_svg
- | Octagon -> Paths.octagon_dot_svg
- | Trending_down -> Paths.trending_down_dot_svg
- | Bluetooth -> Paths.bluetooth_dot_svg
- | Figma -> Paths.figma_dot_svg
- | Package -> Paths.package_dot_svg
- | Trending_up -> Paths.trending_up_dot_svg
- | Bold -> Paths.bold_dot_svg
- | File_minus -> Paths.file_minus_dot_svg
- | Paperclip -> Paths.paperclip_dot_svg
- | Triangle -> Paths.triangle_dot_svg
- | Bookmark -> Paths.bookmark_dot_svg
- | File_plus -> Paths.file_plus_dot_svg
- | Pause_circle -> Paths.pause_circle_dot_svg
- | Truck -> Paths.truck_dot_svg
- | Book_open -> Paths.book_open_dot_svg
- | File -> Paths.file_dot_svg
- | Pause -> Paths.pause_dot_svg
- | Tv -> Paths.tv_dot_svg
- | Book -> Paths.book_dot_svg
- | File_text -> Paths.file_text_dot_svg
- | Pen_tool -> Paths.pen_tool_dot_svg
- | Twitch -> Paths.twitch_dot_svg
- | Box -> Paths.box_dot_svg
- | Film -> Paths.film_dot_svg
- | Percent -> Paths.percent_dot_svg
- | Twitter -> Paths.twitter_dot_svg
- | Briefcase -> Paths.briefcase_dot_svg
- | Filter -> Paths.filter_dot_svg
- | Phone_call -> Paths.phone_call_dot_svg
- | Type -> Paths.type_dot_svg
- | Calendar -> Paths.calendar_dot_svg
- | Flag -> Paths.flag_dot_svg
- | Phone_forwarded -> Paths.phone_forwarded_dot_svg
- | Umbrella -> Paths.umbrella_dot_svg
- | Camera_off -> Paths.camera_off_dot_svg
- | Folder_minus -> Paths.folder_minus_dot_svg
- | Phone_incoming -> Paths.phone_incoming_dot_svg
- | Underline -> Paths.underline_dot_svg
- | Camera -> Paths.camera_dot_svg
- | Folder_plus -> Paths.folder_plus_dot_svg
- | Phone_missed -> Paths.phone_missed_dot_svg
- | Unlock -> Paths.unlock_dot_svg
- | Cast -> Paths.cast_dot_svg
- | Folder -> Paths.folder_dot_svg
- | Phone_off -> Paths.phone_off_dot_svg
- | Upload_cloud -> Paths.upload_cloud_dot_svg
- | Check_circle -> Paths.check_circle_dot_svg
- | Framer -> Paths.framer_dot_svg
- | Phone_outgoing -> Paths.phone_outgoing_dot_svg
- | Upload -> Paths.upload_dot_svg
- | Check_square -> Paths.check_square_dot_svg
- | Frown -> Paths.frown_dot_svg
- | Phone -> Paths.phone_dot_svg
- | User_check -> Paths.user_check_dot_svg
- | Check -> Paths.check_dot_svg
- | Gift -> Paths.gift_dot_svg
- | Pie_chart -> Paths.pie_chart_dot_svg
- | User_minus -> Paths.user_minus_dot_svg
- | Chevron_down -> Paths.chevron_down_dot_svg
- | Git_branch -> Paths.git_branch_dot_svg
- | Play_circle -> Paths.play_circle_dot_svg
- | User_plus -> Paths.user_plus_dot_svg
- | Chevron_left -> Paths.chevron_left_dot_svg
- | Git_commit -> Paths.git_commit_dot_svg
- | Play -> Paths.play_dot_svg
- | Users -> Paths.users_dot_svg
- | Chevron_right -> Paths.chevron_right_dot_svg
- | Github -> Paths.github_dot_svg
- | Plus_circle -> Paths.plus_circle_dot_svg
- | User -> Paths.user_dot_svg
- | Chevrons_down -> Paths.chevrons_down_dot_svg
- | Gitlab -> Paths.gitlab_dot_svg
- | Plus_square -> Paths.plus_square_dot_svg
- | User_x -> Paths.user_x_dot_svg
- | Chevrons_left -> Paths.chevrons_left_dot_svg
- | Git_merge -> Paths.git_merge_dot_svg
- | Plus -> Paths.plus_dot_svg
- | Video_off -> Paths.video_off_dot_svg
- | Chevrons_right -> Paths.chevrons_right_dot_svg
- | Git_pull_request -> Paths.git_pull_request_dot_svg
- | Pocket -> Paths.pocket_dot_svg
- | Video -> Paths.video_dot_svg
- | Chevrons_up -> Paths.chevrons_up_dot_svg
- | Globe -> Paths.globe_dot_svg
- | Power -> Paths.power_dot_svg
- | Voicemail -> Paths.voicemail_dot_svg
- | Chevron_up -> Paths.chevron_up_dot_svg
- | Grid -> Paths.grid_dot_svg
- | Printer -> Paths.printer_dot_svg
- | Volume_1 -> Paths.volume_1_dot_svg
- | Chrome -> Paths.chrome_dot_svg
- | Hard_drive -> Paths.hard_drive_dot_svg
- | Radio -> Paths.radio_dot_svg
- | Volume_2 -> Paths.volume_2_dot_svg
- | Circle -> Paths.circle_dot_svg
- | Hash -> Paths.hash_dot_svg
- | Refresh_ccw -> Paths.refresh_ccw_dot_svg
- | Volume -> Paths.volume_dot_svg
- | Clipboard -> Paths.clipboard_dot_svg
- | Headphones -> Paths.headphones_dot_svg
- | Refresh_cw -> Paths.refresh_cw_dot_svg
- | Volume_x -> Paths.volume_x_dot_svg
- | Clock -> Paths.clock_dot_svg
- | Heart -> Paths.heart_dot_svg
- | Repeat -> Paths.repeat_dot_svg
- | Watch -> Paths.watch_dot_svg
- | Cloud_drizzle -> Paths.cloud_drizzle_dot_svg
- | Help_circle -> Paths.help_circle_dot_svg
- | Rewind -> Paths.rewind_dot_svg
- | Wifi_off -> Paths.wifi_off_dot_svg
- | Cloud_lightning -> Paths.cloud_lightning_dot_svg
- | Hexagon -> Paths.hexagon_dot_svg
- | Rotate_ccw -> Paths.rotate_ccw_dot_svg
- | Wifi -> Paths.wifi_dot_svg
- | Cloud_off -> Paths.cloud_off_dot_svg
- | Home -> Paths.home_dot_svg
- | Rotate_cw -> Paths.rotate_cw_dot_svg
- | Wind -> Paths.wind_dot_svg
- | Cloud_rain -> Paths.cloud_rain_dot_svg
- | Image -> Paths.image_dot_svg
- | Rss -> Paths.rss_dot_svg
- | X_circle -> Paths.x_circle_dot_svg
- | Cloud_snow -> Paths.cloud_snow_dot_svg
- | Inbox -> Paths.inbox_dot_svg
- | Save -> Paths.save_dot_svg
- | X_octagon -> Paths.x_octagon_dot_svg
- | Cloud -> Paths.cloud_dot_svg
- | Info -> Paths.info_dot_svg
- | Scissors -> Paths.scissors_dot_svg
- | X_square -> Paths.x_square_dot_svg
- | Codepen -> Paths.codepen_dot_svg
- | Instagram -> Paths.instagram_dot_svg
- | Search -> Paths.search_dot_svg
- | X -> Paths.x_dot_svg
- | Codesandbox -> Paths.codesandbox_dot_svg
- | Italic -> Paths.italic_dot_svg
- | Send -> Paths.send_dot_svg
- | Youtube -> Paths.youtube_dot_svg
- | Code -> Paths.code_dot_svg
- | Key -> Paths.key_dot_svg
- | Server -> Paths.server_dot_svg
- | Zap_off -> Paths.zap_off_dot_svg
- | Coffee -> Paths.coffee_dot_svg
- | Layers -> Paths.layers_dot_svg
- | Settings -> Paths.settings_dot_svg
- | Zap -> Paths.zap_dot_svg
- | Columns -> Paths.columns_dot_svg
- | Layout -> Paths.layout_dot_svg
- | Share_2 -> Paths.share_2_dot_svg
- | Zoom_in -> Paths.zoom_in_dot_svg
- | Command -> Paths.command_dot_svg
- | Life_buoy -> Paths.life_buoy_dot_svg
- | Share -> Paths.share_dot_svg
- | Zoom_out -> Paths.zoom_out_dot_svg
- | Compass -> Paths.compass_dot_svg
- | Link_2 -> Paths.link_2_dot_svg
- | Shield_off -> Paths.shield_off_dot_svg
- | Copy -> Paths.copy_dot_svg
- | Linkedin -> Paths.linkedin_dot_svg
- | Shield -> Paths.shield_dot_svg
-;;
-
-let to_string t =
- sexp_of_t t
- |> Sexp.to_string
- |> String.lowercase
- |> String.tr ~target:'_' ~replacement:'-'
-;;
-
-let or_default_size size =
- Css_gen.Length.to_string_css
- (match size with
- | Some size -> (size :> Css_gen.Length.t)
- | None -> (`Px 24 :> Css_gen.Length.t))
-;;
-
-let or_default_stroke_width stroke_width =
- Css_gen.Length.to_string_css
- (match stroke_width with
- | Some stroke_width -> (stroke_width :> Css_gen.Length.t)
- | None -> (`Px 2 :> Css_gen.Length.t))
-;;
-
-let or_default_fill fill =
- match fill with
- | None -> "none"
- | Some color -> Css_gen.Color.to_string_css (color :> Css_gen.Color.t)
-;;
-
-let or_default_stroke stroke =
- Css_gen.Color.to_string_css
- (match stroke with
- | None -> (`Name "currentColor" :> Css_gen.Color.t)
- | Some stroke -> (stroke :> Css_gen.Color.t))
-;;
-
-let svg_string ?size ?stroke ?fill ?stroke_width (t : t) =
- let size = or_default_size size in
- let stroke_width = or_default_stroke_width stroke_width in
- let fill = or_default_fill fill in
- let stroke = or_default_stroke stroke in
- [%string
- {| |}]
-;;
-
-let svg ?size ?stroke ?fill ?stroke_width ?(extra_attrs = []) (t : t) =
- let size = or_default_size size in
- let stroke_width = or_default_stroke_width stroke_width in
- let fill = or_default_fill fill in
- let stroke = or_default_stroke stroke in
- let module A = Vdom.Attr in
- let specific_class = "feather-" ^ to_string t in
- match Bonsai_web.am_running_how with
- | `Browser | `Browser_benchmark | `Node | `Node_benchmark ->
- Vdom.Node.inner_html_svg
- ~tag:"svg"
- ~attrs:
- ([ A.string_property "width" size
- ; A.string_property "height" size
- ; A.string_property "viewBox" "0 0 24 24"
- ; A.string_property "fill" fill
- ; A.string_property "stroke" stroke
- ; A.string_property "stroke-width" stroke_width
- ; A.string_property "stroke-linecap" "round"
- ; A.string_property "stroke-linejoin" "round"
- ; A.classes [ "feather"; specific_class ]
- ]
- @ extra_attrs)
- ~this_html_is_sanitized_and_is_totally_safe_trust_me:(path t)
- ()
- | `Node_test ->
- Vdom.Node.create ~attrs:extra_attrs [%string "feather_icons.%{to_string t}"] []
-;;
diff --git a/bindings/feather_icon/src/feather_icon.mli b/bindings/feather_icon/src/feather_icon.mli
deleted file mode 100644
index 91dd49a4..00000000
--- a/bindings/feather_icon/src/feather_icon.mli
+++ /dev/null
@@ -1,323 +0,0 @@
-open! Core
-open! Import
-
-(** A simple way to construct feather icon svgs for use in jsoo.
-
- A few helpful resources:
- - The external feather icons website: https://feathericons.com/
- - Our bonsai demo equivalent: https://bonsai:8548/
- - The code for the bonsai demo: ../../bonsai/examples/feather_icons
-*)
-
-type t =
- | Activity
- | Corner_down_left
- | Link
- | Shopping_bag
- | Airplay
- | Corner_down_right
- | List
- | Shopping_cart
- | Alert_circle
- | Corner_left_down
- | Loader
- | Shuffle
- | Alert_octagon
- | Corner_left_up
- | Lock
- | Sidebar
- | Alert_triangle
- | Corner_right_down
- | Log_in
- | Skip_back
- | Align_center
- | Corner_right_up
- | Log_out
- | Skip_forward
- | Align_justify
- | Corner_up_left
- | Mail
- | Slack
- | Align_left
- | Corner_up_right
- | Map_pin
- | Slash
- | Align_right
- | Cpu
- | Map
- | Sliders
- | Anchor
- | Credit_card
- | Maximize_2
- | Smartphone
- | Aperture
- | Crop
- | Maximize
- | Smile
- | Archive
- | Crosshair
- | Meh
- | Speaker
- | Arrow_down_circle
- | Database
- | Menu
- | Square
- | Arrow_down_left
- | Delete
- | Message_circle
- | Star
- | Arrow_down_right
- | Disc
- | Message_square
- | Stop_circle
- | Arrow_down
- | Divide_circle
- | Mic_off
- | Sunrise
- | Arrow_left_circle
- | Divide_square
- | Mic
- | Sunset
- | Arrow_left
- | Divide
- | Minimize_2
- | Sun
- | Arrow_right_circle
- | Dollar_sign
- | Minimize
- | Tablet
- | Arrow_right
- | Download_cloud
- | Minus_circle
- | Tag
- | Arrow_up_circle
- | Download
- | Minus_square
- | Target
- | Arrow_up_left
- | Dribbble
- | Minus
- | Terminal
- | Arrow_up_right
- | Droplet
- | Monitor
- | Thermometer
- | Arrow_up
- | Edit_2
- | Moon
- | Thumbs_down
- | At_sign
- | Edit_3
- | More_horizontal
- | Thumbs_up
- | Award
- | Edit
- | More_vertical
- | Toggle_left
- | Bar_chart_2
- | External_link
- | Mouse_pointer
- | Toggle_right
- | Bar_chart
- | Eye_off
- | Move
- | Tool
- | Battery_charging
- | Eye
- | Music
- | Trash_2
- | Battery
- | Facebook
- | Navigation_2
- | Trash
- | Bell_off
- | Fast_forward
- | Navigation
- | Trello
- | Bell
- | Feather
- | Octagon
- | Trending_down
- | Bluetooth
- | Figma
- | Package
- | Trending_up
- | Bold
- | File_minus
- | Paperclip
- | Triangle
- | Bookmark
- | File_plus
- | Pause_circle
- | Truck
- | Book_open
- | File
- | Pause
- | Tv
- | Book
- | File_text
- | Pen_tool
- | Twitch
- | Box
- | Film
- | Percent
- | Twitter
- | Briefcase
- | Filter
- | Phone_call
- | Type
- | Calendar
- | Flag
- | Phone_forwarded
- | Umbrella
- | Camera_off
- | Folder_minus
- | Phone_incoming
- | Underline
- | Camera
- | Folder_plus
- | Phone_missed
- | Unlock
- | Cast
- | Folder
- | Phone_off
- | Upload_cloud
- | Check_circle
- | Framer
- | Phone_outgoing
- | Upload
- | Check_square
- | Frown
- | Phone
- | User_check
- | Check
- | Gift
- | Pie_chart
- | User_minus
- | Chevron_down
- | Git_branch
- | Play_circle
- | User_plus
- | Chevron_left
- | Git_commit
- | Play
- | Users
- | Chevron_right
- | Github
- | Plus_circle
- | User
- | Chevrons_down
- | Gitlab
- | Plus_square
- | User_x
- | Chevrons_left
- | Git_merge
- | Plus
- | Video_off
- | Chevrons_right
- | Git_pull_request
- | Pocket
- | Video
- | Chevrons_up
- | Globe
- | Power
- | Voicemail
- | Chevron_up
- | Grid
- | Printer
- | Volume_1
- | Chrome
- | Hard_drive
- | Radio
- | Volume_2
- | Circle
- | Hash
- | Refresh_ccw
- | Volume
- | Clipboard
- | Headphones
- | Refresh_cw
- | Volume_x
- | Clock
- | Heart
- | Repeat
- | Watch
- | Cloud_drizzle
- | Help_circle
- | Rewind
- | Wifi_off
- | Cloud_lightning
- | Hexagon
- | Rotate_ccw
- | Wifi
- | Cloud_off
- | Home
- | Rotate_cw
- | Wind
- | Cloud_rain
- | Image
- | Rss
- | X_circle
- | Cloud_snow
- | Inbox
- | Save
- | X_octagon
- | Cloud
- | Info
- | Scissors
- | X_square
- | Codepen
- | Instagram
- | Search
- | X
- | Codesandbox
- | Italic
- | Send
- | Youtube
- | Code
- | Key
- | Server
- | Zap_off
- | Coffee
- | Layers
- | Settings
- | Zap
- | Columns
- | Layout
- | Share_2
- | Zoom_in
- | Command
- | Life_buoy
- | Share
- | Zoom_out
- | Compass
- | Link_2
- | Shield_off
- | Copy
- | Linkedin
- | Shield
-[@@deriving compare, enumerate, equal, sexp, sexp_grammar]
-
-(** Useful for favicons and css backgrounds *)
-val svg_string
- : ?size:[< Css_gen.Length.t ]
- -> ?stroke:[< Css_gen.Color.t ]
- -> ?fill:[< Css_gen.Color.t ]
- -> ?stroke_width:[< Css_gen.Length.t ]
- -> t
- -> string
-
-(* $MDX part-begin=svg *)
-
-val svg
- : ?size:[< Css_gen.Length.t ]
- -> ?stroke:[< Css_gen.Color.t ]
- -> ?fill:[< Css_gen.Color.t ]
- -> ?stroke_width:[< Css_gen.Length.t ]
- -> ?extra_attrs:Vdom.Attr.t list
- -> t
- -> Vdom.Node.t
-
-(* $MDX part-end *)
-
-val to_string : t -> string
diff --git a/bindings/feather_icon/src/import.ml b/bindings/feather_icon/src/import.ml
deleted file mode 100644
index 083509d9..00000000
--- a/bindings/feather_icon/src/import.ml
+++ /dev/null
@@ -1,6 +0,0 @@
-open! Core
-
-include struct
- open Virtual_dom
- module Vdom = Vdom
-end
diff --git a/bindings/feather_icon/src/paths/activity.svg b/bindings/feather_icon/src/paths/activity.svg
deleted file mode 100644
index 1faf593d..00000000
--- a/bindings/feather_icon/src/paths/activity.svg
+++ /dev/null
@@ -1 +0,0 @@
-
-diff --git a/lib/codemirror.js b/lib/codemirror.js -index 04646a9..9a39cc7 100644 ---- a/lib/codemirror.js -+++ b/lib/codemirror.js -@@ -1420,6 +1425,7 @@ var CodeMirror = (function() { - readOnly: false, - onChange: null, - onCursorActivity: null, -+ onGutterClick: null, - autoMatchBrackets: false, - workTime: 200, - workDelay: 300, - |} - ;; - - let codemirror_editor = - Codemirror.of_initial_state - (State.Editor_state.create - (State.Editor_state_config.create - ~doc - ~extensions: - [ Basic_setup.basic_setup - ; Diff.diff - |> Stream_parser.Stream_language.define - |> Stream_parser.Stream_language.to_language - |> Language.extension - ] - ())) - ;; -end - -module Html_syntax_highlighting = struct - let doc = - {| -
-
- -
-