Skip to content

Instantly share code, notes, and snippets.

@GordonSmith
Last active August 8, 2018 09:00
Show Gist options
  • Save GordonSmith/6c79c4246d10875ec89faec88c4b55e9 to your computer and use it in GitHub Desktop.
Save GordonSmith/6c79c4246d10875ec89faec88c4b55e9 to your computer and use it in GitHub Desktop.

Revisions

  1. GordonSmith revised this gist Aug 8, 2018. 3 changed files with 50 additions and 22 deletions.
    30 changes: 25 additions & 5 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,28 @@
    Tutorial 3: Switch from Pie to Column.
    __Tutorial 3__: Switch from Pie to Column.

    So Pie Charts are so last year, lets switch it up to a Column Chart:
    So [Pie Charts](https://bl.ocks.org/GordonSmith/913403c91d45b11473baa82d0ba790a4) are so last year, lets switch it up to a Column Chart:

    __1__ - Import the required visualization:
    ```javascript
    import { Column } from "@hpcc-js/chart";
    ```
    require(["src/chart/Column"], function (Column) {
    var widget = new Column()
    ...

    __2__ - Instantiate and render the visualisation:
    ```javascript
    var widget = new Column() // Create new instance of Column
    .target("placeholder") // Nominate target on web page
    .columns(["Subject", "Result"]) // Set "Columns"
    .data([ // Set "Data"
    ["English", 45],
    ["Irish", 28],
    ["Math", 98],
    ["Geography", 48],
    ["Science", 82]
    ])
    .render() // Render
    ;
    ```

    Note 1: The only difference between this example and the previous [one](https://bl.ocks.org/GordonSmith/913403c91d45b11473baa82d0ba790a4) is the change from "Pie" to "Column" this demonstrates one of the key features of the @hpcc-js visualization framework - the ability to switch easily between visualisations for a single data "shape".
    Note 2: To discover all the available "published properties" for the `Column` Widget see: [Dermatology-Column](https://rawgit.com/hpcc-systems/Visualization/master/demos/dermatology/index.html?src/chart/Column.simple) and enable the "Properties" view.

    28 changes: 11 additions & 17 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,23 @@
    <!DOCTYPE html>
    <html>

    <head>
    <title>Hello World</title>
    <title>Column Chart</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="index.css">
    <script src="http://viz.hpccsystems.com/v1.14.4/dist-amd/hpcc-viz.js"></script>
    <link rel="stylesheet" href="./index.css">

    <!-- GetLibs: An in-browser module loader for quick demos -->
    <script src="https://unpkg.com/getlibs"></script>
    </head>

    <body>
    <div id="placeholder">
    <!-- Placeholder for Visualization -->
    </div>
    <script>
    require(["src/chart/Column"], function (Column) {
    var widget = new Column() // Create new instance of TextBox
    .target("placeholder") // Nominate target on web page
    .columns(["Subject", "Result"]) // Set "Columns"
    .data([ // Set "Data"
    ["English", 45],
    ["Irish", 28],
    ["Math", 98],
    ["Geography", 48],
    ["Science", 82]
    ])
    .render() // Render
    ;
    });
    // Load Example JavaScript (via GetLibs)---
    System.import('./index.js');
    </script>
    </body>

    </html>
    14 changes: 14 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    import { Column } from "@hpcc-js/chart";

    var widget = new Column() // Create new instance of Column
    .target("placeholder") // Nominate target on web page
    .columns(["Subject", "Result"]) // Set "Columns"
    .data([ // Set "Data"
    ["English", 45],
    ["Irish", 28],
    ["Math", 98],
    ["Geography", 48],
    ["Science", 82]
    ])
    .render() // Render
    ;
  2. GordonSmith revised this gist Sep 17, 2016. 1 changed file with 0 additions and 0 deletions.
    Binary file added preview.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  3. GordonSmith renamed this gist Sep 17, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. GordonSmith revised this gist Sep 17, 2016. No changes.
  5. GordonSmith revised this gist Sep 17, 2016. 6 changed files with 48 additions and 1 deletion.
    1 change: 1 addition & 0 deletions .block
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    license: Apache-2.0
    1 change: 0 additions & 1 deletion Tutorial 3: Column Chart
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    Column Chart
    10 changes: 10 additions & 0 deletions index.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    body {
    padding:0px;
    margin:0px;
    overflow:hidden;
    }

    #placeholder {
    width:100%;
    height:100vh;
    }
    29 changes: 29 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    <!DOCTYPE html>
    <html>
    <head>
    <title>Hello World</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="index.css">
    <script src="http://viz.hpccsystems.com/v1.14.4/dist-amd/hpcc-viz.js"></script>
    </head>
    <body>
    <div id="placeholder">
    </div>
    <script>
    require(["src/chart/Column"], function (Column) {
    var widget = new Column() // Create new instance of TextBox
    .target("placeholder") // Nominate target on web page
    .columns(["Subject", "Result"]) // Set "Columns"
    .data([ // Set "Data"
    ["English", 45],
    ["Irish", 28],
    ["Math", 98],
    ["Geography", 48],
    ["Science", 82]
    ])
    .render() // Render
    ;
    });
    </script>
    </body>
    </html>
    8 changes: 8 additions & 0 deletions reademe.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    Tutorial 3: Switch from Pie to Column.

    So Pie Charts are so last year, lets switch it up to a Column Chart:
    ```
    require(["src/chart/Column"], function (Column) {
    var widget = new Column()
    ...
    ```
    Binary file added thumbnail.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  6. GordonSmith created this gist Sep 17, 2016.
    1 change: 1 addition & 0 deletions Tutorial 3: Column Chart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Column Chart