reactjs - react-highcharts alignThreshold -
i turned app react frontend , have graphing component. need alignthresholds set true , used experimental script of torstein hønsi far. http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/studies/alignthresholds/
is there easy way integrate script?
import react 'react' import reacthighcharts 'react-highcharts/bundle/reacthighcharts'; class graphing extends react.component { constructor(props) { super(props) this.graphconfig = this.graphconfig.bind(this); } render(){ console.log(this.props); if(this.props.active){ return (<reacthighcharts config = {this.graphconfig()}></reacthighcharts>) }else{ return (<div>click row graph</div>) } } graphconfig(){ return { title:{ text:'' }, subtitle:{ text:'' }, chart: { alignthresholds: true, height:this.props.height, events: { load: function() { //addplotbandstoweekends(); }, }, }, xaxis: { type: 'datetime', min: this.props.startdate, max: this.props.enddate }, yaxis: [{ title: { text: 'usd($)', }, opposite: true },{ title: { text: 'visits', }, opposite: false }], tooltip: { pointformat: '<span style="color:{series.color}">{series.name}: <b>{point.y}</b></span><br/>', valueprefix: '{series.options.unit}', shared: true }, legend: { layout: 'vertical', align: 'right', verticalalign: 'middle', borderwidth: 0 }, series: [{ name: 'profit', yaxis: 0, data: this.props.data.map(function(item){return([item.end_time,item.profit])}), color: "rgb(132, 195, 51)", unit: "$" }, { name: 'cumulative profit', yaxis: 0, data: this.props.data.map(function(item){return([item.end_time,item.cumulativeprofit])}), color: "rgb(0, 255, 36)", unit: "$", visible: false }, { name: 'revenue', data: this.props.data.map(function(item){return([item.end_time,item.revenue])}), color: "rgb(255, 158, 53)", unit: "$" }, { name: 'cumulative revenue', data: this.props.data.map(function(item){return([item.end_time,item.cumulativerevenue])}), color: "rgb(255, 200, 100)", unit: "$", visible: false }, { name: 'cost', data: this.props.data.map(function(item){return([item.end_time,item.cost])}), color: "rgb(232, 79, 54)", unit: "$" }, { name: 'cumulative cost', data: this.props.data.map(function(item){return([item.end_time,item.cumulativecost])}), color: "rgb(255, 10, 75)", unit: "$", visible: false }, { name: 'visits', yaxis: 1, data: this.props.data.map(function(item){return([item.end_time,item.visits])}), color: "rgb(86, 60, 119)", unit: "" }, { name: 'cumulative visits', yaxis: 1, data: this.props.data.map(function(item){return([item.end_time,item.cumulativevisits])}), color: "rgb(255, 47, 218)", unit: "", visible: false }, { name: 'conversions', yaxis: 1, data: this.props.data.map(function(item){return([item.end_time,item.conversions])}), color: "rgb(44, 167, 227)", unit: "" }, { name: 'cumulative conversions', yaxis: 1, data: this.props.data.map(function(item){return([item.end_time,item.cumulativeconversions])}), color: "rgb(50, 100, 200)", unit: "", visible: false }] }; } } export default graphing;
the plugin should work fine, need pass instance of highcharts
react-highcharts
using.
it exposed reacthighcharts.highcharts
, that's should pass plugin (see line 59 in jsfiddle).
Comments
Post a Comment