uplot 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +57 -0
- data/Rakefile +32 -0
- data/lib/uplot.rb +5 -0
- data/lib/uplot/engine.rb +4 -0
- data/lib/uplot/version.rb +3 -0
- data/vendor/assets/javascripts/uPlot.iife.min.js +2 -0
- data/vendor/assets/stylesheets/uPlot.min.css +1 -0
- metadata +87 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d2bcd1a6935cfd9a74d528746832b043fb34babba58da0464e57ee9ebbf8e742
|
|
4
|
+
data.tar.gz: ae2cc933bb8a0ae9a87aae47f131bd58f9088b18cb133baf9fcab1052ec4cf9a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 70d8e81a2179129dc5f4b4cc32ba12e2d90fb77e26685befae6c08aaf181fbfedb493755dd695a6e2832c20abff92eceeab072912e9ddcb50a773954542aa66f
|
|
7
|
+
data.tar.gz: 14f99b470277fa38d2f86a6cb79eaa2b9ca96afbd8792fa7b0bb4f9bda34d3c7eeb016de598e7542a97c19da673e434267fe4f0702674ff87871fa3169eecb7d
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2020 gscho
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# uPlot Ruby Gem
|
|
2
|
+
This gem is a rails engine to include [uPlot](https://github.com/leeoniya/uPlot) in your rails application.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
Add this line to your application's Gemfile:
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
gem 'uplot'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
```bash
|
|
13
|
+
$ bundle
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
```bash
|
|
18
|
+
$ gem install uplot
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
To use uPlot in your rails asset pipeline, you'll need to do the following:
|
|
23
|
+
|
|
24
|
+
In `app/assets/javascripts/application.js` add
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
//= require uPlot.iife.min
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
In `app/assets/stylesheets/application.css` add
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
*= require uPlot.min
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
See the dummy rails app in the test directory for an example of this.
|
|
37
|
+
|
|
38
|
+
### Waiting for the DOM
|
|
39
|
+
|
|
40
|
+
If using turbolinks:
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
document.addEventListener('turbolinks:load', function(){
|
|
44
|
+
// uPlot code here
|
|
45
|
+
}, false);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If not using turbolinks:
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
document.addEventListener("DOMContentLoaded", function() {
|
|
52
|
+
// uPlot code here
|
|
53
|
+
}, false);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'Uplot'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
load 'rails/tasks/statistics.rake'
|
|
21
|
+
|
|
22
|
+
require 'bundler/gem_tasks'
|
|
23
|
+
|
|
24
|
+
require 'rake/testtask'
|
|
25
|
+
|
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
|
27
|
+
t.libs << 'test'
|
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
|
29
|
+
t.verbose = false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
task default: :test
|
data/lib/uplot.rb
ADDED
data/lib/uplot/engine.rb
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! https://github.com/leeoniya/uPlot (v1.0.8) */
|
|
2
|
+
var uPlot=function(){"use strict";function n(n,t,e,r){var i;e=e||0;for(var a=2147483647>=(r=r||t.length-1);r-e>1;)n>t[i=a?e+r>>1:o((e+r)/2)]?e=i:r=i;return n-t[e]>t[r]-n?r:e}function t(n,t,e,i){var a=t-n,l=f(a||r(t)||1),u=o(l),c=s(10,u)*e,v=0==a?c:0,h=x(function(n,t){return o(n/t)*t}(n-v,c)),m=x(d(t+v,c));return i&&(0==a?t>0?(h=0,m=2*t):0>t&&(m=0,h=2*n):(c>m-t&&(m+=c),c>n-h&&(h-=c),n>=0&&0>h&&(h=0),0>=t&&m>0&&(m=0))),[h,m]}var e=Math,r=e.abs,o=e.floor,i=e.round,a=e.ceil,l=e.min,u=e.max,s=e.pow,f=e.log10,c=e.PI;function v(n,t){return i(n/t)*t}function h(n,t,e){return l(u(n,t),e)}function m(n){return"function"==typeof n?n:function(){return n}}function p(n,t){return t}function d(n,t){return a(n/t)*t}function g(n){return i(1e3*n)/1e3}function x(n){return i(1e6*n)/1e6}var w=Array.isArray;function b(n){return"object"==typeof n&&null!==n}function y(n){var t;if(w(n))t=n.map(y);else if(b(n))for(var e in t={},n)t[e]=y(n[e]);else t=n;return t}function M(n){for(var t=arguments,e=1;t.length>e;e++){var r=t[e];for(var o in r)b(n[o])?M(n[o],y(r[o])):n[o]=y(r[o])}return n}var k="width",S="height",Y="left",D=requestAnimationFrame,E=document,T=window,W=devicePixelRatio;function z(n,t){null!=t&&n.classList.add(t)}function F(n,t,e){n.style[t]=e+"px"}function A(n,t,e,r){var o=E.createElement(n);return null!=t&&z(o,t),null!=e&&e.insertBefore(o,r),o}function C(n,t){return A("div",n,t)}function _(n,t,e){n.style.transform="translate("+t+"px,"+e+"px)"}var H={passive:!0};function P(n,t,e){t.addEventListener(n,e,H)}function N(n,t,e){t.removeEventListener(n,e,H)}var L=["January","February","March","April","May","June","July","August","September","October","November","December"],B=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function I(n){return n.slice(0,3)}var R=B.map(I),j=L.map(I),G={MMMM:L,MMM:j,WWWW:B,WWW:R};function J(n){return(10>n?"0":"")+n}var U={YYYY:function(n){return n.getFullYear()},YY:function(n){return(n.getFullYear()+"").slice(2)},MMMM:function(n,t){return t.MMMM[n.getMonth()]},MMM:function(n,t){return t.MMM[n.getMonth()]},MM:function(n){return J(n.getMonth()+1)},M:function(n){return n.getMonth()+1},DD:function(n){return J(n.getDate())},D:function(n){return n.getDate()},WWWW:function(n,t){return t.WWWW[n.getDay()]},WWW:function(n,t){return t.WWW[n.getDay()]},HH:function(n){return J(n.getHours())},H:function(n){return n.getHours()},h:function(n){var t=n.getHours();return 0==t?12:t>12?t-12:t},AA:function(n){return 12>n.getHours()?"AM":"PM"},aa:function(n){return 12>n.getHours()?"am":"pm"},a:function(n){return 12>n.getHours()?"a":"p"},mm:function(n){return J(n.getMinutes())},m:function(n){return n.getMinutes()},ss:function(n){return J(n.getSeconds())},s:function(n){return n.getSeconds()},fff:function(n){return function(n){return(10>n?"00":100>n?"0":"")+n}(n.getMilliseconds())}};function V(n,t){t=t||G;for(var e,r=[],o=/\{([a-z]+)\}|[^{]+/gi;e=o.exec(n);)r.push("{"==e[0][0]?U[e[1]]:e[0]);return function(n){for(var e="",o=0;r.length>o;o++)e+="string"==typeof r[o]?r[o]:r[o](n,t);return e}}function O(n,t,e){for(var o=[],i=n;t>i;i++)for(var a=0;e.length>a;a++){var l=e[a]*s(10,i);o.push(+l.toFixed(r(i)))}return o}var q=[1,2,5],X=O(-12,0,q),Z=O(0,12,q),K=X.concat(Z),Q=3600,$=86400,nn=30*$,tn=365*$,en=[5e-4].concat(O(-3,0,q),[1,5,10,15,30,60,300,600,900,1800,Q,7200,3*Q,4*Q,6*Q,8*Q,43200,$,2*$,3*$,4*$,5*$,6*$,7*$,8*$,9*$,10*$,15*$,nn,2*nn,3*nn,4*nn,6*nn,tn,2*tn,5*tn,10*tn,25*tn,50*tn,100*tn]);function rn(n,t){return n.map((function(n){return[n[0],t(n[1]),n[2],t(n[4]?n[1]+n[3]:n[3])]}))}var on="{M}/{D}",an="\n"+on,ln="{h}:{mm}{aa}",un=[[tn,"{YYYY}",7,"",1],[28*$,"{MMM}",7,"\n{YYYY}",1],[$,on,7,"\n{YYYY}",1],[Q,"{h}{aa}",4,an,1],[60,ln,4,an,1],[1,":{ss}",2,an+" "+ln,1],[.001,":{ss}.{fff}",2,an+" "+ln,1]];function sn(n,t){return function(e,r,o,i){var a=t.find((function(n){return i>=n[0]})),l=null,u=null,s=null;return r.map((function(t){var e=n(t),r=e.getFullYear(),o=e.getDate(),i=e.getMinutes(),f=r!=l,c=o!=u,v=i!=s;return l=r,u=o,s=i,(7==a[2]&&f||4==a[2]&&c||2==a[2]&&v?a[3]:a[1])(e)}))}}function fn(n,t,e){return new Date(n,t,e)}function cn(n,t){return t(n)}function vn(n,t){return function(e,r){return t(n(r))}}var hn={show:!0,x:!0,y:!0,lock:!1,points:{show:function(n,t){var e=n.series[t],r=C();r.style.background=e.stroke||"#000";var o=Yn(e.width,1),i=(o-1)/-2;return F(r,k,o),F(r,S,o),F(r,"marginLeft",i),F(r,"marginTop",i),r}},drag:{setScale:!0,x:!0,y:!1},focus:{prox:-1},locked:!1,left:-10,top:-10,idx:null},mn={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},pn=M({},mn,{size:10}),dn='12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',gn="bold "+dn,xn={type:"x",show:!0,scale:"x",space:50,gap:5,size:50,labelSize:30,labelFont:gn,side:2,grid:mn,ticks:pn,font:dn,rotate:0},wn={show:!0,scale:"x",min:1/0,max:-1/0,idxs:[]},bn=new Intl.NumberFormat(navigator.language);function yn(n,t){return t.map(bn.format)}function Mn(n,t,e,r,o,i){for(var a=[],l=t=i?t:+d(t,r).toFixed(12);e>=l;l=+(l+r).toFixed(12))a.push(l);return a}function kn(n,t){return t}var Sn={type:"y",show:!0,scale:"y",space:40,gap:5,size:50,labelSize:30,labelFont:gn,side:3,grid:mn,ticks:pn,font:dn,rotate:0};function Yn(n,t){return u(g(5*t),2*g(n*t)-1)}var Dn={scale:"y",show:!0,band:!1,alpha:1,points:{show:function(n,t){var e=Yn(n.series[t].width,W),r=n.series[0].idxs;return n.bbox.width/e/2>=r[1]-r[0]}},values:null,min:1/0,max:-1/0,idxs:[],path:null,clip:null},En={time:!0,auto:!1,distr:1,min:1/0,max:-1/0},Tn=M({},En,{time:!1,auto:!0}),Wn={};function zn(){var n=[];return{sub:function(t){n.push(t)},unsub:function(t){n=n.filter((function(n){return n!=t}))},pub:function(t,e,r,o,i,a,l){n.length>1&&n.forEach((function(n){n!=e&&n.pub(t,e,r,o,i,a,l)}))}}}function Fn(n,t,e){return[n[0],n[1]].concat(n.slice(2)).map((function(n,r){return An(n,r,t,e)}))}function An(n,t,e,r){return M({},0==t||n&&n.side%2==0?e:r,n)}function Cn(n,t,e,r){return r+(1-(n-t.min)/(t.max-t.min))*e}function _n(n,t,e,r){return r+(n-t.min)/(t.max-t.min)*e}function Hn(n,t,e){return[t,e>t?e:e+86400]}function Pn(n,t,e){var i=e-t;if(0==i){var a=f(i||r(e)||1),l=o(a)+1;return[t,d(e,s(10,l))]}return[t,e]}function Nn(n,e,r){return t(e,r,.2,!0)}function Ln(n){return 0==n.button}function Bn(n){var t;return[n=n.replace(/\d+/,(function(n){return t=i(n*W)})),t]}function In(t,e,a){var s={},f=s.root=C("uplot");null!=t.id&&(f.id=t.id),z(f,t.class),t.title&&(C("title",f).textContent=t.title);var b=A("canvas"),H=s.ctx=b.getContext("2d"),L=C("wrap",f),B=C("under",L);L.appendChild(b);var I=C("over",L);((t=y(t)).plugins||[]).forEach((function(n){n.opts&&(t=n.opts(s,t)||t)}));var R=!1,j=Fn(t.series,wn,Dn),G=Fn(t.axes||[],xn,Sn),J=t.scales=t.scales||{},U=M({x:i(Sn.size/2),y:i(xn.size/3)},t.gutters),O=t.tzDate||function(n){return new Date(1e3*n)},q=t.fmtDate||V,X=function(n){return function(t,e,r,i,a){var l=[],u=i>=nn&&tn>i,s=n(e),f=s/1e3,c=fn(s.getFullYear(),s.getMonth(),u?1:s.getDate()),v=c/1e3;if(u)for(var h=i/nn,m=f==v?f:fn(c.getFullYear(),c.getMonth()+h,1)/1e3,p=new Date(1e3*m),w=p.getFullYear(),b=p.getMonth(),y=0;r>=m;y++){var M=fn(w,b+h*y,1);(m=(+M+(M-n(M/1e3)))/1e3)>r||l.push(m)}else{var k=$>i?i:$,S=v+(o(e)-o(f))+d(f-v,k);l.push(S);for(var Y=n(S),D=Y.getHours()+Y.getMinutes()/60+Y.getSeconds()/Q,E=i/Q;;){S=g(S+i);var T=o(x(D+E))%24,W=n(S).getHours()-T;if(W>1&&(W=-1),(S-=W*Q)>r)break;D=(D+E)%24,.7>g((S-l[l.length-1])/i)*a||l.push(S)}}return l}}(O),on=sn(O,rn(un,q)),an=vn(O,cn("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",q));s.series=j,s.axes=G,s.scales=J;var ln={};for(var mn in J){var pn=J[mn];null==pn.min&&null==pn.max||(ln[mn]={min:pn.min,max:pn.max})}var dn,gn,bn=M({show:!0},t.legend).show,In=[],Rn=!1;if(bn){dn=A("table","legend",f);var jn=j[1].values;if(Rn=null!=jn){var Gn=A("tr","labels",dn);for(var Jn in A("th",null,Gn),gn=jn(s,1,0))A("th",null,Gn).textContent=Jn}else gn={_:0},z(dn,"inline")}var Un=s.cursor=M({},hn,t.cursor);Un.points.show=m(Un.points.show);var Vn=s.focus=M({},t.focus||{alpha:.3},Un.focus),On=Vn.prox>=0,qn=[null];function Xn(n,t){var e=n.scale,r=J[e]=M({},0==t?En:Tn,J[e]),o=r.time;r.range=m(r.range||(o?Hn:0==t?Pn:Nn)),n.spanGaps=!0===n.spanGaps?p:m(n.spanGaps||[]);var i=n.value;if(n.value=o?function(n){return"string"==typeof n}(i)?vn(O,cn(i,q)):i||an:i||kn,n.label=n.label||(o?"Time":"Value"),t>0){n.width=null==n.width?1:n.width,n.paths=n.paths||Wt;var a=Yn(n.width,1);n.points=M({},{size:a,width:u(1,.2*a)},n.points),n.points.show=m(n.points.show),n._paths=null}if(bn&&In.splice(t,0,function(n,t){if(0==t&&Rn)return null;var e=[],r=A("tr","series",dn,dn.childNodes[t]);z(r,n.class),n.show||z(r,"off");var o=A("th",null,r),i=C("ident",o);n.width&&(i.style.borderColor=n.stroke),i.style.backgroundColor=n.fill;var a=C("text",o);for(var l in a.textContent=n.label,t>0&&(P("click",o,(function(t){Un.locked||Ln(t)&&Gt(j.indexOf(n),{show:!n.show},me.setSeries)})),On&&P("mouseenter",o,(function(){Un.locked||Gt(j.indexOf(n),{focus:!0},me.setSeries)}))),gn){var u=A("td",null,r);u.textContent="--",e.push(u)}return e}(n,t)),Un.show){var l=function(n,t){if(t>0){var e=Un.points.show(s,t);if(e)return z(e,"cursor-pt"),z(e,n.class),_(e,-10,-10),I.insertBefore(e,qn[t]),e}}(n,t);l&&qn.splice(t,0,l)}}for(var Zn in s.addSeries=function(n,t){n=An(n,t=null==t?j.length:t,wn,Dn),j.splice(t,0,n),Xn(j[t],t)},s.delSeries=function(n){j.splice(n,1),In.splice(n,1)[0][0].parentNode.remove(),qn.splice(n,1)[0].remove()},j.forEach(Xn),J){var Kn=J[Zn];null!=Kn.from&&(J[Zn]=M({},J[Kn.from],Kn))}var Qn,$n=j[0].scale,nt=J[$n].distr;G.forEach((function(n){if(n.show){var t=J[n.scale];null==t&&(n.scale=n.side%2?j[1].scale:$n,t=J[n.scale]);var e=t.time;n.space=m(n.space),n.rotate=m(n.rotate),n.incrs=m(n.incrs||(2==t.distr?Z:e?en:K)),n.split=m(n.split||(e&&1==t.distr?X:Mn));var r=n.values;n.values=e?w(r)?sn(O,rn(r,q)):r||on:r||yn,n.font=Bn(n.font),n.labelFont=Bn(n.labelFont)}}));var tt,et,rt,ot,it,at,lt,ut,st,ft,ct=null,vt=null,ht=j[0].idxs,mt=null;function pt(n,t){s.data=n,e=n.slice(),Qn=(mt=e[0]).length,2==nt&&(e[0]=mt.map((function(n,t){return t}))),At(),he("setData"),!1!==t&&dt()}function dt(){ct=ht[0]=0,vt=ht[1]=Qn-1,jt($n,2==nt?ct:e[0][ct],2==nt?vt:e[0][vt])}function gt(n,t,e,r){H.strokeStyle=n||"#000",H.lineWidth=t,H.lineJoin="round",H.setLineDash(e||[]),H.fillStyle=r||"#000"}function xt(n,t){s.width=tt=rt=n,s.height=et=ot=t,it=at=0,function(){var n=!1,t=!1,e=!1,r=!1;G.forEach((function(o){if(o.show){var i=o.side,a=i%2,l=o.size+(o.labelSize=null!=o.label?o.labelSize||30:0);l>0&&(a?(rt-=l,3==i?(it+=l,r=!0):e=!0):(ot-=l,0==i?(at+=l,n=!0):t=!0))}})),(n||t)&&(e||(rt-=U.x),r||(rt-=U.x,it+=U.x)),(r||e)&&(t||(ot-=U.y),n||(ot-=U.y,at+=U.y))}(),function(){var n=it+rt,t=at+ot,e=it,r=at;function o(o,i){switch(o){case 1:return(n+=i)-i;case 2:return(t+=i)-i;case 3:return(e-=i)+i;case 0:return(r-=i)+i}}G.forEach((function(n){var t=n.side;n._pos=o(t,n.size),null!=n.label&&(n._lpos=o(t,n.labelSize))}))}();var e=s.bbox;lt=e[Y]=v(it*W,.5),ut=e.top=v(at*W,.5),st=e[k]=v(rt*W,.5),ft=e[S]=v(ot*W,.5),F(B,Y,it),F(B,"top",at),F(B,k,rt),F(B,S,ot),F(I,Y,it),F(I,"top",at),F(I,k,rt),F(I,S,ot),F(L,k,tt),F(L,S,et),b[k]=i(tt*W),b[S]=i(et*W),re(),R&&jt($n,J[$n].min,J[$n].max),R&&he("setSize")}function wt(){if(Xt)Kt=!0;else{if(Qn>0){var t=y(J);for(var r in t){var o=t[r],i=ln[r];null!=i?(M(o,i),r==$n&&At()):r!=$n&&(o.min=1/0,o.max=-1/0)}for(var a in j.forEach((function(r,o){var i=r.scale,a=t[i];if(0==o){var f=a.range(s,a.min,a.max);a.min=f[0],a.max=f[1],ct=n(a.min,e[0]),vt=n(a.max,e[0]),a.min>e[0][ct]&&ct++,e[0][vt]>a.max&&vt--,r.min=mt[ct],r.max=mt[vt]}else if(r.show&&null==ln[i]){var c=r.min==1/0?a.auto?function(n,t,e){for(var r=1/0,o=-1/0,i=t;e>=i;i++)null!=n[i]&&(r=l(r,n[i]),o=u(o,n[i]));return[r,o]}(e[o],ct,vt):[0,100]:[r.min,r.max];a.min=l(a.min,r.min=c[0]),a.max=u(a.max,r.max=c[1])}r.idxs[0]=ct,r.idxs[1]=vt})),t){var f=t[a];if(null==f.from&&f.min!=1/0&&null==ln[a]){var c=f.range(s,f.min,f.max);f.min=c[0],f.max=c[1]}}for(var v in t){var h=t[v];if(null!=h.from){var m=t[h.from];if(m.min!=1/0){var p=h.range(s,m.min,m.max);h.min=p[0],h.max=p[1]}}}var d={};for(var g in t){var x=t[g],w=J[g];w.min==x.min&&w.max==x.max||(w.min=x.min,w.max=x.max,d[g]=!0),ln[g]=null}for(var b in j.forEach((function(n){d[n.scale]&&(n._paths=null)})),d)he("setScale",b)}Un.show&&te()}}s.setData=pt,s.bbox={},s.setSize=function(n){xt(n.width,n.height)};var bt,yt,Mt,kt,St,Yt,Dt,Et=1;function Tt(n,t){var e=new Set(j[n].spanGaps(s,t,n)),r=null;if((t=t.filter((function(n){return!e.has(n)}))).length>0){r=new Path2D;for(var o=lt,i=0;t.length>i;i++){var a=t[i];r.rect(o,ut,a[0]-o,ut+ft),o=a[1]}r.rect(o,ut,lt+st-o,ut+ft)}return r}function Wt(n,t,r,o){var a,s,f=j[t],c=e[0],v=e[t],h=J[$n],m=J[f.scale],p=1==Et?{stroke:new Path2D,fill:null,clip:null}:j[t-1]._paths,d=p.stroke,x=g(f[k]*W),w=1/0,b=-1/0,y=[],M=i(_n(c[1==Et?r:o],h,st,lt));f.band&&1==Et&&r==ct&&(x&&d.lineTo(-x,i(Cn(v[r],m,ft,ut))),c[0]>h.min&&y.push([lt,M-1]));for(var S=1==Et?r:o;S>=r&&o>=S;S+=Et){var Y=i(_n(c[S],h,st,lt));if(Y==M)null!=v[S]&&(a=i(Cn(v[S],m,ft,ut)),w=l(a,w),b=u(a,b));else{var D=!1;if(w!=1/0?(d.lineTo(M,w),d.lineTo(M,b),d.lineTo(M,a),s=M):D=!0,null!=v[S]?(a=i(Cn(v[S],m,ft,ut)),d.lineTo(Y,a),w=b=a,Y-M>1&&null==v[S-1]&&(D=!0)):(w=1/0,b=-1/0),D){var E=y[y.length-1];E&&E[0]==s?E[1]=Y:y.push([s,Y])}M=Y}}if(f.band){var T,z,F=100*x;-1==Et&&r==ct&&(z=lt-F,T=r),1==Et&&o==vt&&(z=lt+st+F,T=o,h.max>c[Qn-1]&&y.push([M,lt+st])),d.lineTo(z,i(Cn(v[T],m,ft,ut)))}if(1==Et&&(p.clip=Tt(t,y),null!=f.fill)){var A=p.fill=new Path2D(d),C=i(Cn(0,m,ft,ut));A.lineTo(lt+st,C),A.lineTo(lt,C)}return f.band&&(Et*=-1),p}function zt(n,t,e,r){var o;if(r>0){var i=n.space(s,t,e,r);(o=function(n,t,e,r){for(var o=e/n,i=0;t.length>i;i++){var a=t[i]*o;if(a>=r)return[t[i],a]}}(e-t,n.incrs(s,t,e,r,i),r,i)).push(o[1]/i)}else o=[0,0];return o}function Ft(n,t,e,r,o,i,a,l){var u=i%2/2;H.translate(u,u),gt(a,i,l),H.beginPath();var s,f,c,v,h=r+(0==e||3==e?-o:o);0==t?(f=r,v=h):(s=r,c=h),n.forEach((function(n){0==t?s=c=n:f=v=n,H.moveTo(s,f),H.lineTo(c,v)})),H.stroke(),H.translate(-u,-u)}function At(){j.forEach((function(n,t){t>0&&(n.min=1/0,n.max=-1/0,n._paths=null)}))}function Ct(){Xt?Zt=!0:(H.clearRect(0,0,b[k],b[S]),he("drawClear"),function(){G.forEach((function(n){if(n.show){var t=J[n.scale];if(t.min!=1/0){var e=n.side,r=e%2,o=t.min,a=t.max,l=zt(n,o,a,0==r?rt:ot),u=l[0],f=l[1],v=n.split(s,o,a,u,l[2],2==t.distr),h=0==r?_n:Cn,m=0==r?st:ft,p=0==r?lt:ut,d=v.map((function(n){return i(h(n,t,m,p))})),x=i(n.gap*W),w=n.ticks,b=w.show?i(w.size*W):0,y=n.values(s,2==t.distr?v.map((function(n){return mt[n]})):v,f,u),M=2==e?n.rotate(s,y,f)*-c/180:0,S=i(n._pos*W),D=S+(b+x)*(0==r&&0==e||1==r&&3==e?-1:1),E=0==r?D:0,T=1==r?D:0;H.font=n.font[0],H.fillStyle=n.stroke||"#000",H.textAlign=M>0?Y:0>M?"right":0==r?"center":3==e?"right":Y,H.textBaseline=M||1==r?"middle":2==e?"top":"bottom";var z=1.5*n.font[1];if(y.forEach((function(n,t){0==r?T=d[t]:E=d[t],(""+n).split(/\n/gm).forEach((function(n,t){M?(H.save(),H.translate(T,E+t*z),H.rotate(M),H.fillText(n,0,0),H.restore()):H.fillText(n,T,E+t*z)}))})),n.label){H.save();var F=i(n._lpos*W);1==r?(T=E=0,H.translate(F,i(ut+ft/2)),H.rotate((3==e?-c:c)/2)):(T=i(lt+st/2),E=F),H.font=n.labelFont[0],H.textAlign="center",H.textBaseline=2==e?"top":"bottom",H.fillText(n.label,T,E),H.restore()}w.show&&Ft(d,r,e,S,b,g(w[k]*W),w.stroke);var A=n.grid;A.show&&Ft(d,r,0==r?2:1,0==r?ut:lt,0==r?ft:st,g(A[k]*W),A.stroke,A.dash)}}})),he("drawAxes")}(),function(){j.forEach((function(n,t){if(t>0&&n.show&&null==n._paths){var r=function(n){for(var t=h(ct-1,0,Qn-1),e=h(vt+1,0,Qn-1);null==n[t]&&t>0;)t--;for(;null==n[e]&&Qn-1>e;)e++;return[t,e]}(e[t]);n._paths=n.paths(s,t,r[0],r[1])}})),j.forEach((function(n,t){t>0&&n.show&&(n._paths&&function(n){var t=j[n];if(1==Et){var e=t._paths,r=e.stroke,o=e.fill,i=e.clip,a=g(t[k]*W),l=a%2/2;gt(t.stroke,a,t.dash,t.fill),H.globalAlpha=t.alpha,H.translate(l,l),H.save();var u=lt,s=ut,f=st,c=ft,v=a*W/2;0==t.min&&(c+=v),0==t.max&&(s-=v,c+=v),H.beginPath(),H.rect(u,s,f,c),H.clip(),null!=i&&H.clip(i),t.band?(H.fill(r),a&&H.stroke(r)):(a&&H.stroke(r),null!=t.fill&&H.fill(o)),H.restore(),H.translate(-l,-l),H.globalAlpha=1}t.band&&(Et*=-1)}(t),n.points.show(s,t,ct,vt)&&function(n){var t=j[n],r=t.points,o=g(t[k]*W),a=o%2/2,l=r.width>0,u=(r.size-r.width)/2*W,s=g(2*u);H.translate(a,a),H.save(),H.beginPath(),H.rect(lt-s,ut-s,st+2*s,ft+2*s),H.clip(),H.globalAlpha=t.alpha;for(var f=new Path2D,v=ct;vt>=v;v++)if(null!=e[n][v]){var h=i(_n(e[0][v],J[$n],st,lt)),m=i(Cn(e[n][v],J[t.scale],ft,ut));f.moveTo(h+u,m),f.arc(h,m,u,0,2*c)}gt(r.stroke||t.stroke||"#000",o,null,r.fill||(l?"#fff":t.stroke||"#000")),H.fill(f),l&&H.stroke(f),H.globalAlpha=1,H.restore(),H.translate(-a,-a)}(t),he("drawSeries",t))}))}(),bt=!0,he("draw"))}function _t(n,t){var e=J[n];if(null==e.from){if(n==$n&&e.time&&G[0].show&&t.max>t.min&&.001>zt(G[0],t.min,t.max,rt)[0])return;ln[n]=t,bt=!1,wt(),!bt&&Ct(),bt=!1}}s.redraw=function(n){!1!==n?jt($n,J[$n].min,J[$n].max):Ct()},s.setScale=_t;var Ht=!1,Pt=Un.drag;if(Un.show){var Nt="cursor-";Un.x&&(Yt=Un.left,yt=C(Nt+"x",I)),Un.y&&(Dt=Un.top,Mt=C(Nt+"y",I))}var Lt=s.select=M({show:!0,left:0,width:0,top:0,height:0},t.select),Bt=Lt.show?C("select",I):null;function It(n,t){if(Lt.show){for(var e in n)F(Bt,e,Lt[e]=n[e]);!1!==t&&he("setSelect")}}function Rt(n){var t=bn?In[n][0].parentNode:null;j[n].show?t&&function(n){n.classList.remove("off")}(t):(t&&z(t,"off"),qn.length>1&&_(qn[n],0,-10))}function jt(n,t,e){_t(n,{min:t,max:e})}function Gt(n,t,e){var r=j[n];if(null!=t.focus&&function(n){n!=Vt&&(j.forEach((function(t,e){!function(n,t){var e=j[n];Jt(n,t),e.band&&Jt(j[n+1].band?n+1:n-1,t)}(e,null==n||0==e||e==n?1:Vn.alpha)})),Vt=n,Ct())}(n),null!=t.show){if(r.show=t.show,Rt(n),r.band){var o=j[n+1]&&j[n+1].band?n+1:n-1;j[o].show=r.show,Rt(o)}jt($n,J[$n].min,J[$n].max)}he("setSeries",n,t),e&&de.pub("setSeries",s,n,t)}function Jt(n,t){j[n].alpha=t,In&&(In[n][0].parentNode.style.opacity=t)}s.setSelect=It,s.setSeries=Gt;var Ut=Array(j.length),Vt=null;function Ot(n,t){var e=h(n/(t==$n?rt:ot),0,1),r=J[t];return r.min+e*(r.max-r.min)}function qt(t){return n(Ot(t,$n),e[0],ct,vt)}bn&&On&&P("mouseleave",dn,(function(){Un.locked||(Gt(null,{focus:!1},me.setSeries),te())})),s.posToIdx=qt,s.posToVal=function(n,t){return Ot(t==$n?n:ot-n,t)},s.valToPos=function(n,t,e){return t==$n?_n(n,J[t],e?st:rt,e?lt:0):Cn(n,J[t],e?ft:ot,e?ut:0)};var Xt=!1,Zt=!1,Kt=!1,Qt=!1;function $t(n){Xt=!0,n(s),Xt=!1,Kt&&wt(),Qt&&te(),Zt&&!bt&&Ct(),Kt=Qt=Zt=bt=Xt}s.batch=$t,s.setCursor=function(n){Yt=n.left,Dt=n.top,te()};var ne=0;function te(n){if(Xt)Qt=!0;else{var t;if(ne=0,Un.show&&(Un.x&&_(yt,i(Yt),0),Un.y&&_(Mt,0,i(Dt))),0>Yt||0==Qn){t=null;for(var o=0;j.length>o;o++)if(o>0&&(Ut[o]=1/0,qn.length>1&&_(qn[o],-10,-10)),bn){if(0==o&&Rn)continue;for(var a=0;In[o].length>a;a++)In[o][a].firstChild.nodeValue="--"}On&&Gt(null,{focus:!0},me.setSeries)}else{t=qt(Yt);for(var f=g(_n(e[0][t],J[$n],rt,0)),c=0;j.length>c;c++){var v=j[c];if(c>0&&v.show){var h=e[c][t],m=null==h?-10:g(Cn(h,J[v.scale],ot,0));Ut[c]=m>0?r(m-Dt):1/0,qn.length>1&&_(qn[c],f,m)}else Ut[c]=1/0;if(bn){if(0==c&&Rn)continue;var p=0==c&&2==nt?mt:e[c],d=Rn?v.values(s,c,t):{_:v.value(s,p[t],c,t)},x=0;for(var w in d)In[c][x++].firstChild.nodeValue=d[w]}}}if(Yt>=0&&Lt.show&&Ht){if(Pt.x){var b=l(kt,Yt),y=u(kt,Yt);F(Bt,Y,Lt[Y]=b),F(Bt,k,Lt[k]=y-b)}if(Pt.y){var M=l(St,Dt),D=u(St,Dt);F(Bt,"top",Lt.top=M),F(Bt,S,Lt[S]=D-M)}}if(null!=n&&(de.pub("mousemove",s,Yt,Dt,rt,ot,t),On)){var E=l.apply(null,Ut),T=null;E>Vn.prox||Ut.some((function(n,t){if(n==E)return T=t})),Gt(T,{focus:!0},me.setSeries)}Un.idx=t,Un.left=Yt,Un.top=Dt,R&&he("setCursor")}}var ee=null;function re(){ee=I.getBoundingClientRect()}function oe(n,t,e,r,o,i){Un.locked||(ie(n,0,e,r,o,i,0,!1,null!=n),null!=n?0==ne&&(ne=D(te)):te())}function ie(n,t,e,r,o,i,a,l,u){null!=n?(e=n.clientX-ee.left,r=n.clientY-ee.top):(e=rt*(e/o),r=ot*(r/i)),u&&(e>1&&rt-1>e||(e=v(e,rt)),r>1&&ot-1>r||(r=v(r,ot))),l?(kt=e,St=r):(Yt=e,Dt=r)}function ae(){It({width:Pt.x?0:rt,height:Pt.y?0:ot},!1)}function le(n,t,e,r,o,i){(null==n||Ln(n))&&(Ht=!0,ie(n,0,e,r,o,i,0,!0,!0),Lt.show&&(Pt.x||Pt.y)&&ae(),null!=n&&(P("mouseup",E,ue),de.pub("mousedown",s,kt,St,rt,ot,null)))}function ue(n,t,e,r,o,i){(null==n||Ln(n))&&(Ht=!1,ie(n,0,e,r,o,i,0,!1,!0),Yt!=kt||Dt!=St?(It(Lt),Pt.setScale&&($t((function(){if(Pt.x){var n=2==nt?qt:Ot;jt($n,n(Lt[Y],$n),n(Lt[Y]+Lt[k],$n))}if(Pt.y)for(var t in J)t!=$n&&null==J[t].from&&jt(t,Ot(ot-Lt.top-Lt[S],t),Ot(ot-Lt.top,t))})),ae())):Un.lock&&(Un.locked=!Un.locked,Un.locked||te()),null!=n&&(N("mouseup",E,ue),de.pub("mouseup",s,Yt,Dt,rt,ot,null)))}function se(n){dt(),null!=n&&de.pub("dblclick",s,Yt,Dt,rt,ot,null)}var fe,ce={};ce.mousedown=le,ce.mousemove=oe,ce.mouseup=ue,ce.dblclick=se,ce.setSeries=function(n,t,e,r){Gt(e,r)},Un.show&&(P("mousedown",I,le),P("mousemove",I,oe),P("mouseenter",I,re),P("mouseleave",I,(function(){Un.locked||Ht||(Yt=-10,Dt=-10,te(1))})),Pt.setScale&&P("dblclick",I,se),fe=function(n){var t=null;function e(){t=null,n()}return function(){clearTimeout(t),t=setTimeout(e,100)}}(re),P("resize",T,fe),P("scroll",T,fe),s.syncRect=re);var ve=s.hooks=t.hooks||{};function he(n,t,e){n in ve&&ve[n].forEach((function(n){n.call(null,s,t,e)}))}(t.plugins||[]).forEach((function(n){for(var t in n.hooks)ve[t]=(ve[t]||[]).concat(n.hooks[t])}));var me=M({key:null,setSeries:!1},Un.sync),pe=me.key,de=null!=pe?Wn[pe]=Wn[pe]||zn():zn();function ge(){xt(t[k],t[S]),he("init",t,e),pt(e||t.data,!1),ln[$n]?_t($n,ln[$n]):dt(),It(Lt,!1),R=!0,he("ready")}return de.sub(s),s.pub=function(n,t,e,r,o,i,a){ce[n](null,t,e,r,o,i,a)},s.destroy=function(){de.unsub(s),N("resize",T,fe),N("scroll",T,fe),f.remove(),he("destroy")},a?a instanceof HTMLElement?(a.appendChild(f),ge()):a(s,ge):ge(),s}return In.assign=M,In.rangeNum=t,In.fmtDate=V,In.tzDate=function(n,t){var e=new Date(n.toLocaleString("en-US",{timeZone:t}));return e.setMilliseconds(n.getMilliseconds()),e},In}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.uplot, .uplot *, .uplot *::before, .uplot *::after {box-sizing: border-box;}.uplot {font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";line-height: 1.5;width: max-content;}.uplot .title {text-align: center;font-size: 18px;font-weight: bold;}.uplot .wrap {position: relative;user-select: none;}.uplot .over, .uplot .under {position: absolute;overflow: hidden;}.uplot canvas {display: block;position: relative;width: 100%;height: 100%;}.uplot .legend {font-size: 14px;margin: auto;text-align: center;}.uplot .legend.inline {display: block;}.uplot .legend.inline * {display: inline-block;}.uplot .legend.inline tr {margin-right: 16px;}.uplot .legend th {font-weight: 600;}.uplot .legend th > * {vertical-align: middle;display: inline-block;}.uplot .legend .ident {width: 1em;height: 1em;margin-right: 4px;border: 2px solid transparent;}.uplot .legend.inline th::after {content: ":";vertical-align: middle;}.uplot .legend .series > * {padding: 4px;}.uplot .legend .series th {cursor: pointer;}.uplot .legend .off > * {opacity: 0.3;}.uplot .select {background: rgba(0,0,0,0.07);position: absolute;pointer-events: none;}.uplot .select.off {display: none;}.uplot .cursor-x, .uplot .cursor-y {position: absolute;left: 0;top: 0;pointer-events: none;will-change: transform;z-index: 100;}.uplot .cursor-x {height: 100%;border-right: 1px dashed #607D8B;}.uplot .cursor-y {width: 100%;border-bottom: 1px dashed #607D8B;}.uplot .cursor-pt {position: absolute;top: 0;left: 0;border-radius: 50%;filter: brightness(85%);pointer-events: none;will-change: transform;z-index: 100;}
|
metadata
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: uplot
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- gscho
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-05-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 5.2.4
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 5.2.4.2
|
|
23
|
+
type: :development
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 5.2.4
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 5.2.4.2
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: sqlite3
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
type: :development
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
description:
|
|
48
|
+
email:
|
|
49
|
+
- greg.c.schofield@gmail.com
|
|
50
|
+
executables: []
|
|
51
|
+
extensions: []
|
|
52
|
+
extra_rdoc_files: []
|
|
53
|
+
files:
|
|
54
|
+
- MIT-LICENSE
|
|
55
|
+
- README.md
|
|
56
|
+
- Rakefile
|
|
57
|
+
- lib/uplot.rb
|
|
58
|
+
- lib/uplot/engine.rb
|
|
59
|
+
- lib/uplot/version.rb
|
|
60
|
+
- vendor/assets/javascripts/uPlot.iife.min.js
|
|
61
|
+
- vendor/assets/stylesheets/uPlot.min.css
|
|
62
|
+
homepage: https://github.com/gscho/uplot
|
|
63
|
+
licenses:
|
|
64
|
+
- MIT
|
|
65
|
+
metadata: {}
|
|
66
|
+
post_install_message:
|
|
67
|
+
rdoc_options: []
|
|
68
|
+
require_paths:
|
|
69
|
+
- lib
|
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '0'
|
|
80
|
+
requirements: []
|
|
81
|
+
rubyforge_project:
|
|
82
|
+
rubygems_version: 2.7.7
|
|
83
|
+
signing_key:
|
|
84
|
+
specification_version: 4
|
|
85
|
+
summary: A small (< 25 KB min), fast chart for time series, lines, areas, ohlc & bars
|
|
86
|
+
(MIT Licensed)
|
|
87
|
+
test_files: []
|