All Projects β†’ himynameisdave β†’ Svelte Frappe Charts

himynameisdave / Svelte Frappe Charts

Licence: mit
πŸ“ˆ Svelte bindings for frappe-charts.

Projects that are alternatives of or similar to Svelte Frappe Charts

Anychart
AnyChart is a lightweight and robust JavaScript charting solution with great API and documentation. The chart types and unique features are numerous, the library works easily with any development stack.
Stars: ✭ 288 (+159.46%)
Mutual labels:  charts, charting-library
Echarts
Apache ECharts is a powerful, interactive charting and data visualization library for browser
Stars: ✭ 49,119 (+44151.35%)
Mutual labels:  charts, charting-library
Lightweight Charts
Financial lightweight charts built with HTML5 canvas
Stars: ✭ 4,390 (+3854.95%)
Mutual labels:  charts, charting-library
Devextreme
HTML5 JavaScript Component Suite for Responsive Web Development
Stars: ✭ 1,385 (+1147.75%)
Mutual labels:  charts, charting-library
Lavacharts
Lavacharts is a graphing / charting library for PHP 5.4+ that wraps Google's Javascript Chart API.
Stars: ✭ 587 (+428.83%)
Mutual labels:  charts, charting-library
Plotly.swift
Interactive data visualization library for Swift
Stars: ✭ 70 (-36.94%)
Mutual labels:  charts, charting-library
React Jsx Highcharts
Highcharts built with proper React components
Stars: ✭ 336 (+202.7%)
Mutual labels:  charts, charting-library
gauge-chart
Gauge Chart Library
Stars: ✭ 45 (-59.46%)
Mutual labels:  charts, charting-library
Reactochart
πŸ“ˆ React chart component library πŸ“‰
Stars: ✭ 459 (+313.51%)
Mutual labels:  charts, charting-library
Flutter echarts
A Flutter widget to use Apache ECharts (incubating) in a reactive way.
Stars: ✭ 420 (+278.38%)
Mutual labels:  charts, charting-library
svg-time-series
SVG time-series charting library
Stars: ✭ 18 (-83.78%)
Mutual labels:  charts, charting-library
Amcharts4
The most advanced amCharts charting library for JavaScript and TypeScript apps.
Stars: ✭ 907 (+717.12%)
Mutual labels:  charts, charting-library
HCLineChartView
HCLineChartView is a beautiful iOS library for drawing line charts. It is highly customizable and easy to use.
Stars: ✭ 22 (-80.18%)
Mutual labels:  charts, charting-library
ux-charts
Simple, responsive, modern Charts with zero dependencies
Stars: ✭ 22 (-80.18%)
Mutual labels:  charts, charting-library
ipychart
The power of Chart.js with Python
Stars: ✭ 48 (-56.76%)
Mutual labels:  charts, charting-library
Fcharts
πŸ“Š [wip] Create beautiful, responsive, animated charts using a simple and intuitive API.
Stars: ✭ 318 (+186.49%)
Mutual labels:  charts, charting-library
Angular Chartist.js
Angular directive for Chartist.js
Stars: ✭ 206 (+85.59%)
Mutual labels:  charts, charting-library
Keen Dataviz.js
Data Visualization Charting Library
Stars: ✭ 215 (+93.69%)
Mutual labels:  charts, charting-library
React Chartjs 2
React components for Chart.js, the most popular charting library
Stars: ✭ 4,667 (+4104.5%)
Mutual labels:  charts, charting-library
Chartkick.py
Create beautiful Javascript charts with minimal code
Stars: ✭ 695 (+526.13%)
Mutual labels:  charts, charting-library

svelte-frappe-charts

πŸ“ˆ Svelte bindings for frappe-charts.


Makes it easy to use frappe-charts in your Svelte project.

Installation

yarn add svelte svelte-frappe-charts

npm i -S svelte svelte-frappe-charts

Note: Assumes you are using >= [email protected].

Usage

Use the chart in your Svelte project with ease:

<script>
  import Chart from 'svelte-frappe-charts';

  let data = {
    labels: ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat'],
    datasets: [
      {
        values: [10, 12, 3, 9, 8, 15, 9]
      }
    ]
  };
</script>

<Chart data={data} type="line" />

The component API directly matches the the configuration of frappe-charts.

Updating data

There are two ways to update data in a chart: either in adding and removing individual points, or updating the existing data with an entirely new set of data points.

Updating individual data points

addDataPoint

Add a data point to the chart, increasing the length of the dataset.

<script>
  import Chart from 'svelte-frappe-charts';

  let data = {
    labels: ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat'],
    datasets: [
      {
        values: [10, 12, 3, 9, 8, 15, 9]
      }
    ]
  };

  let chartRef;

  function addDataPoint() {
    chartRef.addDataPoint('Wed', [30], 1);
  }
</script>

<Chart data={data} type="line" bind:this={chartRef} />

<button on:click={addDataPoint}>Add data point</button>

More info on addDataPoint.

removeDataPoint

Remove a data point from the chart, reducing the length of the dataset.

<script>
  import Chart from 'svelte-frappe-charts';

  let data = {
    labels: ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat'],
    datasets: [
      {
        values: [10, 12, 3, 9, 8, 15, 9]
      }
    ]
  };

  let chartRef;

  function removeDataPoint() {
    chartRef.removeDataPoint(3); // Index of the item to remove
  }
</script>

<Chart data={data} type="line" bind:this={chartRef} />

<button on:click={removeDataPoint}>Remove data point</button>

More info on removeDataPoint.

Updating full data

Update the entire data, including annotations, by passing the entire new data object to update.

<script>
  import Chart from 'svelte-frappe-charts';

  let data = {
    labels: ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat'],
    datasets: [
      {
        values: [10, 12, 3, 9, 8, 15, 9]
      }
    ]
  };

  let chartRef;

  function updateData() {
    data = {
      labels: ['Friday', 'Saturday', 'Sunday'],
      datasets: [
        {
          values: [300, 380, 275]
        }
      ]
    };
  }
</script>

<Chart data={data} type="line" bind:this={chartRef} />

<button on:click={updateData}>Update Chart</button>

Chart navigation

Chart navigation can be used when the isNavigable prop is set on the Chart component. Once it is set, the data-select event is propagated and can be handled in Svelte's standard ways (see the Events section of the tutorial and examples, and the API docs).

<script>
	import Chart from "svelte-frappe-charts";

	let data = {
		labels: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Mon" ],
		datasets: [
			{ values: [ 300, 250, 720, 560, 370, 610, 690, 410, 370, 480, 620, 260, 170, 510, 630, 710 ] },
		],
	};

	const onDataSelect = (event) => {
		console.log("Data select event fired!", event);
		selected = event;
	};
	let selected;
</script>

<h1>Svelte Frappe charts navigation demo</h1>
<Chart {data} on:data-select={onDataSelect} isNavigable type="bar" />

Exporting charts

You can easily export a chart (see Exporting) as an SVG by storing a reference to the <Chart /> component, and then calling exportChart on it:

<script>
  // ...

  let chartRef;
  const onExport = () => chartRef.exportChart();
</script>

<Chart data={data} type="line" bind:this={chartRef} />
<button on:click={onExport}>
  Export
</button>

Contributing

Issues and pull requests are greatly welcome!


✌️Created by Dave. Licenced under MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].