Giter Site home page Giter Site logo

fusioncharts / vue-fusioncharts Goto Github PK

View Code? Open in Web Editor NEW
88.0 16.0 32.0 16.93 MB

Vue Component for FusionCharts JavaScript Charting Library

Home Page: https://fusioncharts.github.io/vue-fusioncharts/

License: MIT License

JavaScript 99.65% HTML 0.35%
vue vue-fusioncharts-component vue-fusioncharts fusioncharts javascript-charts interactive-charts charts visualization data-visualization dataviz

vue-fusioncharts's Introduction

vue-fusioncharts

A simple and lightweight VueJS component for FusionCharts JavaScript Charting Library. The Vue-FusionCharts wrapper lets you easily include FusionCharts in your VueJS projects.


Table of Contents

Getting Started

Requirements

  • Node.js, NPM/Yarn installed globally in your OS.
  • FusionCharts and Vue installed in your project, as detailed below:

Installation

Direct Download All binaries are located on our github repository.

Install from NPM

npm install vue-fusioncharts --save

Install from Yarn

yarn add vue-fusioncharts

Include in your script

Download vue-fusioncharts.js and include it in the HTML <script> tag.

<script src="vue-fusioncharts.js" type="text/javascript"></script>

Usage

There are two ways of adding vue-fusioncharts component in your project

Registering globally as a plugin Import vue, vue-fusioncharts and FusionCharts in main app file.

import Vue from `vue`;
import VueFusionCharts from 'vue-fusioncharts';

// import FusionCharts modules and resolve dependency
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';

Now, register it as plugin in Vue object

Vue.use(VueFusionCharts, FusionCharts, Charts);

This way is recommended when you want component (vue-fusioncharts ) available from everywhere in your app.

Registering locally in your component Import the chart component from vue-fusioncharts/component package in your component file and use Vue.component to register it locally.

import Vue from `vue`;
import VueFusionChartsComponent from 'vue-fusioncharts/component';

// import FusionCharts modules and resolve dependency
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';

const vueFusionCharts = VueFusionChartsComponent(FusionCharts, Charts);

Vue.component('fusioncharts', vueFusionCharts);

This way is recommended when you want component (vue-fusioncharts ) only in specific components of your app.

Click here to view the live example.

Where eventName can be any fusioncharts event. You can find the list of events at fusioncharts devcenter

Working with APIs

To call APIs we will need the chart object. To get the chart object from the component we can use ref and retrieve it from this.$refs[refname].chartObj

<fusioncharts
  :type="type"
  :width="width"
  :height="height"
  :dataFormat="dataFormat"
  :dataSource="dataSource"
  @dataPlotRollover="onDataPlotRollover"
  ref="fc"
>
</fusioncharts>

Now, we can access the chart object from this.$refs.fc.chartObj

var app = new Vue({
  el: '#chart',
  data: {
    type: 'Pie2D',
    width: '500',
    height: '300',
    dataFormat: 'json',
    dataSource: myDataSource
  },
  methods: {
    onDataPlotRollover: function(e) {
      this.$refs.fc.chartObj.slicePlotItem(0);
    }
  }
});

This example will slice a Pie2d section when you rollover the chart.

Working with Events

To attach event listeners to FusionCharts, you can use the v-on or @ operator in the vue-fusioncharts component.

<fusioncharts
  :type="type"
  :width="width"
  :height="height"
  :dataFormat="dataFormat"
  :dataSource="dataSource"
  @eventName="eventHandler"
>
</fusioncharts>

Quick Start

Here is a basic sample that shows how to create a chart using vue-fusioncharts:

import Vue from 'vue';
import VueFusionCharts from 'vue-fusioncharts';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';

// register VueFusionCharts component
Vue.use(VueFusionCharts, FusionCharts, Charts);

const myDataSource = {
  chart: {
    caption: 'Recommended Portfolio Split',
    subCaption: 'For a net-worth of $1M',
    showValues: '1',
    showPercentInTooltip: '0',
    numberPrefix: '$',
    enableMultiSlicing: '1',
    theme: 'fusion'
  },
  data: [
    {
      label: 'Equity',
      value: '300000'
    },
    {
      label: 'Debt',
      value: '230000'
    },
    {
      label: 'Bullion',
      value: '180000'
    },
    {
      label: 'Real-estate',
      value: '270000'
    },
    {
      label: 'Insurance',
      value: '20000'
    }
  ]
};

const chart = new Vue({
  el: '#app',
  data: {
    type: 'column2d',
    width: '500',
    height: '300',
    dataFormat: 'json',
    dataSource: myDataSource
  }
});

Here's HTML template for the above example:

<div id="app">
  <fusioncharts
    :type="type"
    :width="width"
    :height="height"
    :dataFormat="dataFormat"
    :dataSource="dataSource"
  >
  </fusioncharts>
</div>

links to help you get started:

Usage and integration of FusionTime

From [email protected] and [email protected], You can visualize timeseries data easily with vue.

Learn more about FusionTime here.

Sample code for FusionTime

import Vue from 'vue';
import VueFusionCharts from 'vue-fusioncharts';
import FusionCharts from 'fusioncharts';
import TimeSeries from 'fusioncharts/fusioncharts.timeseries';

// register VueFusionCharts
Vue.use(VueFusionCharts, FusionCharts, TimeSeries);

const jsonify = res => res.json();
const dataFetch = fetch(
  'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/data.json'
).then(jsonify);
const schemaFetch = fetch(
  'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/schema.json'
).then(jsonify);

const chart = new Vue({
  el: '#app',
  data: {
    width: '500',
    height: '300',
    type: 'timeseries',
    dataFormat: 'json',
    dataSource: {
      caption: { text: 'Online Sales of a SuperStore in the US' },
      data: null,
      yAxis: [
        {
          plot: [
            {
              value: 'Sales ($)'
            }
          ]
        }
      ]
    }
  },
  mounted: function() {
    Promise.all([dataFetch, schemaFetch]).then(res => {
      const data = res[0];
      const schema = res[1];
      const fusionTable = new FusionCharts.DataStore().createDataTable(
        data,
        schema
      );
      this.dataSource.data = fusionTable;
    });
  }
});

Here's HTML template for the above example:

<div id="app">
  <fusioncharts
    :width="width"
    :height="height"
    :type="type"
    :dataFormat="dataFormat"
    :dataSource="dataSource"
  >
    FusionCharts will render here...
  </fusioncharts>
</div>

Useful links for FusionTime

Going beyond Charts

  • Explore 20+ pre-built business specific dashboards for different industries like energy and manufacturing to business functions like sales, marketing and operations here.
  • See Data Stories built using FusionCharts’ interactive JavaScript visualizations and learn how to communicate real-world narratives through underlying data to tell compelling stories.

For Contributors

  • Clone the repository and install dependencies
$ git clone https://github.com/fusioncharts/vue-fusioncharts.git
$ cd vue-fusioncharts
$ npm install

Licensing

The FusionCharts Vue integration component is open-source and distributed under the terms of the MIT/X11 License. However, you will need to download and include FusionCharts library in your page separately, which has a separate license.

vue-fusioncharts's People

Contributors

ashok1994 avatar kodandarama-accolite avatar legndery avatar pallab-accolite avatar rohanoid5 avatar rohitkr avatar rousan avatar sanjaybhan avatar sikrigagan avatar subratamal 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  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  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

vue-fusioncharts's Issues

renderAt not supported

Since renderAt is not supported I need to wrap my chart in a div with an ID fc-1 after an update my page re-renders but the fusion graph changes it's id so it tried to re-render in a div with ID fd-2. How can I specify the container element?

Double loading vue with message You are running Vue in development mode.

2020-08-09

`import VueFusionCharts from 'vue-fusioncharts';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';

Vue.use(VueFusionCharts, FusionCharts, Charts, FusionTheme);`

When I commented this code Vue working as expected.

Events for time navigator

I want to make an API call and update other data once someone selects a range using time navigator. Where can I find the event for that and how to trigger a function call on it?

Weird Documentation:issue

Best JavaScript Chart Library but the worst documentation ever wasting 4 hours in the doc examples still nothings works, registration component locally but y did globally, error saying using new keyword while what i did its just a simple copy past..., i mean VueDoc

Vue keep-alive not works with fusioncharts?

Hello, I'm trying to apply keep-alive attribute on my Vue (nuxt.js) application. Looks like it's impossible? Every time I change the page and returning back to the one with the charts, they're gone. There is no errors printed in console or anything else that can indicate what the issue might be.

Is that possible to run fusioncharts on keep alive mode?

Error: <text> attribute x: Expected length, "NaN"

When the chart data value is the 0 then fusion chart gives an error like Error: <text> attribute x: Expected length, "NaN".

[{
        "label": "Chart title",
        "value": 0
    },
    {
        "label": "Chart title",
        "value": 0
}]

Vue 3

Is there any plan to support vue 3?

html tag span not working in data labels

I use the 3.18.0 library
I'm using the type chart: column2d
I used the HTML span tag in the data label, but the functionality is not applied in the data label. The functionality is applied in the tooltip

image

VueJs Web Component build

I am trying to build a chart using VueJS web component:

vue-cli-service build --target wc --inline-vue --name my-app ./src/App.vue --env=production

This command produces the following files on dist:

image

However when I see dist.html on the browser I get:

image

I suspect the problem is with shadow dom:

image

When it tries to get the element to render the chart it fails due to shadow dom VueJS WC build produces.

When run yarn serve app is working fine but does not produce shadow DOM:

image

Do you think shadow DOM bugs fusion charts? Is there a workaround? Do I miss something there?

How can I import fusioncharts in small parts?

Hey,

I just found out the package is huge (up to 1.4MB) and we're not using all of it, only 3 types.
I couldn't figure out how to import only the usable parts and reduce the total bundle size.

Could you please guide me on how to properly import per usage base?

'Chart type not supported' message while using multilevelpie

HI,
i am trying to use the multilevelpie example from the website with cue-fusioncharts. I keep getting the chart type not supported message. The vue based example given here-link seems not functional. I first was getting can't initiate fusions charts without 'new' when tried to use Vue.use(fusion charts). After following your example on the GitHub,

let vFC = VueFCComponent(FusionCharts, Charts);
Vue.component('fusioncharts', vFC);

I was able to load the page without error, but the started getting chart type not supported message? Does this mean the VueFCComponent doesn't support this chart type?

dataEmptyMessageFontSize doesn't exist

Hello,
I'm using fusionchart for a view project and I followed the fusioncharts documentation for the properties you can add and the "dataEmptyMessageFontSize" property doesn't work, so I go to your project and when I see in the configuration file, the dataEmptyMessageFontSize property is not present.
Is this normal?

Using Vue.component throws an error

When I try to use

import VueFusionCharts from 'vue-fusioncharts';
import FusionCharts from 'fusioncharts/core';
import MSLine from 'fusioncharts/viz/msline';

Vue.component('fusioncharts', VueFusionCharts, FusionCharts, MSLine);

in my component, in the console.log I have an error:
image

The error is pointing in the node-modules\vue-fusioncharts\src\index.js in the install function:

const install = (Vue, FC, ...options) => {
    options && options.forEach && options.forEach((modules) => {
        addDep(FC, _FC, modules);
    });
    let component = _FCComponent(FC);

    Vue.component(component.name, component);
};

Also when I console.log the Vue.component in the install function it says that it's undefined:

const install = (Vue, FC, ...options) => {
    options && options.forEach && options.forEach((modules) => {
        addDep(FC, _FC, modules);
    });
    let component = _FCComponent(FC);
    console.log('vue-fusioncharts', Vue.component); // my console.log
    Vue.component(component.name, component);
};

image

Another problem is that when I try to import { FCComponent }, the npm can't find it.
import { FCComponent } from 'vue-fusioncharts';
image

Single File Components 'No data to display'

I'm using vue-fusioncharts with a single file component structure (utilizing webpack). I've followed the instructions on how to include fusioncharts in the app (https://www.fusioncharts.com/vue-fusioncharts/) and continue to get 'No data to display'. The only thing unique that I'm doing, different from the examples, is that the data is being included within a component and not on the Vue instance itself..

the main.js file:

import Vue from 'vue';
import VueFusionCharts from 'vue-fusioncharts';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import App from './App';
import router from './router';
import store from './store';

// resolve charts dependency
Charts(FusionCharts);

// register VueFusionCharts component
Vue.use(VueFusionCharts);

// Require the main Sass manifest file
require('./assets/sass/main.sass');

Vue.config.productionTip = false;

/* eslint-disable no-new */
new Vue({
  el: '#app',
  store, // inject store to all children
  router,
  template: '<App/>',
  components: { App },
});

the component file

...
    fusioncharts(:type='type', :width='width', :height='height', :dataFormat='dataFormat', :dataSource='dataSource')
</template>

<script>
const myDataSource = {
  'chart': {
    'caption': 'Age profile of website visitors',
    'subcaption': 'Last Year',
    'theme': 'ocean',
  },
  'data': [
    {
      'label': 'Teenage',
      'value': '1250400',
    },
    {
      'label': 'Adult',
      'value': '1463300',
    },
    {
      'label': 'Mid-age',
      'value': '1050700',
    },
    {
      'label': 'Senior',
      'value': '491000',
    },
  ],
};

export default {
  name: 'track-progress',
  data() {
    return {
      type: 'column2d',
      width: '500',
      height: '300',
      dataFormat: 'json',
      dataSource: myDataSource,
    };
  },
};
</script>
...

I've looked at similar issues, but no luck and so far no solution regarding single file components.. any help would be appreciated!

Do Text Annotations Work With Vue?

I am using fusiontime bar charts which are working beautifully. I also added extensions and those are working as well. However adding annotations causes the chart components to revert to undefined and the chart does not render. Are text annotations supported in vue? Thanks.

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.