Git Product home page Git Product logo

dimple.scalajs.example's Introduction

Dimple.Scalajs.Example

A Sample Application with Dimple.Scalajs. This application constructs both a Bar Chart and a Line Chart. To run this application, run sbt fastOptJS on your terminal. This will create new .js files for you in the target/scala-2.11 directory. Of utmost importance are the scalatags-launcher.js, scalatags.jsdeps.js, and scalatags-fastopt.js files. These files should be added to the html file:

<script type="text/javascript" src="./target/scala-2.11/scalatags-jsdeps.js"></script>
<script type="text/javascript" src="./target/scala-2.11/scalatags-fastopt.js"></script>
<script type="text/javascript" src="./target/scala-2.11/scalatags-launcher.js"></script>

Sample lines of code to draw a bar chart is as follows:

    //Create a new SVG Object to hang the drawing. Equivalent to the dimple.newsvg function
    val svg = Dimple.newSvg("#barContainer", 590, 400) 
    //A Sample Data
    val literalData = js.Array(
      js.Dynamic.literal(Company = "Google", Awesomeness = "2000"),
      js.Dynamic.literal(Company = "Twitter", Awesomeness = "4000"),
      js.Dynamic.literal(Company = "Facebook", Awesomeness = "2500"),
      js.Dynamic.literal(Company = "Microsoft", Awesomeness = "1100"),
      js.Dynamic.literal(Company = "Intel", Awesomeness = "3500")
    )
    //Create a new Chart Object. Equivalent to the dimple.chart object
    val chart = new Chart(svg, literalData)
    chart.addCategoryAxis("x", "Company")
    chart.addMeasureAxis("y", "Awesomeness")
    //The plotfunction used is the plot.bar option.
    chart.addSeries(null, PlotBar)
    //Draw and See.
    chart.draw()

Alt text

Play with this!

Ahoy!

dimple.scalajs.example's People

Contributors

fasholaide avatar

Watchers

 avatar  avatar

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.