0.9.3 • Published 3 years ago

vue-graph v0.9.3

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

vue-graph

A vue component library based on the JUI charts available in vuejs.

forthebadge forthebadge forthebadge

Installation

NPM

npm install --save vue-graph

Browser

Just download dist/vue-graph.js and include it in your HTML file:

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<script src="https://cdn.rawgit.com/juijs/vue-graph/2216ae2f/dist/vue-graph.js"></script>

ES Modules

Plug-In
import Vue from 'vue'
import VueGraph from 'vue-graph'

Vue.use(VueGraph)
Components
import Vue from 'vue'
import GraphLine3D from 'vue-graph/src/components/line3d.js'
import NoteWidget from 'vue-graph/src/widgets/note.js'
import LegendWidget from 'vue-graph/src/widgets/legends.js'

Vue.component(GraphLine3D.name, GraphLine3D);
Vue.component(NoteWidget.name, NoteWidget);
Vue.component(LegendWidget.name, LegendWidget);

Usage

Unlike other chart components, vue-graph have child nodes in the chart called widgets. The widget is used as an additional function of charts such as chart title, legend, tooltip.

The following is a link you can test with CodePen.

<div id="app">
    <graph-treemap
            :width="800"
            :height="800"
            :text-align="'right'"
            :text-vertical-align="'bottom'"
            :colors="[ '#EC2500', '#ECE100', '#EC9800', '#9EDE00' ]"
            :values="values">
        <note :text="'Treemap Chart'" :align="'left'"></note>
        <tooltip :position="'top'"></tooltip>
    </graph-treemap>
</div>

In the following code, the chart is prefixed with 'graph-' for each type. The widget can be added as a child node of the chart, unlike a chart, was named without a prefix.

The vue-graph can be combined with charts and widgets for a variety of visualizations. This is a very flexible and scalable structure.

var vm = new Vue({
    el: "#app",
    data: {
        values: [
            [ '0', 'Apples', -1 ],
            [ '0.0', 'Anne', 5 ],
            [ '0.1', 'Rick', 3 ],
            [ '0.2', 'Peter', 4 ],
            [ '1', 'Bananas', -1 ],
            [ '1.0', 'Anne', 4 ],
            [ '1.1', 'Rick', 10 ],
            [ '1.2', 'Peter', 1 ],
            [ '2', 'Oranges', -1 ],
            [ '2.0', 'Anne', 1 ],
            [ '2.1', 'Rick', 3 ],
            [ '2.2', 'Peter', 3 ],
            [ '3', 'Susanne', 2 ],
        ]
    }
});

Implemented chart list

There are many charts that have not yet been migrated. We are going to continue.

Props

Common

NameTypeRequiredWatchDefaultDescription
themeStringfalsefalseclassicSupports a total of five themes (classic, dark)
stylesObjectfalsefalseundefinedCustomize the style of the chart elements you want in key-value format (Classic, Dark)
colorsArray, FunctionfalsefalseundefinedOptions to change the list of colors defined by chart theme (Style Tab)
clipBooleanfalsefalsefalseOption to cut if the drawing element is out of the chart range
formatFunctionfalsetrueundefinedA callback function that allows you to customize the axis values of the chart
widthNumbertruetrueundefinedThe width of the chart
heightNumbertruetrueundefinedThe height of the chart
paddingTopNumberfalsefalse50Top padding of the chart
paddingRightNumberfalsefalse50Right padding of the chart
paddingBottomNumberfalsefalse50Bottom padding of the chart
paddingLeftNumberfalsefalse50Left padding of the chart
focusStartNumberfalsefalse-1The starting index of the focus area (the criterion is slightly different depending on the type of axis)
focusEndNumberfalsefalse-1The ending index of the focus area (the criterion is slightly different depending on the type of axis)
labelsArrayfalsetrueundefinedLabel of chart data
valuesArrayfalsetrueundefinedIt is a chart data value, and the format may be different for each chart type

Common (Animation)

NameTypeRequiredWatchDefaultDescription
renderIntervalNumberfalsefalse200Rendering interval (ms)
renderHandlerFunctionfalsefalsenullCallback function that can post-process when rendering a chart
renderStopBooleanfalsetruefalsePause or resume chart rendering

Common (X-Y Axis)

NameTypeRequiredWatchDefaultDescription
axisMinNumberfalsefalse0Miniimum value for the chart axis
axisMaxNumberfalsefalse0Maximum value for the chart axis
axisStepNumberfalsefalse10Display interval of chart axis value
axisXStyleStringfalsefalsesolidLine style for chart x-axis area (solid, dotted, gradient, none, hidden)
axisYStyleStringfalsefalsesolidLine style for chart y-axis area (solid, dotted, gradient, none, hidden)
axisXPositionStringfalsefalsebottomChart x-axis position (bottom, top)
axisYPositionStringfalsefalseleftChart y-axis position (left, right)
axisReverseBooleanfalsefalsefalseReplace the x and y axis positions
axisFullModeBooleanfalsefalsefalseDraw a chart drawing element full of the axis label area.
axisIntervalNumberfalsefalse1000 60 60It is the label value display interval of the date type (Unit: ms)
axisFormatString, FunctionfalsefalseHHIt is the label value display format of the date type
textRotateXNumberfalsefalse0The tilt angle of the x-axis text
textRotateYNumberfalsefalse0The tilt angle of the y-axis text

Props by charts

graph-bar, graph-comparison-bar

NameTypeRequiredWatchDefaultDescription
fixedSizeNumberfalsefalse0Fixed width of bar (or height)
minValueNumberfalsefalse0When the value is very small, the minimum size of the bar
barMarginNumberfalsefalse2Margins between bars and bars
barPaddingNumberfalsefalse1Inside padding inside the bar
activeIndexNumberfalsetrueundefinedThe index of the bar to activate
activeEventStringfalsefalseundefinedEvent type to activate the bar
displayStringfalsefalseundefinedOptions that display the value of the bar (max, min, all)

graph-bar3d

NameTypeRequiredWatchDefaultDescription
namesArraytruefalseundefinedName of the z-axis data key
barPaddingNumberfalsefalse20Inside padding inside the bar

graph-stackbar

NameTypeRequiredWatchDefaultDescription
fixedSizeNumberfalsefalse0Fixed width of bar (or height)
barMarginNumberfalsefalse2Margins between bars and bars
barPaddingNumberfalsefalse1Inside padding inside the bar
activeIndexNumberfalsetrueundefinedThe index of the bar to activate
activeEventStringfalsefalseundefinedEvent type to activate the bar
displayStringfalsefalseundefinedOptions that display the value of the bar (max, min, all)
connectedLineBooleanfalsefalsefalseOptions that show the line connecting the bars and bars
fullModeBooleanfalsefalsefalseOption to change to full stack bar
showTextBooleanfalsefalsefalseOptions to show the percentage value in the bar

graph-rangebar

NameTypeRequiredWatchDefaultDescription
barMarginNumberfalsefalse2Margins between bars and bars
barPaddingNumberfalsefalse1Inside padding inside the bar

graph-line, graph-line-dateblock, graph-line-timerange

NameTypeRequiredWatchDefaultDescription
shapeStringfalsefalsenormalIt is the shape of the line (normal, curve, step)
activeIndexNumberfalsefalseundefinedThe index of the line to activate
activeEventStringfalsefalseundefinedEvent type to activate the line
displayStringfalsefalseundefinedOptions that display the value of the line (max, min, all)
opacityNumberfalsefalseundefinedThe transparency of the line (Value between 0 and 1)

graph-line3d

NameTypeRequiredWatchDefaultDescription
namesArraytruefalseundefinedName of the z-axis data key
linePaddingNumberfalsefalse20Inside padding inside the line

graph-bubble

NameTypeRequiredWatchDefaultDescription
minSizeNumberfalsefalse5Minimum size of bubble
maxSizeNumberfalsefalse30Maximum size of bubble
showTextBooleanfalsefalsefalseOptions to show the percentage value in the bubble
activeEventStringfalsefalseundefinedEvent type to activate the bubble

graph-area, graph-area-dateblock, graph-area-timerange, graph-comparison-area

NameTypeRequiredWatchDefaultDescription
shapeStringfalsefalsenormalIt is the shape of the area (normal, curve, step)
opacityNumberfalsefalseundefinedThe transparency of the area (Value between 0 and 1)
borderLineBooleanfalsefalsetrueShow lines on the border of the area

graph-scatter

NameTypeRequiredWatchDefaultDescription
shapeStringfalsefalsecircleIt is the shape of the scatter (circle, triangle, rectangle, cross)
activeEventStringfalsefalseundefinedEvent type to activate the scatter
displayStringfalsefalseundefinedOptions that display the value of the scatter (max, min, all)
opacityNumberfalsefalseundefinedThe transparency of the scatter (Value between 0 and 1)
sizeNumberfalsefalse7Size of scatter (Value between 0 and 1)
hideZeroBooleanfalsefalsefalseOption to hide scatter when the value is 0

graph-pie

NameTypeRequiredWatchDefaultDescription
shapeStringfalsefalsepieIt is the shape of the pie (pie, donut)
activeIndexNumber, ArrayfalsetrueundefinedThe index of the pie to activate
activeEventStringfalsefalseundefinedEvent type to activate the pie
showTextTypeStringfalsefalseundefinedOptions that display the value of the pie (inside, outside)
dataFormatFunctionfalsetrueundefinedPie data format function
showTotalValueBooleanfalsefalseundefinedOptions that show total value in the center when the shape is donut
strokeWidthNumberfalsefalse50When the shape is donut, set the stroke width

graph-treemap

NameTypeRequiredWatchDefaultDescription
showTextBooleanfalsefalsefalseOptions to show the title in the treemap node
textAlignStringfalsefalsecenterHorizontal alignment (center, left, right)
textVerticalAlignStringfalsefalsetopVertical alignment (top, bottom, middle)
titleDepthNumberfalsefalse1Sets the depth of the tree node to show the title
nodeColorFunctionfalsefalseundefinedSet the color of the node to the callback function

graph-equalizer

NameTypeRequiredWatchDefaultDescription
minValueNumberfalsefalse0When the value is very small, the minimum size of the bar
fixedSizeNumberfalsefalse0Fixed width of bar (or height)
barMarginNumberfalsefalse2Margins between bars and bars
barPaddingNumberfalsefalse1Inside padding inside the bar
maxDivisionsNumberfalsefalse5Maximum number of division bars

graph-activebubble

NameTypeRequiredWatchDefaultDescription
gravityNumberfalsefalse0.2Sets the force to pull the bubble
radiusNumberfalsefalse20Radius value of the bubble
opacityNumberfalsefalse1Transparency value of the bubble

Props by widgets

note

A widget that can display text in a chart.

NameTypeRequiredWatchDefaultDescription
textStringtruetrueText to display
alignStringfalsetruecenterHorizontal alignment (center, left, right)
verticalAlignStringtruefalsetopVertical alignment (top, bottom, middle)
dxNumberfalsefalse0x-axis position adjustment value
dyNumberfalsefalse0y-axis position adjustment value
sizeNumberfalsefalseundefinedFont size
colorStringfalsefalseundefinedFont color

tooltip

Widget showing chart element values.

NameTypeRequiredWatchDefaultDescription
namesStringtruetrueName to map to value type
positionStringfalsefalsetopVertical alignment (top, bottom, left, right)
showAnchorBooleanfalsefalsetrueOptions to display anchor

legends

Widget that represents the chart legend.

NameTypeRequiredWatchDefaultDescription
namesStringtruetrueName to map to value type
alignStringfalsefalsecenterHorizontal alignment (center, left, right)
positionStringfalsefalsebottomVertical alignment (top, bottom, left, right)
dxNumberfalsefalse0x-axis position adjustment value
dyNumberfalsefalse0y-axis position adjustment value
filterBooleanfalsefalsefalseOptions to filter elements of a specific name
colorsArrayfalsefalseundefinedFiltering element color by name

guideline

Widget to help you see x-y axis values easily.

NameTypeRequiredWatchDefaultDescription
tooltipXBooleanfalsefalsefalseGuidelines for displaying x-axis values
tooltipYBooleanfalsefalsetrueGuidelines for displaying y-axis values

Events

There are three types of events for the drawing object, outside and inside the axis area.

<div id="app">
    <graph-bar
            :width="600"
            :height="400"
            :axis-min="0"
            :axis-max="50"
            :labels="[ '1Q', '2Q', '3Q', '4Q' ]"
            :values="values"
            :active-event="'click'"
            @click="onClickBar"
            @outside#click="onClickOutside"
            @inside#click="onClickInside">
        <note :text="'Bar Chart (+Event)'"></note>
    </graph-bar>
</div>
<script>
var vm = new Vue({
    el: "#app",
    data: {
        values: [
            [ 10, 5, 5, 5 ],
            [ 40, 10, 10, 10 ],
            [ 30, 30, 30, 30 ]
        ]
    },
    methods: {
        onClickBar: function() {
            console.log(arguments);
            alert("onClickBar");
        },
        onClickOutside: function() {
            console.log(arguments);
            alert("onClickOutside");
        },
        onClickInside: function() {
            console.log(arguments);
            alert("onClickInside");
        }
    }
});
</script>

Common events are shown in the table below.

Outside axisInside axisDrawing objectDescription
outside#clickinside#clickclick
outside#dblclickinside#dblclickdblclick
outside#rclickinside#rclickrclickcontextmenu
outside#mouseoverinside#mouseovermouseover
outside#mouseoutinside#mouseoutmouseout
outside#mousemoveinside#mousemovemousemove
outside#mousedowninside#mousedownmousedown
outside#mouseupinside#mouseupmouseup
0.9.3

3 years ago

0.9.2

3 years ago

0.9.0

3 years ago

0.8.7

4 years ago

0.8.6

5 years ago

0.8.5

5 years ago

0.8.4

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.9

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

6 years ago

0.5.5

6 years ago

0.5.4

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago