# Target line (`chartist-plugin-targetline`, Chartist plugin)

> Draws a horizontal line at a target value.

It places the line by the axis maximum, so the axis should start at zero.

- Author: Harry Twyford
- Source: https://github.com/htwyford/chartist-plugin-targetline, npm: https://www.npmjs.com/package/chartist-plugin-targetline
- License: ISC
- 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: 748 a month, last release 2017-08-11

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-targetline@1.0.1/chartist-plugin-targetline.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.ctTargetLine())]
  });
</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: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
    series: [[620, 780, 940, 1050, 990, 1210]]
  },
  {
    // The plugin places the line by the axis maximum, so start at zero.
    low: 0,
    plugins: [fromLegacyPlugin(plugins.ctTargetLine({ value: 1000 }))]
  }
);
```

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