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-apexcharts-trendline

v1.0.1

Published

vue-apexcharts component for adding a trend line to your charts

Downloads

57

Readme

Vue Apexcharts Trendline

vue-apexcharts component for adding a trend line to your charts. This component uses linear regression to calculate the trend line.

Installation

Installing via npm

npm install vue-apexcharts-trendline

Properties

  • type:
    • The chart type used for the main series. See docs for more information.
    • default: 'area'
  • options:
    • The options to be used for the chart. See docs for more information.
    • default: (uses the ApexCharts defaults)
  • series:
    • The series to be used. docs for more information.
    • *required
    • format: [{name: ..., type: ..., data: ...}, ...], The type property is important for stacked charts.
  • trend-options:
    • Object containing various options used be the component.
    • properties:
      • text: The text string to append the the series name for the trend line series.
      • indices: The indices to be used for trend lines, if you don't want to use all the series.
      • series: An option to set a different series for creating the trend lines, if different from main series.
      • show: Determines if the trend lines should be shown or not.
      • tooltips: Determines whether or not to display tooltips of trend lines.
      • dataLabels: Determines whether or not to display dataLabels of trend lines.
      • combined: Determines whether or not to combine the series for the trend line. If not set and options.chart.stacked is true, then it will combine.
    • defaults:
      • text: 'Trend Line'
      • indices: undefined
      • series: undefined
      • show: true
      • tooltips: false
      • dataLabels: false
      • combined: undefined

Example

This is a basic example show how to us the component in a single file vue component.

<template>
   <div id="trend-line">
       <vue-apexcharts-trendline :type="type" :options="options" :series="series" :trend-options="trend_options"/>
   </div>
</template>

<script>
   import VueApexchartsTrendline from "vue-apexcharts-trendline";

   export default {
           name: 'ExampleChart',
           components: {
               VueApexchartsTrendline,
           },
           data() {
               return {
                   series: [{
                       name: 'series 1',
                       type: 'area',
                       data: [
                           {x: 0, y: 4},
                           {x: 1, y: 2},
                           {x: 2, y: 5},
                           {x: 3, y: 6},
                           {x: 4, y: 8},
                           {x: 5, y: 2},
                           {x: 6, y: 12},
                           {x: 7, y: 23},
                           {x: 8, y: 17},
                           {x: 9, y: 15},
                       ],
                   }, {
                       name: 'series 2',
                       type: 'area',
                       data: [
                           {x: 0, y: 2},
                           {x: 1, y: 5},
                           {x: 2, y: 10},
                           {x: 3, y: 16},
                           {x: 4, y: 6},
                           {x: 5, y: 8},
                           {x: 6, y: 6},
                           {x: 7, y: 4},
                           {x: 8, y: 13},
                           {x: 9, y: 11},
                       ],
                   }],
                   options: {
                       title: {
                           text: 'Example',
                           align: 'center',
                       },
                       chart: {
                           stacked: true,
                       },
                   },
                   type: 'line',
                   trend_options: {
                       indices: [0],
                       combined: false,
                   },
               };
           },
       };
</script>

Screenshot

Notes

  • When using stacked charts the component recalculates the "yaxis.max" value as the trend lines increase the value.
  • When using stacked charts with "{trend-options}.combined = false", the trend lines are also stacked.
  • The component also rounds all y axis labels with "Math.round()"