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

@kong-ui-public/dashboard-renderer

v0.26.16

Published

Render Analytics charts on a page from a JSON definition.

Downloads

7,253

Readme

@kong-ui-public/dashboard-renderer

Render Analytics charts on a page from a JSON definition.

Requirements

  • vue must be initialized in the host application
  • A plugin providing an AnalyticsBridge must be installed in the root of the application.
    • This plugin must provide the necessary methods to adhere to the AnalyticsBridge interface defined in @kong-ui-public/analytics-utilities.
    • The plugin's query method is in charge of passing the query to the correct API for the host app's environment.
    • See the sandbox plugin sandbox-query-provider.ts for an example that simply returns static data rather than consuming an API.
  • The host application must supply peer dependencies for:
    • @kong-ui-public/analytics-chart
    • @kong-ui-public/analytics-utilities
    • @kong-ui-public/analytics-metric-provider
    • @kong-ui-public/i18n
    • @kong/kongponents
    • swrv
    • vue

Usage

Props

This component only takes two properties:

  • context : The time range that the dashboard should query and any additional filters that should be applied.
  • config : The dashboard config and layout.

For context filters and timeSpec see here.

If a timeSpec is not provided in the context object, the renderer will determine a default, which is currently 7 days.

Example

<DashboardRenderer
  :context="context"
  :config="config"
/>

with the following data:


import type { DashboardRendererContext, DashboardConfig } from '@kong-ui-public/dashboard-renderer'
import { DashboardRenderer, ChartTypes } from '@kong-ui-public/dashboard-renderer'

const context: DashboardRendererContext = {
  filters: [],
  timeSpec: {
    type: 'relative',
    time_range: '15M',
  },
}

const config: DashboardConfig = {
  // 4 x 1 grid
  gridSize: {
    cols: 4,
    rows: 1,
  },
  tiles: [
    {
      definition: {
        chart: {
          type: 'horizontal_bar',
        },
        // Request count by route
        query: {
          metrics: ['request_count'],
          dimensions: ['route']
        },
      },
      layout: {
        // Position at column 0, row 0
        position: {
          col: 0,
          row: 0,
        },
        // Spans 2 columns and 1 rows
        size: {
          col: 2,
          row: 1,
        }
      }
    },
    {
      definition: {
        chart: {
          type: 'top_n',
          chartTitle: 'Top N Table',
          description: 'Table description',
        },
        // Top 5 routes by request_count
        query: {
          metrics: ['request_count'],
          dimensions: ['route'],
          limit: 5,
        },
      },
      layout: {
        // Position at column 2, row 0
        position: {
          col: 2,
          row: 0,
        },
        // Spans 2 columns and 1 rows
        size: {
          col: 2,
          row: 1,
        }
      }
    },
  ],
}

Slotted content

<DashboardRenderer
  :context="context"
  :config="config"
>
  <!-- use the `id` set in the tile config for the slot name -->
  <template #slot-1>
    <div>
      <h3>Custom Slot</h3>
      <p>This is a slotted tile</p>
    </div>
  </template>
</DashboardRenderer>
import type { DashboardRendererContext, DashboardConfig } from '@kong-ui-public/dashboard-renderer'
import { DashboardRenderer, ChartTypes } from '@kong-ui-public/dashboard-renderer'

const context: DashboardRendererContext = {
  filters: [],
  timeSpec: {
    type: 'relative',
    time_range: '15M',
  },
}

const config: DashboardConfig = {
  // 4 x 1 grid
  gridSize: {
    cols: 4,
    rows: 1,
  },
  tiles: [
    {
      // Line chart
      definition: {
        chart: {
          type: 'timeseries_line',
        },
        // requests by status code over time
        query: {
          metrics: ['request_count'],
          dimensions: ['status_code', 'time']
        },
      },
      layout: {
        // Position at column 0, row 0
        position: {
          col: 0,
          row: 0,
        },
        // Spans 2 columns and 1 rows
        size: {
          col: 2,
          row: 1,
        }
      }
    },
    {
      // Slottable tile
      definition: {
        chart: {
          type: 'slottable',
          id: 'slot-1' // slot name
        },
        query: {},
      },
      layout: {
        // Position at column 2, row 0
        position: {
          col: 2,
          row: 0,
        },
        // Spans 2 columns and 1 rows
        size: {
          col: 2,
          row: 1,
        }
      }
    },
  ],
}

Auto-fit row content

This example will create a dynamically-sized row that fits to its content rather than being fixed at the configured row height. Note that this works because each chart is only rendered in 1 row; if a chart has fitToContent and layout.size.rows > 1, the fitToContent setting will be ignored.

Rendering AnalyticsChart components (e.g., horizontal bar, vertical bar, timeseries charts) with dynamic row heights may lead to undefined behavior. This option is best used with non-canvas charts (e.g., TopN charts).

import type { DashboardRendererContext, DashboardConfig } from '@kong-ui-public/dashboard-renderer'
import { DashboardRenderer, ChartTypes } from '@kong-ui-public/dashboard-renderer'

const context: DashboardRendererContext = {
  filters: [],
  timeSpec: {
    type: 'relative',
    time_range: '15M',
  },
}

const config: DashboardConfig = {
  // 4 x 1 grid
  gridSize: {
    cols: 4,
    rows: 1,
  },
  tiles: [
    {
      definition: {
        chart: {
          type: 'top_n',
          chartTitle: 'Top N chart of mock data',
          description: 'Description'
        },
        query: {},
      },
      layout: {
        position: {
          col: 0,
          row: 0,
        },
        size: {
          cols: 3,
          rows: 1,
          fitToContent: true,
        },
      },
    },
    {
      definition: {
        chart: {
          type: 'top_n',
          chartTitle: 'Top N chart of mock data',
          description: 'Description',
        },
        query: {},
      },
      layout: {
        position: {
          col: 3,
          row: 0,
        },
        size: {
          cols: 3,
          rows: 1,
          fitToContent: true,
        },
      },
    },
  ],
}