0.0.1 • Published 6 years ago

vue-in-chart v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Build Status Coverage Status

vue-in-charts

Small Vue component to build simple small charts. Intended to be placed inline boxes and tables. :bar_chart: :chart_with_upwards_trend:

Install

Install via npm:

$ npm install vue-in-chart

Install via bower:

$ bower install vue-in-chart

Usage

Import the chart you want to use

import InPieChart from 'vue-in-charts';

Use it on your template. Below you can find the options for each chart.

<in-pie-chart
    :slices="[
            { name: 'Slice 1', value: 90, color: '#F44336' },
            { name: 'Slice 2', value: 70, color: '#2196F3' },
            { name: 'Slice 3', value: 50, color: '#8BC34A' },
            { name: 'Slice 4', value: 20, color: '#FFC107' }
        ]"
    :diameter="'100'" />

Properties

Pie Chart (InPieChart)

PropertyTypeRequiredDefaultDescription
diameterStringfalse'100%'The diameter of the pie. In other words, its width and height.
rotateNumberfalse-90The rotation of the pie. -90 means the first slice will start at 90º
slicesArray (of slice)trueAn array of objects. Each one representing a slice of the pie.
slice.nameStringfalseThe name of the slice. Will be displayed on hovering the chart
slice.valueNumbertrueThe value of the slice. Will be displayed on hovering the chart and also will be used to calculate the percentage
slice.colorStringtrueWill be used to fill the slice with the color.

Line Chart (InLineChart)

PropertySub-PropTypeRequiredDefaultDescription
widthStringfalse'250'The width of the chart.
heightStringfalse'100'The height of the chart.
show-pointsBooleanfalsetrueWeather or not the points should be drawn.
min-yNumberfalsenullThe minimum value for the Y axis. If none is passed, the smaller value will be used.
max-yNumberfalsenullThe maximum value for the Y axis. If none is passed, the greater value will be used.
show-tooltipBooleanfalsetrueWether to show or not the tooltip on hover
linesArray (of line)trueAn array containing the several lines and its properties. A line is defined as below
lineObjecttrueObject that defines a line. Should be used in am array with the lines property above.
dataArray (of numbers)An array of numbers representing the Y axis values for the line.
pointRadiusNumberfalse3The radius of the point on this line. Only applicable if show-points is true.
pointColorStringfalsewhiteThe color for the points of this line. Only applicable if show-points is true
strokeWidthNumberfalse2The stroke width for this line.
strokeColorStringtrueA color string fpr the line color.
fillColorStringfalseA color string representing the color of the area below the line.
fillColorArrayfalseAn array of color strings representing the gradient of the area below the line.
fill-colorObjectfalseAn object that defines the gradient for the fill color. The properties are listed as follow.
.x1StringtrueThe x1 coordinate for the SVG direction.
.x2StringtrueThe x2 coordinate for the SVG direction.
.y1StringtrueThe y1 coordinate for the SVG direction.
.y2StringtrueThe y2 coordinate for the SVG direction.
.stopsArray (of stop)trueAn array of stops.
.stop.offsetStringtruePercentage of the gradient.
.stop.colorStringtrueColor of the stop.

Bar Chart (InBarChart)

PropertySub-PropTypeRequiredDefaultDescription
widthStringfalse'250'The width of the chart.
heightStringfalse'100'The height of the chart.
min-yNumberfalsenullThe minimum value for the Y axis. If none is passed, the smaller value will be used.
max-yNumberfalsenullThe maximum value for the Y axis. If none is passed, the greater value will be used.
show-tooltipBooleanfalsetrueWether to show or not the tooltip on hover.
stroke-widthNumberfalse1The stroke width for the bars.
stroke-colorStringfalse#333The stroke color for the bars.
paddingNumberfalse0The padding among the bars.
fill-colorStringfalsetomatoThe general color for each bar.
fill-colorArrayfalseAn array of string of colors. The colors will be drawn as a vertical gradient.
fill-colorObjectfalseAn object that defines the gradient for the fill color. The properties are listed as follow.
.x1StringtrueThe x1 coordinate for the SVG direction.
.x2StringtrueThe x2 coordinate for the SVG direction.
.y1StringtrueThe y1 coordinate for the SVG direction.
.y2StringtrueThe y2 coordinate for the SVG direction.
.stopsArray (of stop)trueAn array of stops.
.stop.offsetStringtruePercentage of the gradient.
.stop.colorStringtrueColor of the stop.
barsArray (of numbers)trueArray of numbers representing the values for the bars
barsArray (of objects)trueArray of objects representing the values for the bars. A bar is defined as below
barObjectObject that defines a bar. Should be used in am array with the bars property above.
valueNumbertrueThe value for the bar.
fill-colorThis is a specific color for the bar. It overrides the fill-color property above and accept any format as described above