Giter Club home page Giter Club logo

jutsu's Introduction

DEPRECATED

This project is no longer being maintained, as its dependencies have drifted it seems the clojurescript parts don't work the same way as they used to. Running the tests everything works fine, but when using it normally the plots don't seem to work.

This is the main issue, so if you happen to come across this and fix it, knock yourself out, I'll be more than happy to merge the PR. However, at this point I am no longer going to continue working on this. Best of luck fellow clojurians!

jutsu 術

alt text

jutsu translation: technique, way

Do you want fast data visualization that looks professional without a lot of hassle?

Tired of having to come up with your own ad hoc solution to visualize data remotely?

Then this tool is meant for you!

(I promise the graphs look a lot better than on this README. Image quality is being reduced for compression reasons I believe.)

The current api is functionally a light wrapper around plotly.js. This way you can follow their conventions for plotting while getting to use EDN instead of JSON.

The power of jutsu is that it works by sending data to a client just like a website. This has a couple of advantages.

The first is that jutsu works remotely by default, same api for cloud and localhost.

The second is that plotly graphs use javascript for animations and interactivity. This is increasingly becoming the norm for professional data visualization.

Tradeoff: Every call in this api is a side effect. This is denoted in the naming conventions for the api.

Getting Started

If you are new to Clojure then follow these instructions, otherwise skip to usage.

Make sure you have java installed

java -version if you don't, then install a java SDK such as OpenJDK.

Then install boot. Boot is a build tool for clojure which allows you to run tasks from the command line.

To make sure everything is working run boot repl in your command line.

In order to use jutsu you will need to create a build.boot file to add jutsu as a dependency. You can follow the instructions on boot's homepage to guide you.

Usage

Add jutsu to your dependencies

[hswick/jutsu "0.1.3"]

note If you are using nightlight you must place nightlight after jutsu in the list of dependencies. This is currently a known bug.

Then include jutsu into your current namespace.

If working in a repl:

(require '[jutsu.core :as j])

Or if working in a source file:

(:require [jutsu.core :as j])

Then start using jutsu!

;;This will start up a httpkit server and open the jutsu client in your default browser.
(j/start-jutsu!)
;;If you are running this in a script as opposed to the repl 
;;delay for a bit to let the websocket connect.
;;(Thread/sleep 3000)

Each call to jutsu follows a similar function signature [id data]

;;Adds a graph to the jutsu client
(j/graph!
  "foo"
  [{:x [1 2 3 4]
    :y [1 2 3 4]
    :mode "markers"
    :type "scatter"}])

alt text

;;To do realtime updates of a graph
(j/update-graph!  
  "foo"
  {:data {:y [[4]] :x [[5]]} 
   :traces [0]}))
   

alt text

;;You can even view matrix like datasets
(j/dataset! "dataset-foo" 
   [[1 2 3 4] 
    [1 2 3 4] 
    [1 2 3 4] 
    [1 2 3 4]])

alt text

(j/graph! "Line Chart"
  [{:x [1 2 3 5]
    :y [6 7 8 9]
    :type "scatter"}])

alt text

  (j/graph! "Bar Chart"
    [{:x ["foo" "bar" "foobar"]
      :y [20 30 40]
      :type "bar"}])

alt text

  (j/graph! "Pie Chart"
    [{:values [19 26 55]
      :labels ["Residential" "Non Residential" "Utility"]
      :type "pie"}])

alt text

  (j/graph! "3D Scatter"
    [{:x (take 100 (repeatedly #(rand)))
      :y (take 100 (repeatedly #(rand)))
      :z (take 100 (repeatedly #(rand)))
      :type "scatter3d"
      :mode "markers"}]
    {:width 600
     :height 600})

alt text

Please check out plotly's homepage for a full set of documented options.

Remote

The nice thing about jutsu being run like a web app is that it works on remote environments by default.

SSH into your remote machine like so:

ssh -L 9002:localhost:4002 USER@IP_ADDRESS

Then in your code (I personally like to use jutsu in the repl) initialize jutsu:

(j/start-jutsu! 4002 false)

4002 is the port number that jutsu will be serving locally on your remote machine The third argument we set to false because we don't want it to try to open up the graph in a web browser automatically.

In your browser on your computer type localhost:9000 as the url.

You should see the jutsu start page if it is all working.

Then when you are ready you can send graphs to this web page and see them immediately.

Dev

Run all three commands in separate tabs for optimal dev experience.

boot night to edit

boot dev to run

boot repl-client to connect to repl server started with boot dev

Pull requests are very welcome!

Testing

boot test-code to run tests (will reload on resource file changes)

This has the unfortunate side effect of constantly reopening a tab in your browser and can be annoying at times. Would love advice on how to test this better.

Web Socket

Sente receives event via chsk/receive and jutsu uses pattern matching to route the events appropriately.

Dynamically adding more event routes is a possibility, however the coupling between clj(s) makes testing very difficult. Server side router currently only sends events to the client-side-router. However, functionality for receiving events is planned.

More

What jutsu started as

plotly cheat sheet

plotly full reference

MIT LICENSE

Copyright 2017 Harley Swick

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.

jutsu's People

Contributors

hswick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jutsu's Issues

Modify Page Header?

This library is fantastic, but I'm wondering if it's necessary to have the Jutsu header on the page without any ability to change it. I'm working on a project where that would feel very out of place and was hoping for a way to change the page header. Would you be open to making the header an option that can be changed?

Slow when requiring

Currently takes a little less than 5 seconds to require jutsu.core namespace

start-jutsu! fails because of missing browser

(j/start-jutsu! 4000 false)
Starting http-kit...

java.lang.UnsupportedOperationException: The BROWSE action is not supported on the current platform!

I'm trying to launch Jutsu from an environment without a browser and it fails even with display = false

Can't make it work

Sorry, to bother you again, but I can't seem to make it working, now I'm able to open a session even from remote, but when I go to localhost:someport I only see a blank page. I tried plotting some of the examples in the README, but they never show up. I don't get any error, I only see the increasing n° of the plot I try to draw but nothing else

nightlight + jutsu dependency issue

Made note of this in README.

nightlight dependency must come after jutsu in dependency list. I believe the issue is somewhere on the js side of things with cljs. As both dependencies package a small website.

Would like to insulate jutsu from other libs. Maybe boot pods does the trick?

core.async dependency doesn't play well with clojure 1.9.0

(require '[jutsu.core :as j])
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: medley.core, being replaced by: #'medley.core/boolean?

         clojure.lang.ExceptionInfo: Call to clojure.core/refer-clojure did not conform to spec:
                                     In: [2] val: (quote :as) fails at: [:args :exclude :op :spec] predicate: #{:exclude}
                                     In: [2 1] val: :as fails at: [:args :exclude :op :quoted-spec :spec] predicate: #{:exclude}
                                     In: [2] val: (quote :as) fails at: [:args :only :op :spec] predicate: #{:only}
                                     In: [2 1] val: :as fails at: [:args :only :op :quoted-spec :spec] predicate: #{:only}
                                     In: [2] val: (quote :as) fails at: [:args :rename :op :spec] predicate: #{:rename}
                                     In: [2 1] val: :as fails at: [:args :rename :op :quoted-spec :spec] predicate: #{:rename}
                                     :clojure.spec/args  ((quote :exclude) (quote [reduce into merge map take partition partition-by]) (quote :as) (quote core))

clojure.lang.Compiler$CompilerException: clojure.lang.ExceptionInfo: Call to clojure.core/refer-clojure did not conform to spec:
In: [2] val: (quote :as) fails at: [:args :exclude :op :spec] predicate: #{:exclude}
In: [2 1] val: :as fails at: [:args :exclude :op :quoted-spec :spec] predicate: #{:exclude}
In: [2] val: (quote :as) fails at: [:args :only :op :spec] predicate: #{:only}
In: [2 1] val: :as fails at: [:args :only :op :quoted-spec :spec] predicate: #{:only}
In: [2] val: (quote :as) fails at: [:args :rename :op :spec] predicate: #{:rename}
In: [2 1] val: :as fails at: [:args :rename :op :quoted-spec :spec] predicate: #{:rename}
:clojure.spec/args ((quote :exclude) (quote [reduce into merge map take partition partition-by]) (quote :as) (quote core))
#:clojure.spec{:problems ({:path [:args :exclude :op :spec], :pred #{:exclude}, :val (quote :as), :via [], :in [2]} {:path [:args :exclude :op :quoted-spec :spec], :pred #{:exclude}, :val :as, :via [], :in [2 1]} {:path [:args :only :op :spec], :pred #{:only}, :val (quote :as), :via [], :in [2]} {:path [:args :only :op :quoted-spec :spec], :pred #{:only}, :val :as, :via [], :in [2 1]} {:path [:args :rename :op :spec], :pred #{:rename}, :val (quote :as), :via [], :in [2]} {:path [:args :rename :op :quoted-spec :spec], :pred #{:rename}, :val :as, :via [], :in [2 1]}), :args ((quote :exclude) (quote [reduce into merge map take partition partition-by]) (quote :as) (quote core))}, compiling:(clojure/core/async.clj:9:1)

Trouble with plotting over 100 items

Hi! I tried out this neat library, but had trouble plotting more than 100 items.

The below:

(j/graph! "Testing"
                [{:y (range 1000)
                  :x (range 1000)
                  :mode "markers"
                  :type "scatter"
                  :name "testing"}])

gives only 100 items in the plot (see ellipsis at end of :x and :y):

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.