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-pivot-table-plus

v0.7.1

Published

A customized vue component for pivot table

Downloads

203

Readme

vue-pivot-table-plus

A customized vue component for pivot table.

This project is modified based on vue-pivot-table to adjust its design to our products and add custom features described below.

vue-pivot-table screenshot

Customized features

  • Used v-model to bind row / column fields
    • And get these states reactively
  • Reset row / column fields
  • Download the current pivotted table in CSV / TSV
  • Sortable rows
  • Design updates
    • Shrinked buttons and table

Install

npm install --save vue-pivot-table-plus

Usage

The component Pivot has an aggregation table (referred to as PivotTable) from data & specific rows/columns.

Pivot has also a drag & drop user interface to configure rows/columns of a PivotTable.

You have to npm install bootstrap.

<!-- App.vue (template) -->
<template>
  <div id="app">
  ...

    <Pivot
      :data="data"
      v-model="fields"
      :reducer="reducer"
      :showSettings="defaultShowSettings"
      >
    </Pivot>
  ...

</template>
/* App.vue (js)*/
// Import the needed component(s)
import Vue from 'vue'
import { Pivot } from 'vue-pivot-table-plus'

export default Vue.extend({
  name: "app",
  components: { Pivot },
  data: () => {
    return {
      data: Object.freeze([{ x: 0, y: 0, z: 0 }, { x: 1, y: 1, z: 1 }]),
      fields: {
        availableFields: [],
        rowFields: [{
          getter: item => item.x,
          label: 'X-axis'
        }, {
          getter: item => item.y,
          label: 'Y-axis',
        }],
        colFields: [{
          getter: item => item.z,
          label: 'Z-axis'
        }],
        fieldsOrder: {}
      },
      reducer: (sum, item) => sum + 1,
      defaultShowSettings: true,
      tableHeight: '400px'
    }
  }
  ...
})
/* main.js */
import Vue from 'vue'
import 'bootstrap'
import 'bootstrap/dist/css/bootstrap.min.css'
import App from './App.vue'

new Vue({
  render: h => h(App)
}).$mount("#app")

API

Props

Prop | Type | Default | Description -----|------|---------|------------ data | Array | [] | Dataset to use in the pivot ; each element should be an object fields | Object (v-model) | {} | Information about pivot table. It includes available fields, row fields, column fields. You can receive the change of these information by watching this fields. Please consult the above example for usage. reducer | function | (sum, item) => sum + 1 | Function applied to reduce data in the pivot table tableHeight | Number | 500px | The height of table default-show-settings | Boolean | true | Show settings at component creation no-data-warning-text | String | 'No data to display.' | Text to display when data is empty is-data-loading | Boolean | false | Display a loading content instead of the table when the value is true (see slots for customization) available-fields-label-text | String | 'Available fields' | Text for available fields drag area rows-label-text | String | 'Rows' | Text for the rows drag area cols-label-text | String | 'Columns' | Text for the columns drag area hide-settings-text | String | 'Hide settings' | Text for the "hide settings" button show-settings-text | String | 'Show settings' | Text for the "show settings" button filename | String | (Determined by datetime) | Filename without extension for the downloading csv / tsv

Field format

Each element in the arrays fields, colFields or rowFields should be an Object with this format:

Prop | Type | Description -----|------|------------ label | String | Text to display in the draggable button (Pivot only) getter | Function | Function to apply on an element of data to get the field value sort | Function | Optional - Function to order fields in the pivot table header ; if no value is provided, javascript-natural-sort will be applied showHeader | Boolean | Optional (default: true) - Whether the header should be displayed in the pivot table showFooter | Boolean | Optional (default: false) - Whether the footer should be displayed in the pivot table headerSlotName | String | Optional - Name of the slot to use to format the header in the pivot table ; if no slot name is provided, the value will be displayed as found in data footerSlotName | String | Optional - Same as above for the footer

Large datasets

If this component is used with large datasets, consider applying Object.freeze on your data object to avoid useless change tracking on each data element.

See https://vuejs.org/v2/guide/instance.html#Data-and-Methods.

Build

# Install dependencies
npm install

# Serve with hot reload at localhost:8080
cd demo && npm run serve

# Build js libraries in dist folder
npm run build

Future features

  • Select enable / disable of each features (reset buttons, download button, and etc.)
  • More sophiscated design updates

Framework/Plugin

  • CSS
    • Bootstrap ^4.2.1
  • JavaScript
    • Vue ^2.6.10
    • jQuery ^3.3.1
    • VueDraggable ^2.21.0
    • BootstrapVue ^2.15.0

License

This software is released under the Apache License v2.0.

Copyright 2019 LINE Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.