GithubHelp home page GithubHelp logo

time-sharing's Introduction

time-sharing

canvas分时图

Basic Usage

<div id="my-chart"></div>

In a browser:

<script src="time-sharing.min.js"></script>
var myChart = new timeSharing.InitChart({
    el: '#my-chart',
})

Using npm:

npm i time-sharing --save
import { InitChart } from 'time-sharing'

var myChart = new InitChart({
    el: '#my-chart'
})

效果图

demo.gif

demo

https://zakrivi.github.io/time-sharing/example/

applyConfig

myChart.applyConfig(options);

传递图表数据和参数, 并重新绘制图表

  • type: object
name type default description
*rawData array [] 分时数据
*tradingLength number 60*24 交易时段的最大数据量
*startTime number Date.now() - 60 * 60 * 24 * 1000 开始时间
*endTime number Date.now() 结束时间
digit number 2 保留小数位
colors object { up: 'red', down: 'green'} 涨跌颜色

Example use:

const rawData = [] // 例: [{time: 1604006220, price: '1.94914'},...]

myChart.applyConfig({
    rawData: rawData, 
    startTime: 1604008800000, 
    endTime: 1604091600000,
    closePrice: 1.95070,
    tradingLength: 60 * 24, 
    digit:5
});

subscribe

myChart.subscribe(type, callback)

订阅图表事件

  • type: string
  • value: mousemove | mousedown | mouseup | mouseleave | touchend | touchstart | touchmove

Example use:

myChart.subscribe('mousedown', function(){
    console.log('mousedown')
});

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.