Skip to content

Commit

Permalink
Bump version to 1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nagix committed May 10, 2021
1 parent 0792037 commit 3ce8c98
Show file tree
Hide file tree
Showing 21 changed files with 273 additions and 231 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 Akihiko Kusanagi
Copyright (c) 2021-2019 Akihiko Kusanagi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

*[Chart.js](https://www.chartjs.org) plugin for live streaming data*

Version 1.2 or earlier requires Chart.js 2.6.x. Version 1.3 or later requires Chart.js 2.7.x. Version 1.8 requires Chart.js 2.7.x or 2.8.x.
Version 1.9 requires Chart.js 2.7.x, 2.8.x or 2.9.x. If you need Chart.js 2.6.x support, use [version 1.2.0](https://github.com/nagix/chartjs-plugin-streaming/releases/tag/v1.2.0).

## Installation

Expand Down Expand Up @@ -35,9 +35,9 @@ To use CDN:

chartjs-plugin-streaming can be used with ES6 modules, plain JavaScript and module loaders.

chartjs-plugin-streaming requires [Moment.js](https://momentjs.com/) and [Chart.js](https://www.chartjs.org). If you are using Chart.js 2.8.0 or later, Moment.js can be replaced with [other date libraries and corresponding adapters](https://github.com/chartjs/awesome#adapters).
chartjs-plugin-streaming requires [Moment.js](https://momentjs.com/) and [Chart.js](https://www.chartjs.org). If you are using Chart.js 2.8.0 or later, [other date libraries and corresponding adapters](https://github.com/chartjs/awesome#adapters) can be used. Note that Moment.js is still required, though.

Version 1.8 supports the [line](https://www.chartjs.org/docs/latest/charts/line.html) and [bar](https://www.chartjs.org/docs/latest/charts/bar.html) chart types with both [Number data](https://www.chartjs.org/docs/latest/charts/line.html#number) and [Point data](https://www.chartjs.org/docs/latest/charts/line.html#point) (each data point is specified an array of objects containing x and y properties) as well as the [bubble](https://www.chartjs.org/docs/latest/charts/bubble.html) and [scatter](https://www.chartjs.org/docs/latest/charts/scatter.html) chart types with Point data. In case of Point data, either x or y must be in any of the date formats that the data library accepts ([date formats](https://momentjs.com/docs/#/parsing/) in case of Moment.js), and the corresponding axis must have a 'realtime' scale that has the same options as [time](https://www.chartjs.org/docs/latest/axes/cartesian/time.html) scale. Once the realtime scale is specified, the chart will auto-scroll along with that axis. Old data will be automatically deleted after the time specified by the `ttl` option, or as it disappears off the chart.
Version 1.9 supports the [line](https://www.chartjs.org/docs/latest/charts/line.html) and [bar](https://www.chartjs.org/docs/latest/charts/bar.html) chart types with both [Number data](https://www.chartjs.org/docs/latest/charts/line.html#number) and [Point data](https://www.chartjs.org/docs/latest/charts/line.html#point) (each data point is specified an array of objects containing x and y properties) as well as the [bubble](https://www.chartjs.org/docs/latest/charts/bubble.html) and [scatter](https://www.chartjs.org/docs/latest/charts/scatter.html) chart types with Point data. In case of Point data, either x or y must be in any of the date formats that the data library accepts ([date formats](https://momentjs.com/docs/#/parsing/) in case of Moment.js), and the corresponding axis must have a 'realtime' scale that has the same options as [time](https://www.chartjs.org/docs/latest/axes/cartesian/time.html) scale. Once the realtime scale is specified, the chart will auto-scroll along with that axis. Old data will be automatically deleted after the time specified by the `ttl` option, or as it disappears off the chart.

### Usage in ES6 as module

Expand Down
42 changes: 21 additions & 21 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<meta property="og:site_name" content="chartjs-plugin-streaming" />
<meta name="twitter:site" content="@nagix" />
<meta name="theme-color" content="#ffffff">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/moment@2.24.0/min/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.8.0"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/moment@2.29.1/min/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.9.0"></script>
</head>
<body>
<section id="hero-spot" class="hero-spot">
Expand Down Expand Up @@ -367,7 +367,7 @@ <h4>Create a new application</h4>

<li>
<h4>Install modules</h4>
<p>Install <a href="http://jerairrest.github.io/react-chartjs-2/">react-chartjs-2</a> and <a href="https://nagix.github.io/chartjs-plugin-streaming/">chartjs-plugin-streaming</a> into our project.</p>
<p>Install <a href="http://reactchartjs.github.io/react-chartjs-2/">react-chartjs-2</a> and <a href="https://nagix.github.io/chartjs-plugin-streaming/">chartjs-plugin-streaming</a> into our project.</p>
<div class="terminal">
<div class="header"></div>
<div class="shell">
Expand Down Expand Up @@ -417,7 +417,7 @@ <h4>Create a chart component</h4>

<li>
<h4>Stream data</h4>
<p>You can append the data in the callback function and add more chart options.<br />The browser refreshes and displays a live streaming chart.<br />See the Chart.js <a href="https://www.chartjs.org/docs">documentation</a>, <a href="https://www.chartjs.org/samples">samples</a> and react-chartjs-2 <a href="https://github.com/jerairrest/react-chartjs-2">documentation</a><br />for the customization options.</p>
<p>You can append the data in the callback function and add more chart options.<br />The browser refreshes and displays a live streaming chart.<br />See the Chart.js <a href="https://www.chartjs.org/docs">documentation</a>, <a href="https://www.chartjs.org/samples">samples</a> and react-chartjs-2 <a href="https://github.com/reactchartjs/react-chartjs-2">documentation</a><br />for the customization options.</p>
<div class="terminal">
<div class="header">src/App.js (Patial)</div>
<div class="shell">
Expand Down Expand Up @@ -626,34 +626,34 @@ <h4>...and you're done!</h4>
var ctx1 = document.getElementById('chart1').getContext('2d');
var chart1 = new Chart(ctx1, {
type: 'line',
data: { datasets: [{ data: [] }, { data: [] }] },
options: { scales: { xAxes: [{ type: 'realtime' }] } }
data: {datasets: [{data: []}, {data: []}]},
options: {scales: {xAxes: [{type: 'realtime'}]}}
});

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

var ctx3 = document.getElementById('chart3').getContext('2d');
var chart3 = new Chart(ctx3, {
type: 'line',
data: { datasets: [{ data: [] }, { data: [] }] },
options: { scales: { xAxes: [{
data: {datasets: [{data: []}, {data: []}]},
options: {scales: {xAxes: [{
type: 'realtime',
realtime: { onRefresh: onRefresh, delay: 2000 }
}] } }
realtime: {onRefresh: onRefresh, delay: 2000}
}]}}
});

var ctx4 = document.getElementById('chart4').getContext('2d');
var chart4 = new Chart(ctx4, {
type: 'line',
data: { datasets: [{
data: {datasets: [{
data: [],
label: 'Dataset 1',
borderColor: 'rgb(255, 99, 132)',
Expand All @@ -665,11 +665,11 @@ <h4>...and you're done!</h4>
label: 'Dataset 2',
borderColor: 'rgb(54, 162, 235)',
backgroundColor: 'rgba(54, 162, 235, 0.5)'
}] },
options: { scales: { xAxes: [{
}]},
options: {scales: {xAxes: [{
type: 'realtime',
realtime: { onRefresh: onRefresh, delay: 2000 }
}] } }
realtime: {onRefresh: onRefresh, delay: 2000}
}]}}
});
</script>
<script src="/js/jquery.js"></script>
Expand All @@ -684,7 +684,7 @@ <h4>...and you're done!</h4>
<img src="/favicon-32x32-glay.png" style="position: absolute; top: 34px; left: 50%; margin-left: -16px;">
</a>
<ul class="site-footer-links">
<li>&copy; 2019 Akihiko Kusanagi</li>
<li>&copy; 2017-2021 Akihiko Kusanagi</li>
</ul>
</footer>
<script>
Expand Down
42 changes: 21 additions & 21 deletions docs/ja/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<meta property="og:site_name" content="chartjs-plugin-streaming" />
<meta name="twitter:site" content="@nagix" />
<meta name="theme-color" content="#ffffff">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/moment@2.24.0/min/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.8.0"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/moment@2.29.1/min/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.9.0"></script>
</head>
<body>
<section id="hero-spot" class="hero-spot">
Expand Down Expand Up @@ -367,7 +367,7 @@ <h4>アプリケーションを新たに作成する</h4>

<li>
<h4>モジュールをインストールする</h4>
<p><a href="http://jerairrest.github.io/react-chartjs-2/">react-chartjs-2</a> および <a href="https://nagix.github.io/chartjs-plugin-streaming/">chartjs-plugin-streaming</a> をプロジェクトにインストールします。</p>
<p><a href="http://reactchartjs.github.io/react-chartjs-2/">react-chartjs-2</a> および <a href="https://nagix.github.io/chartjs-plugin-streaming/">chartjs-plugin-streaming</a> をプロジェクトにインストールします。</p>
<div class="terminal">
<div class="header"></div>
<div class="shell">
Expand Down Expand Up @@ -417,7 +417,7 @@ <h4>チャートを作成する</h4>

<li>
<h4>データを流し込む</h4>
<p>コールバック関数でデータを追加し、様々なチャートオプションを指定することができます。<br />ブラウザは自動更新され、ストリーミングチャートが表示されます。<br />カスタマイズのオプションについては Chart.js の<a href="https://www.chartjs.org/docs">ドキュメント</a><a href="https://www.chartjs.org/samples">サンプル</a><br />react-chartjs-2 の<a href="https://github.com/jerairrest/react-chartjs-2">ドキュメント</a>をご覧ください。</p>
<p>コールバック関数でデータを追加し、様々なチャートオプションを指定することができます。<br />ブラウザは自動更新され、ストリーミングチャートが表示されます。<br />カスタマイズのオプションについては Chart.js の<a href="https://www.chartjs.org/docs">ドキュメント</a><a href="https://www.chartjs.org/samples">サンプル</a><br />react-chartjs-2 の<a href="https://github.com/reactchartjs/react-chartjs-2">ドキュメント</a>をご覧ください。</p>
<div class="terminal">
<div class="header">src/App.js (一部)</div>
<div class="shell">
Expand Down Expand Up @@ -626,34 +626,34 @@ <h4>...これで完了です!</h4>
var ctx1 = document.getElementById('chart1').getContext('2d');
var chart1 = new Chart(ctx1, {
type: 'line',
data: { datasets: [{ data: [] }, { data: [] }] },
options: { scales: { xAxes: [{ type: 'realtime' }] } }
data: {datasets: [{data: []}, {data: []}]},
options: {scales: {xAxes: [{type: 'realtime'}]}}
});

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

var ctx3 = document.getElementById('chart3').getContext('2d');
var chart3 = new Chart(ctx3, {
type: 'line',
data: { datasets: [{ data: [] }, { data: [] }] },
options: { scales: { xAxes: [{
data: {datasets: [{data: []}, {data: []}]},
options: {scales: {xAxes: [{
type: 'realtime',
realtime: { onRefresh: onRefresh, delay: 2000 }
}] } }
realtime: {onRefresh: onRefresh, delay: 2000}
}]}}
});

var ctx4 = document.getElementById('chart4').getContext('2d');
var chart4 = new Chart(ctx4, {
type: 'line',
data: { datasets: [{
data: {datasets: [{
data: [],
label: 'Dataset 1',
borderColor: 'rgb(255, 99, 132)',
Expand All @@ -665,11 +665,11 @@ <h4>...これで完了です!</h4>
label: 'Dataset 2',
borderColor: 'rgb(54, 162, 235)',
backgroundColor: 'rgba(54, 162, 235, 0.5)'
}] },
options: { scales: { xAxes: [{
}]},
options:{scales: {xAxes: [{
type: 'realtime',
realtime: { onRefresh: onRefresh, delay: 2000 }
}] } }
realtime: {onRefresh: onRefresh, delay: 2000}
}]}}
});
</script>
<script src="/js/jquery.js"></script>
Expand All @@ -684,7 +684,7 @@ <h4>...これで完了です!</h4>
<img src="/favicon-32x32-glay.png" style="position: absolute; top: 34px; left: 50%; margin-left: -16px;">
</a>
<ul class="site-footer-links">
<li>&copy; 2019 Akihiko Kusanagi</li>
<li>&copy; 2017-2021 Akihiko Kusanagi</li>
</ul>
</footer>
<script>
Expand Down
54 changes: 37 additions & 17 deletions docs/samples/annotation.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

<head>
<title>chartjs-plugin-streaming sample</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.24.0/min/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.1/min/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/chartjs-plugin-annotation.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.8.0"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.9.0"></script>
<style>
canvas {
-moz-user-select: none;
Expand Down Expand Up @@ -62,12 +62,21 @@
}

function onRefresh(chart) {
var box = chart.options.annotation.annotations[1];
var now = Date.now();
chart.data.datasets.forEach(function(dataset) {
dataset.data.push({
x: Date.now(),
x: now,
y: randomScalingFactor()
});
});
if (!(box.xMax >= now - 22000)) {
box.xMin = now - 2000;
box.xMax = now + 8000;
box.yMin = randomScalingFactor();
box.yMax = randomScalingFactor();
chart.update({duration: 0});
}
}

var color = Chart.helpers.color;
Expand Down Expand Up @@ -145,11 +154,12 @@
{
drawTime: 'beforeDatasetsDraw',
type: 'box',
xScaleID: 'x-axis-0',
yScaleID: 'y-axis-0',
yMin: randomScalingFactor(),
yMax: randomScalingFactor(),
xMin: 0,
xMax: 0,
backgroundColor: color(chartColors.purple).alpha(0.25).rgbString(),
borderColor: color(chartColors.purple),
borderColor: chartColors.purple,
borderWidth: 1,
onClick: function(e) {
console.log('Box', e.type, this);
Expand Down Expand Up @@ -204,10 +214,10 @@
</div>
<div class="tab-pane fade" id="html" role="tabpanel" aria-labelledby="html-tab">
<pre class="prettyprint lang-html p-3 bg-light">&lt;head&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/moment@2.24.0/min/moment.min.js"&gt;&lt;/script&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"&gt;&lt;/script&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/moment@2.29.1/min/moment.min.js"&gt;&lt;/script&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4"&gt;&lt;/script&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/[email protected]/chartjs-plugin-annotation.min.js"&gt;&lt;/script&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.8.0"&gt;&lt;/script&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.9.0"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
Expand Down Expand Up @@ -240,12 +250,21 @@
}

function onRefresh(chart) {
var box = chart.options.annotation.annotations[1];
var now = Date.now();
chart.data.datasets.forEach(function(dataset) {
dataset.data.push({
x: Date.now(),
x: now,
y: randomScalingFactor()
});
});
if (!(box.xMax >= now - 22000)) {
box.xMin = now - 2000;
box.xMax = now + 8000;
box.yMin = randomScalingFactor();
box.yMax = randomScalingFactor();
chart.update({duration: 0});
}
}

var color = Chart.helpers.color;
Expand Down Expand Up @@ -323,11 +342,12 @@
{
drawTime: 'beforeDatasetsDraw',
type: 'box',
xScaleID: 'x-axis-0',
yScaleID: 'y-axis-0',
yMin: randomScalingFactor(),
yMax: randomScalingFactor(),
xMin: 0,
xMax: 0,
backgroundColor: color(chartColors.purple).alpha(0.25).rgbString(),
borderColor: color(chartColors.purple),
borderColor: chartColors.purple,
borderWidth: 1,
onClick: function(e) {
console.log('Box', e.type, this);
Expand Down
Loading

0 comments on commit 3ce8c98

Please sign in to comment.