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

oibp-indicator

v0.0.4

Published

指标组件

Downloads

4

Readme

介绍

本组件用于展示指标或标签数据,组件包括以下三个区域:

  1. 标题区域:支持设置 0-20 个长度的标题;
  2. 功能区域:目前只支持“下钻”功能;
  3. 展示区域:展示所配置的指标或标签数据。

快速上手

1. 安装

npm i oibp-indicator

2. 在项目中引入

// main.js

import Vue from 'vue'

// 引入指标组件
import OibpIndicator from 'oibp-indicator'
Vue.component('oibp-indicator', OibpIndicator)

3. 在项目中使用

<template>
  <div class="home">
    <div class="indicator-container">
      <oibp-indicator :title="title" :show-drill-down="true" :indicator-list="indicatorList" @drillDown="handleDrillDown" />
    </div>
  </div>
</template>

<script>
const indicatorListData = [
  { key: '1', label: '指标1', value: '10000' }, { key: '2', label: '指标2', value: '20000', warning: true },
  { key: '3', label: '指标3', value: '300001223454999' }, { key: '4', label: '指标4', value: '400001223454888' },
  { key: '5', label: '指标5', value: '50000' }, { key: '6', label: '指标6', value: '60000' },
  { key: '5', label: '指标5', value: '50000' }, { key: '6', label: '指标6', value: '60000' },
]

export default {
  name: 'Home',
  data() {
    return {
      title: '',
      indicatorList: [],
    }
  },
  created () {
    setTimeout(() => {
      this.title = '组件标题'
      this.indicatorList = indicatorListData
    }, 2000)
  },
  methods: {
    handleDrillDown() {
      console.log('下钻')
    }
  }
}
</script>

<style scoped>
.home { background-color: #ddd; padding: 10px; }
.indicator-container { display: flex; overflow-x: auto; margin-top: 10px; }
.indicator-container > .oibpIndicator { margin-right: 10px; }
.indicator-container > .oibpIndicator:last-child { margin-right: 0; }
</style>

组件支持的属性及方法

| 属性/方法 | 描述 | 类型 | 默认值 | |-----------------|-----------|----------|--------| | title | 组件标题 | string | '' | | show-drill-down | 是否显示下钻功能 | boolean | true | | indicator-list | 指标数据 | array | [] | | drillDown | 点击下钻触发的方法 | function | |

1. indicator-list 数据结构示例

/**
 * key:指标的唯一标识
 * label:指标的名称
 * value:指标的值,最多展示十位字符,超出部分显示 ...
 * warning:指标是否需要预警,默认为 false,如果设置为 true,指标的值将会以另一种颜色展示
 */
const indicatorList = [
  { key: '1', label: '指标1', value: '10000' }, { key: '2', label: '指标2', value: '20000', warning: true },
  { key: '3', label: '指标3', value: '300001223454999' }, { key: '4', label: '指标4', value: '400001223454888' },
  { key: '5', label: '指标5', value: '50000' }, { key: '6', label: '指标6', value: '60000' },
  { key: '5', label: '指标5', value: '50000' }, { key: '6', label: '指标6', value: '60000' },
]

注意事项

  1. 本组件使用了 flex 布局,建议包裹组件的容器也开启 flex 布局。如:
<template>
  <div class="home">
    <div class="indicator-container">
      <oibp-indicator/>
    </div>
  </div>
</template>

<style scoped>
.indicator-container {
  display: flex;
}
</style>
  1. 本组件的主要用途是展示指标或标签数据,如果 indicator-list 属性没传,或者传的是空数组,那么整个组件将不会展示。