Giter VIP home page Giter VIP logo

vue-bar's Introduction

WARNING: project is no longer actively maintained, make sure to update any dependencies if you plan on using this in your project. (This project does not work with Vue3 and higher.)

Vue Bars

Vue Bars

🌈 Simple, elegant spark bars for Vue.js


npm vue

Installation

npm i vuebars -S

Usage

import Vue from 'vue'
import Bars from 'vuebars'

Vue.use(Bars)

Live Demo

vue template

<bars
  :data="[1, 2, 5, 9, 5, 10, 3, 5, 2, 5, 1, 8, 2, 9, 0]"
  :gradient="['#6fa8dc', '#42b983']">
</bars>

Inspired by

vuetrend - 📈 Simple, elegant spark lines

Props

Name Type Default Description Example
data Number|Object undefined The data accepted by Vue Bars is incredibly simple: An array of y-axis values to graph. [120, 149, 193.4, 200, 92] or [{ value: 4 }, { value: 6 }, { value: 8 }]
gradient String ['#000'] Colour can be specified as any SVG-supported format (named, rgb, hex, etc). ['#0FF', '#F0F', '#FF0']
width Number auto Set an explicit width for your SVG. -
height Number auto Set an explicit height for your SVG. -
padding Number 8 If you set a very large strokeWidth on your line, you may notice that it gets "cropped" towards the edges. -
rounding Number 2 To control radius on each bar's corners -
barWidth Number 4 Set width of each bar -
labelRotate Number -45 To control rotation of labels -
labelSize Number 0.7 To control size of labels -
labelColor String #999 To control color of labels -
labelData String [] Array of strings ['label1','label2','label3']
minBarHeight Number 3 Minimum height -
autoDraw Boolean false Allow the line to draw itself on mount. Set to true to enable, and customize using autoDrawDuration and autoDrawEasing. -
growDuration Number 0.5 The amount of time, in seconds, that the autoDraw animation should span. This prop has no effect if autoDraw isn't set to true. -
max Number -Infinity Specify max value -
min Number Infinity Specify min value, This is useful if you have multiple lines. See #8 -

SVG Props

By default, all properties not recognized by Vue Bars will be delegated to the SVG. The line inherits these properties if none of its own override them.

On-the-fly reloading

Make sure you use pass the same variable for your data as for the key, this will make sure Vue recognizes changes to your data array, and consequently forces a reload of the instance.

TODO

  • Unit test

License

MIT

vue-bar's People

Contributors

ansidev avatar dependabot[bot] avatar deviavir avatar jorgenvatle avatar noahbare avatar smknstd avatar zombiesplat 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  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

vue-bar's Issues

Missing Label Parameter Documentation

Within the documentation for labels there is no mention of the available props you can change, such as :labelRotate and :labelColor without having to look into the code. I believe the documentation for labels should be updated.

Rounding prop doesn't work

Browser: Chrome

When I change the rounding prop it doesn't change anything.

My input:

   <bars
          data="[1, 2, 5, 9, 5, 10, 3, 5, 2, 5, 1, 8, 2]"
          gradient="['#00ac84']"
          :barWidth="10"
          :rounding="4"
    />

Output:

image

Flip prop

Hi!

Would you accept a prop that would flip the bars to be rendered horizontally (instead of vertically)?
All naming suggestions are also welcome (since flip might not be that obvious).

Best,
andreas

Bars grow from top to down instead of bottom up

On the website: https://deviavir.github.io/vue-bar/ the bars load vertically, from bottom (0), to top of the value range (say, 12).

However in practice: https://jsfiddle.net/1bvxyjhk/ (example in README)

The bars load vertically as expected, but from top to bottom (which seems a bit more awkward).

This seems to happen in 1.5.0 but not earlier versions.

Some possible solutions:

  1. Fix so bars load from bottom to top as before
  2. Fix so that negative bars load from 0 to their value, and positive bars 0 to their value
  3. Have option for which direction bars load vertically, and as mentioned in another issue possibility to load them horizontally

Does not rebuild svg after updated data

Unlike Vue-trend, vue-bar does not rebuilt its own SVG after data that's been feeding this svg has changed.

Here's my example:

<template>
  <div class="row">
    <div class="col-12">
        <button class="btn btn-future" @click="refresh">Refresh</button>

        <hr>

        <bars
          :data="bars"
          :gradient="['#6fa8dc', '#42b983']"
          :barWidth="2" :rounding="1">
        </bars>
    </div>
  </div>
</template>

<script>
  import _ from 'lodash'

  export default {
    data() {
      return {
        bars: [],
        trends: []
      }
    },

    created() {
      this.randomArray();
    },

    methods: {
      randomArray() {
        this.bars = _.times(100, _.random.bind(30, 10000));
        this.trends = _.times(100, _.random.bind(30, 10000));
      },
      refresh() {
        this.randomArray();
      }
    }
  }
</script>

Negative bars

Hi,
should be possibile to add negative bars?

Thank you

Label Size

Would it be possible to accept a prop to change the font size? On a graph with multiple labels, the text gets cut off on the sides because it's too big.

Cannot set property 'boundary' of undefined

Hi!
I'm using the vue-bars module on a codepen project.
It appeared to work, however, I've encountered this error when trying to render a graph:

parameters:

<bars
       :data="numbers">
    </bars>

numbers is a data object with the following structure:

numbers: [
        { key: 1 },
        { key: 2 },
        { key: 3 },
      ]

link to codepen project

How to display tips?

Awesome project!

How do I display a custom tooltip when I hover over a bar?

Thanks!

Segregate Labels for backwards compatibility

When I made the update for the labels, I pretty much only did enough for my own needs. However that update was not backwards compatible and will break existing implementations.

My plan is to make the x-axis labels an optional parameter passed in as an array of text. This issue will serve to also let others know I am working on this if your build breaks in the meantime, update your packages.json for version 0.1.3

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

ReferenceError: Path is not defined

Using expressVue so unable to pass this to Vue.use. That being said not entirely sure that this shouldn't work using the import alone. Wondering if there is something in the files that could be causing conflict or if there might be a way to install this using expressVue and serverside rendering.

From

 h(Path, {

Thanks.

vue3 support

Hello,

Thanks for creating this simple bar chart.
Does this will work with vue 3?

In the dependencies is "vue": "^2.5.21"

Bar is not displaying properly

 <!-- Expected showing 15 columns -->
  <bars
    :data="[1, 2, -5, 9, 5, 10, 3, 5, 5, 12, 1, 8, 2, 9, 14]"
    :gradient="['#6fa8dc', '#42b983']"
    :barWidth="5"
    :growDuration="1">
  </bars>
 <!-- it's working fine as I expected -->
  
 <!-- Expected showing 2 columns -->
  <bars
    :data="[1, 2]"
    :gradient="['#6fa8dc', '#42b983']"
    :barWidth="100"
    :growDuration="1"
  >
  </bars>
  <!-- It's not working properly as I expected -->

Attached the image below.

image

I believe I am explaining properly now and want to resolve this issue asap.

README not being updated with latest pull request changes

The last few pull requests:

  • labelSize prop
  • labelColor prop
  • labelRotate prop
  • Negative Bars feature

Did not include README changes to their pull requests to add the new features / props in the API docs.

(Adding issues so I may tackle them myself, for reference)

Related to #23

Prop label size should be allow for any unit, such as the more standard "rem" unit

em as a unit of measurement is a less modern "font size" unit of measurement. Many frameworks (such as the 4.0.0 bootstrap) try to use "rem" (root em) instead, which does a proportional size compared to a single root size (for use in scaling the UI of an app, usually in @media queries). Other applications might use em, or pt, or any other measurement.

I think an apt change would be to:

  1. Change the default to "0.7rem". Right now, 0.7em is quite large for any app that does both mobile and desktop.
  2. Allow the labelSize prop to accept a unit attached such as "12px", "12pt", "12em" (or a labelSizeUnit prop)

As with the other issue, might try and tackle this myself, making issue for reference.

Also, I'm not sure if this is a bug, but "labelSize" PR seemed to only edit files in dist/ not the files in src/ but I'm not sure if that is intentional or not.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

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.