Giter Site home page Giter Site logo

devexperts / dxcharts-lite Goto Github PK

View Code? Open in Web Editor NEW
39.0 7.0 8.0 2.89 MB

Flexible financial charts based on HTML5 canvas

Home Page: https://devexperts.com/dxcharts/

License: Mozilla Public License 2.0

JavaScript 1.94% Shell 0.03% TypeScript 98.03%
canvas charting charting-library charts finance html5-charts typescript javascript chart

dxcharts-lite's Introduction


devexperts-logo

DXCharts Lite - one of the most powerful financial charting tools

DXcharts Lite is a modern solution made for visualization financial data with full variety of charts.
It's been created and tempered as a part of big tradings apps with millions of users.
Now it's grown enough to be recognized as independent product capable to support any from your needs
as a simple widget for blog and as a part of big enterprise solution for trading.

License: MPL 2.0 ย  PRs: Welcome ย  Version


4 charts example


Overview

Get started with DXCharts Lite, install the library and configure it as you want.

Quick-start

Installation

Install library to your project:

npm install @devexperts/dxcharts-lite

Your package.json after installation:

"dependencies": {
	"@devexperts/dxcharts-lite": "1.0.0",
	...
}

Create chart

If you use webpack or any other bundler - import createChart method and pass element where the chart will be rendered as a first argument.

export const createChartInstance = () => {
	const container = document.getElementById('chart_container');
	const chartInstance = DXChart.createChart(container);
	return chartInstance;
};

createChart - method, that creates a new chart instance using ChartBootstrap class and returns it.

Method accepts 2 parameters:

  • element - The HTML element where the chart will be rendered
  • config (optional) - instance of ChartConfig

Also, please, set width: 100% and height: 100% for parent container by default chart is auto-resizing to parent you can change it by setting fixedSize in config

Now you should have empty chart on screen.

Set data

Let's pass in some data i.e. Candles. You can use bundled function to generate some mock data. Import generateCandlesData and call it to generate candles.

export const generateMockData = () => {
	const candles = generateCandlesData();
	chart.setData({ candles });
};

Now you should see chart just like image below:

Basic chart

HTML-markup

Here is full quick-start code example:

<html>
	<head>
		<script src="https://www.unpkg.com/@devexperts/[email protected]/dist/dxchart.min.js"></script>
		<script type="importmap">
			{
				"imports": {
					"@devexperts/dxcharts-lite/": "https://www.unpkg.com/@devexperts/[email protected]/"
				}
			}
		</script>
	</head>
	<body>
		<div id="chart_container"></div>
	</body>
	<script type="module">
		import generateCandlesData from '@devexperts/dxcharts-lite/dist/chart/utils/candles-generator.utils';

		// create chart instance, pass parent container as 1st argument
		const container = document.getElementById('chart_container');
		const chart = DXChart.createChart(container);
		// create and set candles data
		const candles = generateCandlesData();
		chart.setData({ candles });
	</script>
</html>

Configuration

You can configure chart with ChartConfig object. It is optional.

ChartConfig is used to set initial properties for chart instance. Below you can see full table of it, and other options, that ChartConfig consists of.

API

Every chart component has an API allowing change a lot of params on the fly. Change appearance at runtime. Subscribe on different events in chart (like HOVER on candle)

Here are the links of the main components:

Examples

We have created a lot of examples with different chart configuration. You can find them here.

Demo

To show you how it's beautiful, we have created Demo version, based on DXCharts Lite. Feel all power of our library!

dxcharts-lite's People

Contributors

alextsk avatar alps-of-idioms avatar deltazn avatar disyakidneyshot avatar dxpm avatar hokilpet avatar keelaro1 avatar kirillbobkov avatar kokovtsev avatar nikolaenkov 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dxcharts-lite's Issues

Handle double tap for mobile version

Duplicates

  • I have searched the proposed features

Latest version

  • I have tested the latest version

Suggestion โญ

We need to add dblTouchSubject in canvasInputListener to support double tap ections from mobile

Motivation ๐Ÿ”ฆ

No response

Examples ๐Ÿ“ƒ

No response

Add posibility to disable animation

Duplicates

  • I have searched the proposed features

Latest version

  • I have tested the latest version

Suggestion โญ

We should add possibility to disable animations via config.

Motivation ๐Ÿ”ฆ

Sometimes animations can affect performance

Examples ๐Ÿ“ƒ

config.scale.disableAnimations = true/false

Y axis labels are not updated after last candle change

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Y axis labels are not updated after last candle change

Link to minimal reproduction

https://jumpshare.com/s/eeAlUixInaK8hhns7FvU

Steps to Reproduce the Bug or Issue ๐Ÿ•น

Observe price label and volume labels color

Expected behavior ๐Ÿค”

Labels should be updated when last candle changes its value

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]

Additional context ๐Ÿ”ฆ

No response

Volumes object is always persists in dynamic objects

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Dynamic object component has a linked list with all of current objects on the chart and it always contains volumes component, no matter if they are turned off or on.

Link to minimal reproduction

Steps to Reproduce the Bug or Issue ๐Ÿ•น

  • Opens dxcharts with dev tools opened
  • Try to enable and disable volumes
  • Observe dynamic object list

Expected behavior ๐Ÿค”

Volumes are in dynamic object only if they are enabled

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]

Additional context ๐Ÿ”ฆ

No response

Last price color does not change immediately after `setChartType`

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Precondition:
Colors for chart type = line are different from standard ones, e.g. like this

DXChart.createChart(container, {
      colors: {
        lineTheme: {
          upColor: '#ccc',
          downColor: '#ccc',
          noneColor: '#ccc'
        }
      }
    });

When the chart.setChartType method is called, the last price indicator color does not change until some event triggers repaint (e.g. user interacts with the chart, or new data arrives)

Link to minimal reproduction

https://codepen.io/dmkokovtsev/pen/qBvMzXM

Steps to Reproduce the Bug or Issue ๐Ÿ•น

In the codepen attached, press the "Toggle" button to see the issue

Expected behavior ๐Ÿค”

The "last price" indicator should change its color immediately

Platform

Chrome/Win10

Additional context ๐Ÿ”ฆ

No response

Sometimes volume label is displayed incorrectly

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Chart is open
Select 'show crosshair' checkbox
'Volume' in separate mode

Actual result
Sometimes incorrectly displayed 'Volume' label

Link to minimal reproduction

https://devexperts.com/dxcharts/

Steps to Reproduce the Bug or Issue ๐Ÿ•น

Steps to reproduce
Add all labels
Observe 'Volume' label

Expected behavior ๐Ÿค”

Label should have the same width as YAxis or smaller

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]

Additional context ๐Ÿ”ฆ

No response

Fix the docs examples, some of them are not working

Overview:

Docs examples don't work at next folders:

  • docs/how-to/y-scale-labels
  • docs/how-to/set-and-update-candles
  • docs/how-to/crosstool

What to do:

Pls, fix them and regenerate codesandboxes after it using yarn generate:codesandbox

Wrong y-Axis label color for histogram chart

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Looks like for histogram chart type lastPriceColor = histogram.up/downCap, which leads to some unexpected results

Link to minimal reproduction

Steps to Reproduce the Bug or Issue ๐Ÿ•น

  • set custom color to colors.labels.lastPrice
  • switch chart type to histogram
  • observe y-axis label color

Expected behavior ๐Ÿค”

Histogram label uses histogram.${trend}Bright color from config

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]

Additional context ๐Ÿ”ฆ

No response

Pass previous candle for candle transformer

Duplicates

  • I have searched the proposed features

Latest version

  • I have tested the latest version

Suggestion โญ

For some chart types we need previouly calculated candle data to calculate current candle

Motivation ๐Ÿ”ฆ

No response

Examples ๐Ÿ“ƒ

No response

Improve X-labels generation time

Duplicates

  • I have searched the proposed features

Latest version

  • I have tested the latest version

Suggestion โญ

We need to improve X-labels generation time

Motivation ๐Ÿ”ฆ

Performance

Examples ๐Ÿ“ƒ

No response

Support reordering feature

In right click menu there are options to reorder chart objects. To support it we need to perform a refactoring.

Most likely, we need to draw data series and drawings on the same canvas - DynamicObjectsCanvas.

Moreover, we need to create a new model for dynamic objects.


// looks like discreminated union is a great fit for this interface

interface DynamicObject {

drawer: Drawer; // DrawingsDrawer or DataSeriesDrawer

model: unkown; // DrawingModel or DataSeriesModel

}

DynamicObjectsModel {

// Or linked list? We will have often reordering operations

// and no index access operations.

// Also, delete operations in the middle of the list are quite often (delete drawing, remove studies)

// ListNode<T>{ val: T, prev?: T, next?: T }

// LinkedList<T> { head?: T, tail?: T }

objects: LinkedList<DynamicObject>;

// in our domain models we will have only DrawingModel and DataSeriesModel without ListNode

// so create a hashMap for fast access to ListNode

objectsMap: Map<DrawingModel | DataSeriesModel, ListNode<T>>;

moveForward(listNode)

sendBackward(listNode)

bringToFront(listNode)

bringToBack(listNode)

}

 

DynamicObjectsDrawer {

draw(objects) {

for (const obj of objects)

{
 const { model, drawer } = obj;
 drawer.draw(model);
}

}

}

Add and setup size-limit package

Duplicates

  • I have searched the proposed features

Latest version

  • I have tested the latest version

Suggestion โญ

Would be useful to add and setup size-limit package to control package output size.

Motivation ๐Ÿ”ฆ

Package/bundle size is one of the main preference when choosing dependencies in software project and could be additional advantage, because it not only about application size, but also about application performance. Automated controlling of the package size can be helpful in development of this package.

Examples ๐Ÿ“ƒ

No response

Use dxcharts-lite package from upkg.com CDN in examples

Overview:

In our codesandboxes examples we're using our custom CDN to attach dxcharts-lite package to an example.
Since our dxcharts-lite has been published to npm registry, we can use a better CDN like unpkg.com to fetch our chart.

What to do:

  • replace our custom CDN link to unpkg.com CDN or any other open-sourced CDN
  • regenerate the sandboxes

Low label disappears too early on bottom border

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Low label has a different behaviour for displaying near the border than high label

Link to minimal reproduction

Steps to Reproduce the Bug or Issue ๐Ÿ•น

Add a low label on the chart and try to scroll y scale down so it would dissapear. Observe that label hides to early while there is still a space to display it.

Expected behavior ๐Ÿค”

Low label won't dissapear unless it's tottaly off the viewport

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]

Additional context ๐Ÿ”ฆ

No response

Drawings movement between layers is slow

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Create several drawings and try to move them using the dynamic object model. Sometimes it takes a few seconds for a drawing to assume a new position.

Link to minimal reproduction

Steps to Reproduce the Bug or Issue ๐Ÿ•น

  • Add two or more drawing to the chart so that they would partially cover each other
  • Try using dynamicObjectModel functions like moveForward, moveBackwards, etc
  • Please observe the time lag.

Expected behavior ๐Ÿค”

Drawings have to take new position almost immediately

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]

Additional context ๐Ÿ”ฆ

No response

I would like to participate in the development of an open source project for C #, and how to participate in this project

Duplicates

  • I have searched the proposed features

Latest version

  • I have tested the latest version

Suggestion โญ

I implement Blazor c # based on this Demo code. Can you teach me how to implement this function for a fee? I will open source these codes

Motivation ๐Ÿ”ฆ

I want to understand https://devexperts.com/dxcharts-demo/ Suggested implementation

Examples ๐Ÿ“ƒ

I want to know https://devexperts.com/dxcharts-demo/ Those APIs were called

Get rid of RxJS

Duplicates

  • I have searched the proposed features

Latest version

  • I have tested the latest version

Suggestion โญ

RxJS bundle is quite big, moreover, some projects might not use it, however, they'll have to include this dependency in their bundle anyway.
I suggest writing a lightweight implementation which will follow this proposal.
Also, we need to make sure that it's compatible with rxjs, since there are existing projects which uses our current implementaion with rxjs

Motivation ๐Ÿ”ฆ

Make dxcharts-lite really lite

Doji Candles are shown as dots if showCandlesBorder: false

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Doji candles are shown as dots
image

Link to minimal reproduction

Please see steps below

Steps to Reproduce the Bug or Issue ๐Ÿ•น

  1. Apply this config to chart: config.components.chart.showCandlesBorder = false
  2. Observe doji candles
image

Expected behavior ๐Ÿค”

Doji candles are shown as candles (or dashes)

Platform

  • OS: macOS
  • Browser: Chrome

Additional context ๐Ÿ”ฆ

No response

Source code published with releases has the wrong `package.json` version

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Your release process is not bumping the package.json before tar'ing up the source code put with each release on github. This means pulling 2.4.6 pulls 2.4.5 technically if you pull the github tgz.

Link to minimal reproduction

Download the tar for the latest release

Steps to Reproduce the Bug or Issue ๐Ÿ•น

Download the tar and untar it, Validate the package.json version in the resulting folder

Expected behavior ๐Ÿค”

package.json version should match the version on github

Platform

Applies across the board

Additional context ๐Ÿ”ฆ

No response

Crosstool doesn't appear after longtouch event

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

Crosstool doesn't appear until some movement happens after long touch

Link to minimal reproduction

https://jumpshare.com/s/h94gBAwhdPuMRhkuv5LI

Steps to Reproduce the Bug or Issue ๐Ÿ•น

  1. Enable crosstool in settings
  2. Switch to mobile mode
  3. Do a long tap, observe crosstool doesn't appear until some movement happens

Expected behavior ๐Ÿค”

Crosstool should appear after longtouch (if visible in settings)

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]

Additional context ๐Ÿ”ฆ

No response

Second-to-last candle is hovered by default

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Describe the bug ๐Ÿ˜ฏ

When the data is initially provided into the chart, I assume that the hover subject should emit the last candle in this dataset.

However, it actually emits the second to last one, or even the 4th-5th one. I guess the Y axis is somehow accounted for incorrectly in the X coordinate calculation.

In other words, the chart reports the initial hover as if the mouse pointer was at X = (xCenter of the last candle) - (Y axis width)

Link to minimal reproduction

https://codepen.io/dmkokovtsev/pen/rNoZJwG

Steps to Reproduce the Bug or Issue ๐Ÿ•น

  1. Wait for the data to appear
  2. Observe the timestamp in the #hover_info div

Expected behavior ๐Ÿค”

The timestamp of the last candle

Platform

Windows, Chrome

Additional context ๐Ÿ”ฆ

No response

Prohibit dragging YAxis if config.visible is false

Duplicates

  • I have searched the proposed features

Latest version

  • I have tested the latest version

Suggestion โญ

Prohibit dragging YAxis if config.visible is false

Motivation ๐Ÿ”ฆ

No response

Examples ๐Ÿ“ƒ

No response

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.