Giter VIP home page Giter VIP logo

fundvis's Introduction

Fund Performance Visualisation (Ver. 2.0)

[Collaborators are welcome, if interested, please email: [email protected]]

alt tag

Design Characteristics:

  1. Allow quick selection of the funds, and add it into the plot (click the color rectangles, mouse over to get the name)

  2. Auto adjust of y-axis according to the selected funds

  3. Allow traversal of time line quickly, quick selection of time interval (select over the yellow slider bar at the bottom)

  4. Has a tracing dot to view the detailed price (next to the color rectangles) and date (top right corner). You may also click onto the dots/lines to know more details about the funds

  5. Two modes (to change the mode, click the checkbox at the top) for showing fund performance: 1. actual price--only one fund will be shown 2. percent mode, which allow you to add as many funds onto the chart as possible

  6. The reference point (base price) of the percentage mode can be set to any date within the data range. That means you can easily find out one month, one year, 5 year return. (you can get percentage change of the fund price of any interval length: just move the refernce pt)

HTML Page & D3 Code Part

Server Part for Fetching Data of the Funds

    Framework that we are using

    1. Codeigniter 2.1.4 - PHP Framework (/php/api/)
    2. RESTful API for Codeigniter (/php/api/application/libraries/CORE_Controller/php)
    3. We etablished a RESTful archieture for providing the wbe services to our end points (here is HTML pages, in future, it may be mobile devices etc). The end points send the request to the server via AJAX call.

    Files structure

    Please refer to the document in Codeigniter to have a detail understanding. Basically it can be separated into two parts, application and system

    Application

    It is the place where our main application will be put, all later codes commit should be into this file.

    config

    All the static fields like database location (in database.php) will be stored in this folder. You will need to modify the error_message.php in that folder later on.

    controllers

    The main place where all request is first processed, please take a look on user.php for example.

    helpers

    Our custom helper for doing our routine jobs will be put in here. It exists as a form of function but not class, you can think it is a Utility class that has static methods. Currently I do not see a need for adding any helper file in there, using the one provided by Codeigniter is good enough.

    libraries

    Our custom library for doing our routine jobs will be put in here. And it always exists as a form of class. Our two main libraries are REST_Controller.php (for handling RESTful request) and CORE_Controller.php (for handling session checking and validation as well as formulate the error and generate error message). Normally, you do not need to change the file in there, it will be covered by me.

    models

    The main place where all communications to database will happen in here. Please take user_model.php as the example.

    views

    The main place to return some views to user, since we don't need that (we only return JSON), you can skip this folder.

    System

    The core part of the framework, normally we will not modify any files in there. And it shares the same structure as the Application folder.

    Note on creating new file

    Common

    Please start with this line

    ``` // Please ignore the "?>" at the end. ```

    And end with this

    ```PHP /* End of file __filename__.php */ /* Location: ./application/__folder__/__filename__.php */ ```

    In controllers

    For all RESTful controller,
    please incl. this statement before defining the class

    ```PHP require_once (APPPATH. 'libraries/REST_Controller.php'); ```

    And define the class like this
    For example, if you have a class called `trip`

    ```PHP class Trip extends REST_Controller { public function __construct() { parent::__construct(); $this->load->library('CORE_Controller'); $this->core_controller->set_response_helper($this); }
    // other functions go below...
    

    }

    <p>
    And name the file as trip.php
    <br>
    Example can be found in user.php
    </p>
    
    <h4>In models</h4>
    <p>
    Define your class like this
    </p>
    ```PHP
    class Trip_model extends CI_Model {
    	// define the KEY and table name in here
    
    	// methods go below...
    }
    

    And name the file as trip_model.php

    That's all you need to know when creating a new class.

    Special note on classes in controllers folder

    Currently I have not yet finished writing all checking strategy on the CORE_Controller.php, but you still need to use that class, just initialize the class like the example above will be good enough.

    - Please use core_controller as your responsing method
    e.g. If you need to response failure message back to the app, please do this

    ```PHP /** * @param $error_code INT This will be referenced back to the error_message.php in the config folder using the error code * @param $override_custom_message STRING Once it is not null, it will replace the default message referenced in the error_message.php, case like validation error would be a good place to use $override_custom_message */ $this->core_controller->fail_response($error_code, $override_custom_message); ```

    Example: controllers/user.php -> register_post() method
    If you need to response success message back to the app, please do this

    ```PHP $this->core_controller->successfully_processed(); ```

    After calling the above two methods, the server will STOP processing remaining codes.
    More often enough, you need to send data back to client not only success message, you can do this

    ```PHP /** * @param $key STRING The key used in the return JSON data pack, `Exception` will be thrown if the key is already used before, reserved keys are `session_token` and `expire_time` * @param $value ANY The value that will matched with the KEY, $value should not be null */ $this->core_controller->add_return_data($key, $value);

    // Note that this method can be chained, i.e. $this->core_controller->add_return_data($key1, $value1)->add_return_data($key2, $value2)->add_return_data($key3, $value3);

    // Please remember to call successfully_processed() in the end of the chain if no more processing is needed.

    <p>
    On the call of fail_response(), all added return data <b>will be dropped and will not be included</b> in the return message.
    </p>
    </ol>
    
    
    <h2>Development History & Other Versions</h2>
    <ol>
    <p>
    <li><a href="http://mpf.vis.ywng.cloudbees.net/"> MPF Vis</a> (An older & simpler version Ver. 1.0) <a href="https://github.com/ywng/mpf_vis">[Source]</a></li>
    </p>
    </ol>
    

fundvis's People

Contributors

ywng avatar

Watchers

James Cloos 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.