npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-chartify

v1.0.3

Published

A comprehensive and easy-to-use charting library for Vue.js applications. With interactive features and extensive customization options, the Vue Charting Package is the perfect solution for adding data visualizations to your Vue.js applications.

Downloads

18

Readme

Vue Chartify

Vue Chartify is a lightweight and easy-to-use library for creating beautiful and interactive charts with Vue.js. Supports the common chart types, such as line and bar chart and more will be added soon.

  • MIT License
  • Static Badge
  • Static Badge

Features

  • Responsive and adaptive to different screen sizes
  • Lightweight, efficient, on-demand binding events
  • Customizable colors, fonts, lines, and animation
  • Supports Vue 3 and TypeScript

Installation

  • Use npm:
  npm install vue-chartify
  • Add the css in main.ts
import { createApp } from 'vue'
import App from './App.vue'
import "vue-chartify/style.css"

createApp(App).mount('#app')
  • Import the component
<script>
import { defineComponent } from 'vue'
import { VcBarChart, VcLineChart } from 'vue-chartify';
export default defineComponent({
    components: { VcBarChart, VcLineChart },
    // rest of your component
})
</script>
  • Use the component in template

    • Bar Chart
    <vc-bar-chart 
        data-source="<YourDataSource>"
        argument-field="<YourArgumentField>"
        value-field="<YourValueField>"
        :show-value-axis-line="true"
        :show-argument-axis-line="true"
        :show-value-titles="true"
        :show-argument-titles="true"
        :show-value-labels="true"
        :show-horizontal-grid-lines="true"
        :show-vertical-grid-lines="true"
        :bar-colors="['#454d66', '#309975', '#58b368', '#dad873', '#efeeb4', '#454d66', '#309975']"
        bar-color="red"
        :bar-radius="5"
        :animation="true"
    />
    • Line Chart
    <vc-line-chart 
        data-source="<YourDataSource>"
        argument-field="<YourArgumentField>"
        value-field="<YourValueField>"
        :show-value-axis-line="true"
        :show-argument-axis-line="true"
        :show-value-titles="true"
        :show-argument-titles="true"
        :show-value-labels="true"
        :show-horizontal-grid-lines="true"
        :show-vertical-grid-lines="true"
        line-color="#343090"
        :line-width="3"
        :animation="true"
        :show-points="true"
    />

Common Props

* = required

| Name | Type | Default | Description | | ----------------- | -------------- | ----------- | ------------------- | | dataSource * | Object[] | [] | Binds the UI component to data | | argumentField * | String | undefined | Specifies which data source field provides arguments for series points | | valueField * | String | undefined | Specifies which data source field provides values for series points | | width | String | 100% | Specifies the width of the UI component | | height | String | 500px | Specifies the height of the UI component in pixels.edges | | showValueLabels | Boolean | false | Shows the value as label on data points | | showArgumentTitles | Boolean | true | Shows the argument (x-axis) titles | | showValueTitles | Boolean | true | Shows the value (y-axis) titles | | showValueAxisLine | Boolean | true | Shows the value axis (y-axis) line | | showArgumentAxisLine | Boolean | true | Shows the argument axis (x-axis) line | | showHorizontalGridLines | Boolean | false | Shows the horizontal grid | showVerticalGridLines | Boolean | false | Shows the vertical grid lines | | horizontalGridLineOptions | Object | {stroke: '#dddddd80', 'stroke-width': '1px'} | Specifies the horizontal grid lines style | | verticalGridLineOptions | Object | {stroke: '#dddddd80', 'stroke-width': '1px' | Specifies the vertical grid lines
| fontSize | String | 12px | Specify font size value
| fontColor | String | black | Specify font color
| fontFamily | String | Arial, Helvetica, sans-serif | Specify font family | animation | Boolean | true | Enables the animation in the UI component
| animationDuration | String | 0.5s | Specifies how long the animation runs
| breakpoints | Object | Breakpoints | Specifies breakpoints for chart responsiveness | customValueLabel | Function | (value: number, index: number) => value | Custom value label function

Specific Props

  • Bar Chart Props

| Name | Type | Default | Description | | ----------------- | -------------- | ----------- | ------------------- | | barColor | String | black | Specifies bar colors | | barColors | String[] | [] | Specifies color for each specific bar | | barRadius | Number | 0 | Specifies bar radius value |

  • Line Chart Props

| Name | Type | Default | Description | | ----------------- | --------| --------| ---------------------------------- | | lineColor | String | black | Specifies line color | | lineWidth | Number | 3 | Specifies width value of the line | | showPoints | Boolean | true | Show the points |

Breakpoints

The default object of Breakpoints has the following properties. The gap value determines the spacing and affects their sizes.

{
    xs: {
        width: '576px',
        gap: '20px'
    },
    sm: {
        width: '768px',
        gap: '22px'
    },
    md: {
        width: '992px',
        gap: '25px'
    },
    lg: {
        width: '1200px',
        gap: '27px'
    },
    xl: {
        width: '1400px',
        gap: '30px'
    }
}

Example

Capture.jpg

<template>
  <div>
    <div class="bar-charts">
      <vc-bar-chart
        :data-source="dataSource"
        argument-field="continent"
        value-field="density"
        :bar-colors="['#454d66', '#309975', '#58b368', '#dad873', '#efeeb4', '#454d66', '#309975']"
        :bar-radius="5"
        :animation="true"
        :custom-value-label="getValueLabel"
        show-value-labels
        @bar:click="onBarClick"
      />
      <vc-bar-chart
        :data-source="dataSource"
        argument-field="continent"
        value-field="population"
        :bar-colors="['#e0f0ea', '#95adbe', '#574f7d', '#503a65', '#3c2a4d', '#e0f0ea', '#95adbe']"
        :bar-radius="5"
        :animation="true"
        show-value-labels
        :custom-value-label="getValueLabel"
        @bar:click="onBarClick"
      />
    </div>
    <vc-line-chart
      :data-source="dataSource"
      argument-field="continent"
      value-field="area"
      line-color="#574f7d"
      :animation="true"
      :custom-value-label="getValueLabel"
      @point:click="onBarClick"
    />
  </div>
</template>

<script>
import { VcBarChart, VcLineChart } from 'vue-chartify'
export default {
  components: { VcBarChart, VcLineChart },
  data() {
    return {
      dataSource: [
        {
          continent: 'Europe',
          population: 740433713,
          area: 22134710,
          density: 33
        },
        {
          continent: 'Africa',
          population: 1460481772,
          area: 29648481,
          density: 49
        },
        {
          continent: 'South America',
          population: 439719009,
          area: 17461112,
          density: 25
        },
        {
          continent: 'North America',
          population: 604182517,
          area: 21330000,
          density: 28
        },
        {
          continent: 'Asia',
          population: 4753079726,
          area: 31033131,
          density: 153
        },
        {
          continent: 'Australia',
          population: 46004866,
          area: 8486460,
          density: 5
        },
        {
          continent: 'Antartica',
          population: 0,
          area: 13720000,
          density: 0
        }
      ]
    }
  },
  methods: {
    onBarClick(data) {
      console.log(data)
    },
    onPointClick(data) {
      console.log(data)
    },
    getValueLabel(value) {
      if (value > 0 && value < 1) {
        const precision = Math.ceil(-Math.log10(value))
        return value.toFixed(precision)
      }
      return value.toLocaleString()
    }
  }
}
</script>

<style lang="scss" scoped>
.bar-charts {
  display: flex;
  flex-direction: row;
}
</style>