Giter VIP home page Giter VIP logo

anychart-react's Introduction

AnyChart - Robust JavaScript/HTML5 Chart library for any project AnyChart Travis Build AnyChart NPM Version AnyChart Releases AnyChart Download

AnyChart Data Visualization Framework

AnyChart is a flexible JavaScript (HTML5, SVG, VML) charting framework that fits any solution in need of data visualization.

Table of Contents

Download and install

There are several ways to download/install AnyChart.

Direct download

All binaries are located in dist folder.

CDN

If you don't want to download and host AnyChart yourself, you can include it from the AnyChart CDN (Content Delivery Network): https://www.anychart.com/download/cdn

<head>
<script src="https://cdn.anychart.com/releases/v8/js/anychart-base.min.js"></script>
</head>

Package managers

You can install AnyChart using npm, bower or yarn:

  • npm install anychart
  • bower install anychart
  • yarn add anychart

Getting started

The fastest way to start with AnyChart is to include framework into a webpage and write some code. Look at this simple HTML snippet below:

<!doctype html>
<body>
<div id="container" style="width: 500px; height: 400px;"></div>
<script src="https://cdn.anychart.com/releases/v8/js/anychart-base.min.js" type="text/javascript"></script>
<script>
    anychart.onDocumentReady(function() {
        // create a pie chart
        var chart = anychart.pie([
            ["Chocolate", 5],
            ["Rhubarb compote", 2],
            ["Crêpe Suzette", 2],
            ["American blueberry", 2],
            ["Buttermilk", 1]
        ]);
        chart.title("Top 5 pancake fillings");
        // set the container where chart will be drawn
        chart.container("container");
        //  draw the chart on the page
        chart.draw();
    });
</script>
</body>
</html>

Step by step quick start guides

Plugins

AnyChart provides wide variety of plugins for different kind of technologies, which includes:

Using AnyChart with TypeScript

You can use AnyChart in your TypeScript projects - we have definition file for our library which you can find in distribution folder. Please, take a look at webpack and typescript integration example for more details.

Using AnyChart with ECMAScript 6

You can use AnyChart in your ECMAScript 6 projects over two ways:

Plain ECMAScript 6

To add AnyChart on a page use <script> section with type="module" attribute.

<script type="module">
    import '_localpath_to_anychart/anychart-bundle.min.js'
    
    // regular AnyChart code here
</script>

For more details, take a look at AnyChart ES6 example.

Bundling tools and Module Loaders

You can use AnyChart with any bundling tool or module loader such as WebPack, Browserify, Require.js and others. For more details, take a look at AnyChart Webpack example.

Technical Integrations

AnyChart can run on any platform and with any database. These samples were created to demonstrate how AnyChart can be easily integrated into your environment. All examples are distributed under an Apache 2.0 License and can be customized to your application. If you are interested in a particular integration not listed here, please contact us.

ASP.NET, C# and MySQL ASP.NET, VB.NET and MySQL ASP.NET, C#, SignalR and MySQL
Go, Revel and MySQL Go and MySQL Java Servlets, Maven, JDBC, JSP and MySQL
NodeJS and MongoDB using socket.io Java Spring, Maven, Hibernate and MySQL Julia and MySQL
NodeJS Express, Jade and MongoDB PHP, Symfony and MySQL PHP, Laravel and MySQL
PHP, Slim and MySQL Perl, Catalyst Web Framework and MySQL Python, Flask and MySQL
Python, Django and MySQL R, Shiny and MySQL Ruby, Sinatra and MySQL
Ruby on Rails and MySQL Scala, Akka and MySQL Scala, Play and MySQL

Contribution guide

To contribute to AnyChart project please:

  • Fork AnyChart repository.
  • Create a branch from the develop branch.
  • Make any changes you want to contribute.
  • Create a pull request against the develop branch.

GitHub documentation: Forking repositories.
GitHub documentation: Collaborating using pull requests.

Please, note:

  1. AnyChart bears no responsibility for the code written by third-party developers until pull request is accepted.
  2. After pull request is accepted the author of pull request sign over all rights to the code to AnyChart.

Build and debug

Dependencies

AnyChart uses several third-party libraries and tools to work with JavaScript and CSS.

Building options

build.py python script is used to work with AnyChart project. You need to install python to use it.

To see all available options of the build script use -h or --help command:

./build.py -h.

To see command options use:

./build.py <command_name> -h

To install all dependencies use the deps command:

./build.py deps.

After running this command you can compile the project using the compile command:

./build.py compile

This compiles production version of anychart-bundle and all modules and puts them into the out folder. You can read more about modules in our Modules article.

To create a dev build for the debug purposes use -d or --develop option:

./build.py compile -d

The -df option generates property renaming report, variable renaming report, and source map location mapping files:

./build.py compile -df

Source map maps minified code to source code. Read more about using source maps in Chrome or source maps in Firefox.

Module system

AnyChart since v8.0.0 is structured as a modules, so you can use only what you need. Please look at our article Modules to start working with modules.

Package directory

├── css
│   ├── anychart.less
│   ...
├── dist
│   ├── json-schema.json
│   ├── xml-schema.xsd
│       ...
├── src
│   ├── charts
│   ├── core
│   ├── modules
│   ├── themes
│       ...
│   README.md
│   LICENSE
│   ...

css

The css folder contains .less CSS files that are compiled into one .css file.

src

The src folder contains AnyChart source code files organized according to the project structure. For example:

  • charts subfolder contains chart classes
  • core subfolder contains core classes
  • modules subfolder contains modules
  • themes contains themes

dist

The dist folder contains binaries and JSON/XML Schemas.

Contacts

Links

License

© AnyChart.com - JavaScript charts. All rights reserved.

anychart-react's People

Contributors

antonbaranchuk avatar chidori avatar irkutsk-anychart avatar loki20beta avatar rkkmkkfx avatar romanlubushkin 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anychart-react's Issues

Using charts in a <table> tag

I'm trying to align charts beside each other inside a table. I notice that there's a lot of extra styling the library associates with the tag that is preventing me from doing this. Any suggestions on how to get around this?

I'd like to be able to do something like this, with the two AnyChart's to be positioned beside each other:

                <table>
                    <tr>
                        <td>
                            <AnyChart  />
                        </td>
                        <td>
                            <AnyChart />
                        </td>
                    </tr>
                </table>

Thanks

Memory heap issue

Hi,

I tried to plot a simple Anychart with create-react-app project. But, it is giving me "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory" error.
image

The code of my component is :

import React from "react";
import AnyChart from 'anychart-react'

class NewChart extends React.Component {

    render() {
        return (
            <div className="chart-component">
                <div className="chart-section">
                    <AnyChart
                        type="pie"
                        data={[1, 2, 3, 4]}
                        title="Simple pie chart"
                    />
                </div>
            </div>
        );
    }
}

export default NewChart;

setting minimum and maximum for yScale

Hi,

I'm trying to set to the minimum and maximum bounds for the yScale and am having trouble. Here's my component.

<AnyChart key={i} id={'anychart-bar-'+i} type='bar' height={300} data={data} yScale={{ minimum: -2, maximum: 2 }} yAxis={[0, { labels: { format: x => x.value + 1 } } ]} xAxis={[0, { orientation: 'right', overlapMode: 'allowOverlap' } ]} tooltip={{ format: x => x.value + 1 }} />

However, the value ranges on the y axis are still being set automatically by the data.

AnyChart Graph inside tables/divs, zoom behaves like mouse coords is wrong

I'm using v8 Graph, and putting it into a container like so:

<div class="container-fluid">
    <div class="row">
        <div class="col">
            <h3>Graphs in Boxes!</h3>
        </div>
    </div>
    <div class="row">
        <div class="col mybox">
            <h4>box 1</h4>
        </div>
        <div class="col mybox">
            <div id="container"></div>
        </div>
    </div>
    <div class="row">
        <div class="col mybox">
            <h4>box 3</h4>
        </div>
        <div class="col mybox">
            <h4>box 4</h4>
        </div>
    </div>
</div>

Render is fine, drag/pan and click events fire correctly (even contextmenu), but zooming in and out zooms AND shifts, as if I'm at a mouse coordinate outside of the bounds of the given DIV. Occurs with or without an explicit Stage defined.

Additionally (and, it seems to explain this), mouse event report a (clientX,ClientY) that is relative to the (0,0) of the window, not the containing DIV.

Is this a bug, or is there some way to bind the scope of the graph's coordinate system to be relative to its container? If we zoom like moused over a node, we all expect to see that node stay under the mouse.

Cannot render multi-series chart

Reproduce:

  • Clone this repo.
  • Run yarn
  • Run yarn build:dev
  • Run yarn start
  • Open your browser to http://localhost:8080/

Issue:
The multi-series chart does not show up. As mentioned here, the chart needs to be re-rendered to render the multi-column data. However, this does not seem feasible for the example repo, if the chart is part of a nested child component that cannot be directly re-rendered using the react-dom. (Using react-dom to render components more than once in the react spa is considered an anti-pattern).

Question:
How can we render a mutli-series chart when using a nested react component?

using typescript

how can i use anychart with react and typescript? i try to install types package but it dosent exist.
image

Chart Resize on Window Resize

The charts don't resize when the browser window resizes. Would this be an AnyChart-React issue or an AnyChart issue?

ReferenceError: anychart is not defined

in this file you have code like this:

https://github.com/AnyChart/AnyChart-React/blob/master/examples/src/simple_dashboard.js#L5

import React from 'react'
import ReactDOM from 'react-dom'
import AnyChart from '../../dist/anychart-react.min.js'

let stage = anychart.graphics.create();
let chart1 = anychart.line([1, 2, 3]);
chart1.bounds(0, 0, '100%', '50%');
let chart2 = anychart.column();
chart2.column([3, 2, 1]);
chart2.line([3, 5, 6]);
chart2.bounds(0, '50%', '100%', '50%');

ReactDOM.render(
  <AnyChart
    instance={stage}
    width={800}
    height={600}
    charts={[chart1, chart2]}
  />, document.getElementById('root'));

but anychart is not defined. when testing this with Jest, the runner will throw an error:
ReferenceError: anychart is not defined

how are you supposed to write tests for this?

rangeSelector and rangePicker is not working

Below code

`import React from 'react';
import AnyChart from 'anychart-react';
import anychart from 'anychart';

export default class Chart extends React.Component {

constructor() {
super();
this.state = { chart: 'stock' };
}

render() {
const dataTable = anychart.data.table();
dataTable.addData([
['2015-12-24', 511.53, 514.98, 505.79, 506.40],
['2015-12-25', 512.53, 514.88, 505.69, 507.34],
['2015-12-26', 511.83, 514.98, 505.59, 506.23],
['2015-12-27', 511.22, 515.30, 505.49, 506.47],
['2015-12-28', 510.35, 515.72, 505.23, 505.80],
['2015-12-29', 510.53, 515.86, 505.38, 508.25],
['2015-12-30', 511.43, 515.98, 505.66, 507.45],
['2015-12-31', 511.50, 515.33, 505.99, 507.98],
['2016-01-01', 511.32, 514.29, 505.99, 506.37],
['2016-01-02', 511.70, 514.87, 506.18, 506.75],
['2016-01-03', 512.30, 514.78, 505.87, 508.67],
['2016-01-04', 512.50, 514.77, 505.83, 508.35],
['2016-01-05', 511.53, 516.18, 505.91, 509.42],
['2016-01-06', 511.13, 516.01, 506.00, 509.26],
['2016-01-07', 510.93, 516.07, 506.00, 510.99],
['2016-01-08', 510.88, 515.93, 505.22, 509.95],
['2016-01-09', 509.12, 515.97, 505.15, 510.12],
['2016-01-10', 508.53, 516.13, 505.66, 510.42],
['2016-01-11', 508.90, 516.24, 505.73, 510.40],
]);
const mapping = dataTable.mapAs();
mapping.addField('open', 1, 'first');
mapping.addField('high', 2, 'max');
mapping.addField('low', 3, 'min');
mapping.addField('close', 4, 'last');
mapping.addField('value', 4, 'last');
const chart = anychart.stock();

chart.plot(0).ohlc(mapping).name('ACME Corp.');
const rangeSelector = anychart.ui.rangeSelector();
const rangePicker = anychart.ui.rangePicker();
chart.title('AnyStock Basic Sample');
chart.container('container');
chart.draw();
rangePicker.render(chart);
rangeSelector.render(chart);

const json = {
  type: 'stock',
  title: 'Stock Chart - simple',
  width: 800,
  height: 600,
  instance: chart,
};

return (
  <div className="App">
    <AnyChart {...json} />
  </div>
);

}
}
`

image

How i can do multiline line chart with react version ?

const lineData = [
{ name : "mon" , x:20, y:20},
{ name : "tue" , x:10, y:20},
{ name : "wed" , x:10, y:20},
{ name : "thu" , x:10, y:20},
{ name : "fri" , x:10, y:20},
{ name : "sat" , x:10, y:20},
{ name : "sun" , x:10, y:20},
]
<AnyChart height={400} id="pvtId" data={lineData} type="line" title="P v T" />

TypeError: Cannot read property 'table' of undefined

import React from 'react'
import ReactDOM from 'react-dom'
import anychart from 'anychart'
import AnyChart from 'anychart-react'

export default class SimpleChart extends React.Component {
	constructor(){
		super();
	}

	render() {
		const table = anychart.data.table();
		table.addData([
			['2015-12-24', 511.53, 514.98, 505.79, 506.40],
			['2015-12-25', 512.53, 514.88, 505.69, 507.34],
			['2015-12-26', 511.83, 514.98, 505.59, 506.23],
			['2015-12-27', 511.22, 515.30, 505.49, 506.47],
			['2015-12-28', 510.35, 515.72, 505.23, 505.80],
			['2015-12-29', 510.53, 515.86, 505.38, 508.25],
			['2015-12-30', 511.43, 515.98, 505.66, 507.45],
			['2015-12-31', 511.50, 515.33, 505.99, 507.98],
			['2016-01-01', 511.32, 514.29, 505.99, 506.37],
			['2016-01-02', 511.70, 514.87, 506.18, 506.75],
			['2016-01-03', 512.30, 514.78, 505.87, 508.67],
			['2016-01-04', 512.50, 514.77, 505.83, 508.35],
			['2016-01-05', 511.53, 516.18, 505.91, 509.42],
			['2016-01-06', 511.13, 516.01, 506.00, 509.26],
			['2016-01-07', 510.93, 516.07, 506.00, 510.99],
			['2016-01-08', 510.88, 515.93, 505.22, 509.95],
			['2016-01-09', 509.12, 515.97, 505.15, 510.12],
			['2016-01-10', 508.53, 516.13, 505.66, 510.42],
			['2016-01-11', 508.90, 516.24, 505.73, 510.40]	
		]);
		
		const mapping = table.mapAs();
		mapping.addField('open', 1, 'first');
		mapping.addField('high', 2, 'max');
		mapping.addField('low', 3, 'min');
		mapping.addField('close', 4, 'last');
		mapping.addField('value', 4, 'last');
   
		const chart = anychart.stock();
		chart.plot(0).ohlc(mapping).name('ACME Corp.');
		chart.title('AnyStock Basic Sample');
		chart.container('container');
		chart.draw();

    let json = {
        type: 'stock', // pie column bar
        title: 'Stock Chart',
        width: 800,
        height: 600,

        // PIE
        instance: chart,

        // fill: '#0066cc',
        // hoverFill: '#0066cc',
        // hatchFill: 'backwarddiagonal',
        // stroke: '#808080',
        // hoverStroke: '#0066cc',

        // COLUMN / BAR


    }

    return (
      <div className="App">
        <AnyChart
          {...json}
        />
      </div>
    );
  }
}

"anychart-react": "^1.4.1",
Error after npm start.
TypeError: Cannot read property 'table' of undefined
at new SimpleChart (/home/gtcoder/Sites/stock-predition/client/modules/Chart/pages/Simple/Simple.js:9:17)
at processChild (/home/gtcoder/Sites/stock-predition/node_modules/react-dom/cjs/react-dom-server.node.development.js:2095:14)
at resolve (/home/gtcoder/Sites/stock-predition/node_modules/react-dom/cjs/react-dom-server.node.development.js:2061:5)
at ReactDOMServerRenderer.render (/home/gtcoder/Sites/stock-predition/node_modules/react-dom/cjs/react-dom-server.node.development.js:2380:22)
at ReactDOMServerRenderer.read (/home/gtcoder/Sites/stock-predition/node_modules/react-dom/cjs/react-dom-server.node.development.js:2354:19)
at renderToString (/home/gtcoder/Sites/stock-predition/node_modules/react-dom/cjs/react-dom-server.node.development.js:2726:25)
at /home/gtcoder/Sites/stock-predition/server/server.js:140:29

Strange component behavior

Hi. I conduct a comparative analysis of visualization tools and one of the tools on my list is AnyChart. Since I use React adapters whenever possible, I also took your implementation. But I ran into one very strange problem. It consists in the fact that if it is necessary to draw a dataset from several series, I have to draw an adapter component with the initial settings without a dataset and when redrawing (re-rendering) already set it. For example:

interface Props {}
interface State {
  isMounted: boolean
}

const dataset = [
  ['2018', 1, 2, 3],
  ['2017', 10, 20, 30],
  ['2016', 100, 200, 300],
]

class LineChart extends PureComponent<Props, State> {
  public static displayName = 'LineChart'
  public state: State = {
    isMounted: false
  }

  componentDidMount() {
    this.setState({ isMounted: true })
  }

  public render() {
    const { width, height } = this.props

    if (this.state.isMounted) {
      const chartDataSet = anychart.data.set(dataset)

      return <AnyChart data={chartDataSet} />
    }

    return <AnyChart width={width} height={height} type="line" legend />
  }
}

I analyzed the adapter code a bit and paid attention to this part:

  // ...
  createInstance(props) {
    if (props.instance) {
      // ...
    } else if (props.type) {
      this.removeInstance();
      this.disposeInstance = true;
      this.instance = anychart[props.type](props.data);
      this.isStage = false;
      delete props.type;
      delete props.data;
    }
    // ...
  }
  // ...

I understand that, for example, the method anychart.line and the method chart.data take different input parameters. Does it make sense to separate these two properties and rename at least one of them at least in the adapter, so that there is no need to re-render the chart?

How do I prevent rescrolling

How do I prevent a scrolling when my data changes?

chart.data(treeData);

<AnyChart
   instance={stage}
  height={600}
  charts={[chart]} />

Async chart rendering

Hello,

We would really need to be able to use async rendering in our application: https://docs.anychart.com/Common_Settings/ASYNC_Rendering
It's just a boolean passed to the draw() function, which could be added in the props. Is it something that can be added?

Also is this repo still alive? I can see the Anychart version has been bumped to the latest one, but the React version used is ancient now. Are there any plans of upgrading it?

Thanks!

How to create multiple containers

Reproduce:

  • Clone this repo / branch.
  • Run yarn
  • Run yarn build:dev
  • Run yarn start
  • Open your browser to http://localhost:8080/

Issue:
I want to have two charts from anychart be rendered with a non-anychart element be rendered inbetween them. e.g.:

  <section>
    <Chart />
    <h1>I am a title between two charts!</h1>
    <Chart />
  </section>

However, the charts are getting placed in the same container and the header shows up after the two charts. How can I render multiple charts with anychart such that they are placed in their own, separate container? Thanks.

Upgrade to 7.14 may be a breaking change.

I ran a yarn (package.json) update and anycharts is now producing an error:

Uncaught TypeError: __webpack_require__(...) is not a function

I believe the upgrade of the anycharts peer dependency to 7.14 today is what's causing it.

how to create multiple containers

How to render multiple anychart in the same component

if i add like this then both the values are merged and shown in the single chart

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.