Convert Figma logo to code with AI

joewalnes logosmoothie

Smoothie Charts: smooooooth JavaScript charts for realtime streaming data

2,245
232
2,245
28

Top Related Projects

64,568

Simple HTML5 Charts using the <canvas> tag

16,856

Open-source JavaScript charting library behind Plotly and Dash

108,427

Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:

Highcharts JS, the JavaScript charting framework

Quick Overview

Smoothie Charts is a lightweight JavaScript charting library designed for live, streaming data. It provides a simple way to create smooth, animated charts that update in real-time, making it ideal for visualizing time-series data, system monitoring, and other dynamic data sources.

Pros

  • Lightweight and fast, with minimal dependencies
  • Specifically optimized for live, streaming data
  • Easy to use and integrate into web applications
  • Supports multiple chart types and customization options

Cons

  • Limited to time-series data visualization
  • Not as feature-rich as some larger charting libraries
  • Documentation could be more comprehensive
  • Less active development in recent years

Code Examples

  1. Creating a basic line chart:
var chart = new SmoothieChart();
var canvas = document.getElementById('myChart');
chart.streamTo(canvas, 1000);

var line1 = new TimeSeries();
setInterval(function() {
  line1.append(new Date().getTime(), Math.random());
}, 1000);

chart.addTimeSeries(line1);
  1. Adding multiple series to a chart:
var chart = new SmoothieChart();
var canvas = document.getElementById('myChart');
chart.streamTo(canvas, 1000);

var line1 = new TimeSeries();
var line2 = new TimeSeries();

setInterval(function() {
  line1.append(new Date().getTime(), Math.random());
  line2.append(new Date().getTime(), Math.random());
}, 1000);

chart.addTimeSeries(line1, {strokeStyle: 'rgba(0, 255, 0, 1)', lineWidth: 2});
chart.addTimeSeries(line2, {strokeStyle: 'rgba(255, 0, 0, 1)', lineWidth: 2});
  1. Customizing chart options:
var chart = new SmoothieChart({
  millisPerPixel: 50,
  grid: {
    strokeStyle: '#555555',
    fillStyle: '#444444',
    lineWidth: 1,
    millisPerLine: 1000,
    verticalSections: 4
  },
  labels: {
    fillStyle: '#ffffff'
  }
});

Getting Started

  1. Include the Smoothie Charts library in your HTML:
<script src="https://cdnjs.cloudflare.com/ajax/libs/smoothie/1.34.0/smoothie.min.js"></script>
  1. Create a canvas element in your HTML:
<canvas id="myChart" width="400" height="200"></canvas>
  1. Initialize the chart and add data:
var chart = new SmoothieChart();
var canvas = document.getElementById('myChart');
chart.streamTo(canvas, 1000);

var line = new TimeSeries();
setInterval(function() {
  line.append(new Date().getTime(), Math.random());
}, 1000);

chart.addTimeSeries(line);

This will create a basic live-updating chart with random data. Customize the chart and data sources as needed for your specific use case.

Competitor Comparisons

64,568

Simple HTML5 Charts using the <canvas> tag

Pros of Chart.js

  • More comprehensive and feature-rich, offering a wide variety of chart types
  • Extensive documentation and large community support
  • Responsive and mobile-friendly by default

Cons of Chart.js

  • Larger file size, which may impact page load times
  • Steeper learning curve due to more complex API and configuration options
  • May be overkill for simple, real-time data visualization needs

Code Comparison

Smoothie example:

var chart = new SmoothieChart();
var canvas = document.getElementById('mycanvas');
chart.addTimeSeries(dataSeries, { strokeStyle: 'rgba(0, 255, 0, 1)', fillStyle: 'rgba(0, 255, 0, 0.2)', lineWidth: 4 });
chart.streamTo(canvas, 500);

Chart.js example:

var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
    type: 'line',
    data: { datasets: [{ data: [] }] },
    options: { scales: { xAxes: [{ type: 'realtime' }] } }
});

Smoothie is focused on real-time, streaming data visualization with a simpler API, while Chart.js offers a more comprehensive charting solution with various chart types and customization options. Smoothie is lighter and easier to set up for real-time data, whereas Chart.js provides more flexibility and features at the cost of increased complexity and file size.

16,856

Open-source JavaScript charting library behind Plotly and Dash

Pros of Plotly.js

  • More comprehensive and feature-rich, offering a wide range of chart types and customization options
  • Better support for interactive and responsive visualizations
  • Larger community and more frequent updates

Cons of Plotly.js

  • Larger file size and potentially slower performance for simple real-time charts
  • Steeper learning curve due to its extensive API and options
  • May be overkill for basic streaming data visualization needs

Code Comparison

Smoothie:

var chart = new SmoothieChart();
var canvas = document.getElementById('mycanvas');
chart.addTimeSeries(myTimeSeries);
chart.streamTo(canvas, 1000);

Plotly.js:

Plotly.newPlot('myDiv', [{
  y: [1, 2, 3].map(Math.random),
  type: 'line'
}]);

setInterval(function() {
  Plotly.extendTraces('myDiv', { y: [[Math.random()]] }, [0]);
}, 1000);

Both libraries allow for real-time data visualization, but Plotly.js offers more complex chart types and customization at the cost of a more verbose setup. Smoothie is more straightforward for simple streaming charts, while Plotly.js provides a broader range of visualization options and interactivity.

108,427

Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:

Pros of D3

  • More comprehensive and versatile for data visualization
  • Larger community and ecosystem with extensive documentation
  • Supports a wide range of chart types and complex visualizations

Cons of D3

  • Steeper learning curve due to its extensive API
  • Heavier library size, which may impact page load times
  • Requires more code for simple visualizations

Code Comparison

Smoothie (creating a time series chart):

var chart = new SmoothieChart();
var canvas = document.getElementById('mycanvas');
chart.addTimeSeries(dataSeries);
chart.streamTo(canvas, 1000);

D3 (creating a simple line chart):

var svg = d3.select("svg");
var line = d3.line().x(d => x(d.date)).y(d => y(d.value));
svg.append("path")
    .datum(data)
    .attr("d", line);

Summary

Smoothie is focused on real-time streaming data visualization, making it simpler for specific use cases. D3 offers a more powerful and flexible toolkit for creating various types of data visualizations but requires more setup and knowledge to use effectively. Choose Smoothie for quick, real-time charts, and D3 for more complex or diverse visualization needs.

Highcharts JS, the JavaScript charting framework

Pros of Highcharts

  • More comprehensive and feature-rich, offering a wide variety of chart types
  • Extensive documentation and community support
  • Better suited for complex, interactive visualizations

Cons of Highcharts

  • Larger file size and potentially slower performance for simple charts
  • Commercial license required for most use cases
  • Steeper learning curve due to more extensive API

Code Comparison

Smoothie (creating a simple time series chart):

var chart = new SmoothieChart();
var canvas = document.getElementById('mycanvas');
chart.streamTo(canvas, 1000);

var line1 = new TimeSeries();
setInterval(function() {
  line1.append(new Date().getTime(), Math.random());
}, 1000);
chart.addTimeSeries(line1);

Highcharts (creating a simple time series chart):

Highcharts.chart('container', {
  series: [{
    data: (function() {
      var data = [], time = (new Date()).getTime(), i;
      for (i = -19; i <= 0; i += 1) {
        data.push([time + i * 1000, Math.random()]);
      }
      return data;
    }())
  }]
});

Summary

Smoothie is lightweight and focused on real-time streaming charts, making it ideal for simple, performance-critical applications. Highcharts offers a more comprehensive charting solution with a wider range of chart types and customization options, but comes with a larger footprint and commercial licensing requirements.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

npm version

Smoothie Charts is a really small charting library designed for live streaming data. I built it to reduce the headaches I was getting from watching charts jerkily updating every second.

See http://smoothiecharts.org


Getting Started


Example

Given a <canvas>:

<canvas id="chart" width="400" height="100"></canvas>

Create a time series and chart with code resembling:

// Create a time series
var series = new TimeSeries();

// Find the canvas
var canvas = document.getElementById('chart');

// Create the chart
var chart = new SmoothieChart();
chart.addTimeSeries(series, { strokeStyle: 'rgba(0, 255, 0, 1)' });
chart.streamTo(canvas, 500);

Then, add data to your time series and it will be displayed on the chart:

// Randomly add a data point every 500ms
setInterval(function() {
    series.append(Date.now(), Math.random() * 10000);
}, 500);

Questions

For help, use the Smoothie Charts Google Group.


License (MIT)

NPM DownloadsLast 30 Days