# Threshold (`chartist-plugin-threshold`, Chartist plugin)

> Splits lines and bars at a value and gives the parts above and below their own classes to style.

- Author: Gion Kunz
- Source: https://github.com/gionkunz/chartist-plugin-threshold, npm: https://www.npmjs.com/package/chartist-plugin-threshold
- License: WTFPL
- Written for the Chartist 0.x API; runs on v2 with `chartist/compat` (a script that reads the global `Chartist`, for backwards compatibility)
- Charts: line, bar
- Server rendering: no, it needs a browser
- Downloads: 1441 a month, last release 2015-11-18

Setup:

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/chartist@2.0.0-rc.2/dist/index.min.css">
<script type="module">
  import 'https://cdn.jsdelivr.net/npm/chartist@2.0.0-rc.2/dist/compat.min.js';
</script>
<script defer src="https://cdn.jsdelivr.net/npm/chartist-plugin-threshold@0.0.2/dist/chartist-plugin-threshold.js"></script>
<script type="module">
  import { lineChart } from 'https://cdn.jsdelivr.net/npm/chartist@2.0.0-rc.2/dist/index.min.js';
  import { fromLegacyPlugin } from 'https://cdn.jsdelivr.net/npm/chartist@2.0.0-rc.2/dist/compat.min.js';

  lineChart('#chart', data, {
    plugins: [fromLegacyPlugin(Chartist.plugins.ctThreshold())]
  });
</script>
```

Example (`src/main.ts`):

```ts
import 'chartist/styles.css';
import './style.css';
import { lineChart } from 'chartist';
import { fromLegacyPlugin } from 'chartist/compat';

// Plugin scripts register on the global `Chartist`.
const { plugins } = Chartist;

lineChart(
  '#chart',
  {
    labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    series: [[2, 5, 3, 7, 4, 8, 6]]
  },
  {
    showArea: true,
    plugins: [fromLegacyPlugin(plugins.ctThreshold({ threshold: 4 }))]
  }
);
```

All plugins: https://chartist.dev/plugins.md
