forked from Bremen/ESG
3 lines
10 KiB
JavaScript
3 lines
10 KiB
JavaScript
"use strict";function _classCallCheck(o,e){if(!(o instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(o,e){for(var a=0;a<e.length;a++){var t=e[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(o,t.key,t)}}function _createClass(o,e,a){return e&&_defineProperties(o.prototype,e),a&&_defineProperties(o,a),o}var FlotDemo=function(){function o(){_classCallCheck(this,o),this.init()}return _createClass(o,[{key:"init",value:function(){this.lineChart(),this.barChart(),this.areaChart(),this.horizontalBarChart(),this.combineChart(),this.realtimeChart(),this.handleTooltips()}},{key:"lineChart",value:function(){for(var o=[],e=[],a=0;a<14;a+=.5)o.push([a,Math.sin(a)]),e.push([a,Math.cos(a)]);var t=[{data:o,label:"sin(x)"},{data:e,label:"cos(x)"}],l={series:{lines:{show:!0},points:{fillColor:"dark"===Looper.skin?Looper.getColors("gray")[200]:Looper.white,show:!0}},colors:[Looper.colors.brand.purple,Looper.colors.brand.teal],grid:{hoverable:!0,borderWidth:0,color:Looper.getMutedColor()},legend:{position:"se"},xaxis:{tickLength:0},yaxis:{min:-1.2,max:1.2}};l=$.extend(!0,{},Looper.flotDefaultOptions(),l),$("#flot-line").plot(t,l)}},{key:"barChart",value:function(){var o={series:{bars:{show:!0,barWidth:.5,align:"center",fillColor:{colors:[{opacity:.9},{opacity:.1}]}}},colors:[Looper.colors.brand.teal],grid:{hoverable:!0,borderWidth:0,color:Looper.getMutedColor()},xaxis:{mode:"categories",tickLength:0}};o=$.extend(!0,{},Looper.flotDefaultOptions(),o),$("#flot-bar").plot([[["January",10],["February",8],["March",4],["April",13],["May",17],["June",9]]],o)}},{key:"areaChart",value:function(){function o(o){return new Date(o,1,1).getTime()}var e=[[o(1800),700],[o(1850),2600],[o(1900),8200],[o(1950),17162],[o(1955),18688],[o(1960),20415],[o(1965),21957],[o(1970),23194],[o(1975),24343],[o(1980),25607],[o(1985),26946],[o(1990),28355],[o(1995),29944],[o(2e3),31592],[o(2005),33216],[o(2010),34412]],a=[[o(1800),20300],[o(1850),27600],[o(1900),40800],[o(1950),54740],[o(1955),57518],[o(1960),60140],[o(1965),63403],[o(1970),65586],[o(1975),67554],[o(1980),69243],[o(1985),70601],[o(1990),72158],[o(1995),72741],[o(2e3),72799],[o(2005),72472],[o(2010),72708]],t=[{label:"Asia",data:[[o(1800),63500],[o(1850),80900],[o(1900),94700],[o(1950),139849],[o(1955),154195],[o(1960),167434],[o(1965),189942],[o(1970),214312],[o(1975),239751],[o(1980),263234],[o(1985),288755],[o(1990),316781],[o(1995),343005],[o(2e3),367974],[o(2005),391751],[o(2010),411963]],color:Looper.colors.brand.purple},{label:"Europe",data:a,color:Looper.colors.brand.teal},{label:"North America",data:e,color:Looper.colors.brand.indigo}],l={series:{lines:{show:!0,fill:!0}},xaxis:{tickLength:0,axisLabel:"Year",axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelPadding:10,axisLabelFontFamily:"inherit, sans-serif",axisLabelColour:Looper.getMutedColor(),mode:"time",tickSize:[20,"year"],timeformat:"%Y"},yaxis:{axisLabel:"Population (multiply by 10,000)",axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelPadding:3,axisLabelFontFamily:"inherit, sans-serif",axisLabelColour:Looper.getMutedColor(),tickFormatter:function(o){return o}},legend:{noColumns:3,position:"nw"},grid:{hoverable:!0,borderWidth:0,color:Looper.getMutedColor()}};l=$.extend(!0,{},Looper.flotDefaultOptions(),l),$("#flot-area").plot(t,l)}},{key:"horizontalBarChart",value:function(){var o=[{label:"Precious Metal Price",data:[[1582.3,0],[28.95,1],[1603,2],[774,3],[1245,4],[85,5],[1025,6]],color:Looper.colors.brand.teal}],e={series:{bars:{show:!0}},bars:{align:"center",barWidth:.5,horizontal:!0,fillColor:{colors:[{opacity:1},{opacity:1}]},lineWidth:1},xaxis:{axisLabel:"Price (USD/oz)",axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelPadding:10,axisLabelFontFamily:"inherit, sans-serif",axisLabelColour:Looper.getMutedColor(),tickFormatter:function(o){return o},max:2e3},yaxis:{axisLabel:"Precious Metals",axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelPadding:3,axisLabelFontFamily:"inherit, sans-serif",axisLabelColour:Looper.getMutedColor(),tickLength:0,ticks:[[0,"Gold"],[1,"Silver"],[2,"Platinum"],[3,"Palldium"],[4,"Rhodium"],[5,"Ruthenium"],[6,"Iridium"]]},legend:{noColumns:0,position:"ne"},grid:{hoverable:!0,borderWidth:0,color:Looper.getMutedColor()}};e=$.extend(!0,{},Looper.flotDefaultOptions(),e),$("#flot-barhor").plot(o,e)}},{key:"combineChart",value:function(){function o(o,e,a){return new Date(o,e-1,a).getTime()}var e=[[o(2012,1,1),11],[o(2012,1,2),9],[o(2012,1,3),7],[o(2012,1,4),13],[o(2012,1,5),11],[o(2012,1,6),11],[o(2012,1,7),9],[o(2012,1,8),10],[o(2012,1,9),7],[o(2012,1,10),11],[o(2012,1,11),7],[o(2012,1,12),6],[o(2012,1,13),4],[o(2012,1,14),5],[o(2012,1,15),11],[o(2012,1,16),8],[o(2012,1,17),9],[o(2012,1,18),16],[o(2012,1,19),11],[o(2012,1,20),18],[o(2012,1,21),8],[o(2012,1,22),17],[o(2012,1,23),11],[o(2012,1,24),13],[o(2012,1,25),11],[o(2012,1,26),11],[o(2012,1,27),9],[o(2012,1,28),8],[o(2012,1,29),7],[o(2012,1,30),8],[o(2012,1,31),20]],a=[[o(2012,1,1),320],[o(2012,1,2),430],[o(2012,1,3),540],[o(2012,1,4),560],[o(2012,1,5),964],[o(2012,1,6),1022],[o(2012,1,7),436],[o(2012,1,8),750],[o(2012,1,9),648],[o(2012,1,10),639],[o(2012,1,11),654],[o(2012,1,12),300],[o(2012,1,13),739],[o(2012,1,14),748],[o(2012,1,15),768],[o(2012,1,16),1023],[o(2012,1,17),869],[o(2012,1,18),489],[o(2012,1,19),987],[o(2012,1,20),980],[o(2012,1,21),580],[o(2012,1,22),387],[o(2012,1,23),345],[o(2012,1,24),560],[o(2012,1,25),405],[o(2012,1,26),876],[o(2012,1,27),543],[o(2012,1,28),650],[o(2012,1,29),600],[o(2012,1,30),900],[o(2012,1,31),531]],t=[[o(2012,1,1),1],[o(2012,1,2),-2],[o(2012,1,3),-2],[o(2012,1,4),1],[o(2012,1,5),3],[o(2012,1,6),4],[o(2012,1,7),5],[o(2012,1,8),6],[o(2012,1,9),7],[o(2012,1,10),7],[o(2012,1,11),6],[o(2012,1,12),7],[o(2012,1,13),8],[o(2012,1,14),8],[o(2012,1,15),3],[o(2012,1,16),2],[o(2012,1,17),4],[o(2012,1,18),-1],[o(2012,1,19),5],[o(2012,1,20),6],[o(2012,1,21),-2],[o(2012,1,22),-7],[o(2012,1,23),-9],[o(2012,1,24),-8],[o(2012,1,25),-7],[o(2012,1,26),-6],[o(2012,1,27),-3],[o(2012,1,28),1],[o(2012,1,29),6],[o(2012,1,30),9],[o(2012,1,31),8]],l=[{label:"Sea Level Pressure",data:a,color:Looper.getMutedColor(),bars:{show:!0,align:"center",barWidth:5184e4,lineWidth:1}},{label:"Wind Speed",data:e,yaxis:2,color:Looper.colors.brand.purple,points:{fillColor:Looper.colors.brand.purple,show:!0},lines:{show:!0}},{label:"Temperature",data:t,yaxis:3,color:Looper.colors.brand.teal,points:{fillColor:Looper.colors.brand.teal,show:!0},lines:{show:!0}}],i={xaxis:{mode:"time",tickSize:[3,"day"],tickLength:0,axisLabel:"Date",axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"inherit, Arial",axisLabelColour:Looper.getMutedColor(),axisLabelPadding:10},yaxes:[{position:"left",max:1070,axisLabel:"Sea Level Pressure (hPa)",axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"inherit, Arial",axisLabelColour:Looper.getMutedColor(),axisLabelPadding:3},{position:"right",axisLabel:"Wind Speed (km/hr)",axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"inherit, Arial",axisLabelColour:Looper.getMutedColor(),axisLabelPadding:3},{position:"right",axisLabel:"Temperature (°C)",axisLabelUseCanvas:!0,axisLabelFontSizePixels:12,axisLabelFontFamily:"inherit, Arial",axisLabelColour:Looper.getMutedColor(),axisLabelPadding:3}],legend:{noColumns:1,position:"nw"},grid:{hoverable:!0,borderWidth:0,color:Looper.getMutedColor()}};i=$.extend(!0,{},Looper.flotDefaultOptions(),i),$("#flot-combine").plot(l,i)}},{key:"realtimeChart",value:function(){function e(){for(t=t.slice(1);t.length<300;){var o=(0<t.length?t[t.length-1]:50)+10*Math.random()-5;o<0?o=0:100<o&&(o=100),t.push(o)}for(var e=[],a=0;a<t.length;++a)e.push([a,t[a]]);return e}var t=[],o=[{data:e(),color:Looper.colors.brand.teal}],a={series:{lines:{show:!0,fill:!0},shadowSize:0},yaxis:{min:0,max:100},xaxis:{show:!1},grid:{borderWidth:0,color:Looper.getMutedColor()}};a=$.extend(!0,{},Looper.flotDefaultOptions(),a);var l=$.plot("#flot-realtime",o,a);!function o(){l.setData([{data:e(),color:Looper.colors.brand.teal}]),l.draw(),setTimeout(o,1e3)}()}},{key:"handleTooltips",value:function(){$('<div id="flot-tooltip" class="flot-tooltip"></div>').appendTo("body"),$(document).on("plothover","#flot-line, #flot-bar",function(o,e,a){if(a){var t=a.datapoint[0].toFixed(2),l=a.datapoint[1].toFixed(2),i=void 0===a.series.label?a.series.data[a.dataIndex][0]:a.series.label+" of "+t;$("#flot-tooltip").html(i+" = "+l).css({top:a.pageY+5,left:a.pageX+5}).fadeIn(300)}else $("#flot-tooltip").hide()}),$('<div id="flot-tooltip2" class="flot-tooltip"></div>').appendTo("body"),$(document).on("plothover","#flot-area",function(o,e,a){if(a){var t=a.datapoint[0],l=a.datapoint[1],i=a.series.color;$("#flot-tooltip2").html("<strong>".concat(a.series.label,"</strong><br>").concat(new Date(t).getFullYear()," : <strong>Population : ").concat(l,"</strong> <br> <em>(multiply by 10,000)</em>")).css({top:a.pageY+5,left:a.pageX+5,borderColor:i,color:Looper.getDarkColor(),backgroundColor:Looper.getLightColor()}).fadeIn(300)}else $("#flot-tooltip2").hide()}),$('<div id="flot-tooltip3" class="flot-tooltip"></div>').appendTo("body"),$(document).on("plothover","#flot-barhor",function(o,e,a){if(a){var t=a.datapoint[0],l=(a.datapoint[1],a.series.color);$("#flot-tooltip3").html("<strong>".concat(a.series.label," :</strong> ").concat(t)).css({top:a.pageY+9,left:a.pageX-100,borderColor:l,color:Looper.getDarkColor(),backgroundColor:Looper.getLightColor()}).fadeIn(300)}else $("#flot-tooltip3").hide()}),$('<div id="flot-tooltip4" class="flot-tooltip"></div>').appendTo("body"),$(document).on("plothover","#flot-combine",function(o,e,a){if(a){var t=a.datapoint[0],l=a.datapoint[1],i=a.series.color,r="Jan "+new Date(t).getDate(),s="";"Sea Level Pressure"==a.series.label?s="hPa":"Wind Speed"==a.series.label?s="km/hr":"Temperature"==a.series.label&&(s="°C"),$("#flot-tooltip4").html("'<strong>".concat(a.series.label,"'</strong><br>").concat(r,"' : <strong>").concat(l,"'</strong> ").concat(s)).css({top:a.pageY+5,left:a.pageX+5,borderColor:i,color:Looper.getDarkColor(),backgroundColor:Looper.getLightColor()}).fadeIn(300)}else $("#flot-tooltip4").hide()})}}]),o}();$(document).on("theme:init",function(){new FlotDemo});
|
|
//# sourceMappingURL=../../sourcemaps/pages/flot-demo.min.js.map
|