1 line
1.6 KiB
JavaScript
1 line
1.6 KiB
JavaScript
"use strict";var t=function(t){return t&&t.__esModule?t["default"]:t},i=t(require("react")),e=t(require("./streaming-graph"));module.exports=i.createClass({displayName:"streaming-graph-view",getInitialState:function(){return{}},render:function(){this.hasMounted&&this.updateVisibility();var t={width:"97%",height:310,border:"1px solid grey",position:"relative"};return i.createElement("div",null,i.createElement("div",{className:"panel-heading",style:{height:40}},i.createElement("h2",{style:{margin:"auto",textAlign:"center"}},this.props.title)),i.createElement("div",{style:t,ref:"graph"}))},componentDidMount:function(){var t=i.findDOMNode(this.refs.graph),s=[];this.hasMounted=!0;for(var r in this.props.groups)s.push({id:this.props.groups[r].id,content:this.props.groups[r].name,style:this.checkStyle(this.props.groups[r]),options:{shaded:!1}});this.velocityGraph=new e(t,s,this.props.dataAxis),this.updateVisibility(),this.interval=setInterval(this.update.bind(this),this.props.intervalLength)},checkStyle:function(t){var i="";return t.color?i+"stroke:"+t.color:i},update:function(){!this.props.parent.paused&&this.props.parent.isConnected&&(this.addPoints(),this.updateVisibility(),this.velocityGraph.renderStep())},updateVisibility:function(){var t={};for(var i in this.props.groups){var e=this.props.groups[i].name;t[this.props.groups[e].id]=this.props.groups[e].isVisible}this.velocityGraph.graph2d.setOptions({groups:{visibility:t}})},addPoints:function(){for(var t in this.props.groups)this.velocityGraph.addDataPoint(this.props.groups[t].id,this.props.groups[t].data)},componentWillUnmount:function(){clearInterval(this.interval)}}); |