0.1.9 • Published 3 years ago

k-vue-funnel-graph-js v0.1.9

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

VueFunnelGraph.js

npm GitHub GitHub last commit Gitter

Funnel graph drawing library for Vue.js.

  • SVG charts
  • Values, Labels, Percentages display
  • Two-dimensional graph support
    • Legend display
    • Detailed percentage breakdown on hover
  • Animated
  • Solid color and gradient fill
  • Horizontal and vertical charts

This is the Vue.js version of FunnelGraph.js, learn more about the library and see documentation here.

Demo

Online Demo

CodePen Demo

Development Demo

  • Clone the repo
  • Navigate to src folder
  • Run vue serve example.vue
  • Visit the URL displayed

Installation

NPM

npm i vue-funnel-graph-js

UNPKG

<script src="https://unpkg.com/vue-funnel-graph-js"></script>

CDN

<script src="https://cdn.jsdelivr.net/npm/vue-funnel-graph-js/dist/vue-funnel-graph.min.js"></script>

Usage

After installing, import the VueFunnelGraph component:

import { VueFunnelGraph } from 'vue-funnel-graph-js';

You can now use the custom element:

<vue-funnel-graph :width="width" :height="height" :labels="labels"
              :values="values" :colors="colors" :sub-labels="subLabels" :direction="direction"
              :gradient-direction="gradientDirection"
              :animated="true" :display-percentage="true"
></vue-funnel-graph>

The values are passed to props:

export default {
  name: 'app',
  components: {
      VueFunnelGraph
  },
  data() {
      return {
          labels: ['Impressions', 'Add To Cart', 'Buy'],
          subLabels: ['Direct', 'Social Media', 'Ads'],
          values: [
          // with the given Labels and SubLabels here's what the values represent:
          // 
          // Direct, Social, Ads  
          //    |      |     |  
          //    v      v     v
              [3000, 2500, 6500], // Segments of "Impressions" from top to bottom
              [3000, 1700, 1000], // Segments of "Add To Cart"
              [600,  200,  130]   // Segments of "Buy"
          ],
          colors: [
              ['#FFB178', '#FF3C8E'], // color set for "Impressions" segment
              ['#A0BBFF', '#EC77FF'], // color set for "Add To Cart" segment
              ['#A0F9FF', '#7795FF']  // color set for "Buy" segment
          ],
          direction: 'horizontal',
          gradientDirection: 'horizontal',
          height: 300,
          width: 800
      };
  }
}

Options

OptionDescriptionTypeRequiredOptionsDefaultExample
widthWidth of the funnel graphnumberYes0800
heightHeight of the funnel graphnumberYes0300
labelsTitle of each data partarrayYes'Impressions', 'Add To Cart', 'Buy'
valuesNumbers that the funnel chart visualizesarrayYes12000, 4700, 930
colorsColors of the graph. If a string or array with one element passed it fills the graph with a solid color, if the array contains more than one element it fill the graph with a gradient. For two-dimensional charts and array of arrays shall be passed to fill each segment with a separate gradient. The array can contain arrays and strings mixed. If a there are more segments than colors provided, up to 10 extra segments will be filled with pre-defined solid colorsarray⎮stringYes12000, 4700, 930
subLabels (:sub-labels)Title of each data segmentarrayYes for two-dimensional graphs'Direct', 'Social Media', 'Ads'
directionWhether the chart visualization is displayed vertically or horizontallystringNo'vertical', 'horizontal''horizontal'
gradientDirection (:gradient-direction)Whether the gradient applied to the segments of the graph is displayed from top to bottom or from left to rightstringNo'vertical', 'horizontal''horizontal'
animatedWhether any change in graph shape will be displayed with a smooth transitionbooleanNotrue, falsetruefalse
displayPercentage (:display-percentage)Whether to display the automatically calculated percentage values below the labelsbooleanNotrue, falsetrue