123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554 |
- <template>
- <view>
- <!-- 导航栏 -->
- <view @tap="closeFrame">
- <cu-custom bgColor="bg-gradual-sisBlack" :isBack="true">
- <block slot="backText">
- <view style="height: 80rpx;line-height: 80rpx;color: silver;">返回</view>
- </block>
- <block slot="content">
- <view style="color: silver;">{{name}}历史曲线</view>
- </block>
- </cu-custom>
- </view>
-
- <view class="bc">
- <!-- 心跳标签 -->
-
- <view class="heartbeatLabel">
-
- <div class="zhiti heartbeat">{{name}}</div>
- <div class="zhiti heartbeat">{{realValue}}</div>
- <div class="zhiti heartbeat">{{unit}}</div>
- </view>
-
- <!-- 日期时间选择器 -->
-
- <view class="chooseTime">
- <view class="timeSelector">
-
- <div class="zhiti">{{rangetime[0]}} - {{rangetime[1]}}</div>
- <button type="primary" @click="onShowDatePicker('rangetime')">选择日期时间范围</button>
- </view>
- <mx-date-picker :show="showPicker" :type="type" :value="value" :show-tips="false" :begin-text="'运动开始'" :end-text="'运动结束'" :show-seconds="true" @confirm="onSelected" @cancel="onSelected" />
- </view>
- <!-- 曲线图标题 -->
- <view titleC>
- <view class="curveTitle">{{name}}曲线图</view>
- <view class="garden" style="background-color:;"></view>
- <view class="curveTitle_1">{{unit}}</view>
- </view>
- <!-- 曲线图 -->
- <scroll-view scroll-x class="horizontalSlider">
- <view class="slide">
- <view class="graphHeartbeat">
-
- <view class="qiun-charts">
-
- <!-- 没用 <canvas canvas-id="canvasLineC" id="canvasLineC" class="charts" :width="cWidth*pixelRatio" :height="cHeight*pixelRatio" :style="{'width':cWidth+'px','height':cHeight+'px'}" disable-scroll=true @ontouchstart="touchLineC" @ontouchmove="moveLineC" @ontouchend="touchEndLineC"></canvas> -->
-
- <canvas canvas-id="canvasLineC" id="canvasLineC" class="charts" @touchstart="touchLineC" ></canvas>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- import uCharts from '../../tools/u-charts/u-charts.js';
- import MxDatePicker from "@/components/mx-datepicker/mx-datepicker.vue";
- var _self;
- var canvaLineC=null;
- export default {
- data:function() {
- return {
-
- showPicker: false,
- date: '2019/01/01',
- time: '15:00:12',
- datetime: '2019/01/01 15:00:12',
- range: ['2019/01/01','2019/01/06'],
- rangetime: ['2020/03/20 14:00','2020/03/21 13:59'],
- type: 'rangetime',
- value: '',
- XT_Num:[],
- braceletCurve_XTPL:{},
- beginTime:'',
- endTime:'',
- isFrameShow: false,
- count: 0,
- cWidth: '',
- cHeight: '',
- pixelRatio: 1,
- serverData: '',
- sanJiao: 'sanJiaoDown',
- unit:'',
- color:'',
- name:'',
- realValue:''
- }
- },
-
- onLoad(option){
- _self = this;
- this.braceletCurve_XTPL = JSON.parse(option.braceletCurve_XTPL_Details);
- this.realValue = option.dataInformation;
- this.unit = option.unit;
- this.color = option.color;
- this.name = option.name;
-
- this.cWidth = uni.upx2px(1850);
- this.cHeight = uni.upx2px(600);
- this.getServerData_C();
- },
- //整体背景颜色
- mounted() {
- document.querySelector('body').setAttribute('style', 'background-color:#242424');
- },
- /* beforeCreate () {
-
- document.querySelector('body').setAttribute('style', 'background-color:#242424')
-
- },
-
- beforeDestroy () {
-
- document.querySelector('body').removeAttribute('style')
-
- }, */
-
- onShow:function(){
- },
- methods: {
- closeFrame: function() {
- this.count = this.count + 1;
- if (this.isFrameShow) {
- this.isFrameShow = false;
- this.sanJiao = 'sanJiaoDown';
- }
- },
- onShowDatePicker(type){//显示
- this.type = type;
- this.showPicker = true;
- this.value = this[type];
- },
-
- onSelected(e) {//选择
-
- let LineC = {
- categories: [
- ' 17:26',
- '18:56',
- '19:56',
- '20:56',
- '21:56',
- '22:56',
- '23:56',
- '00:56',
- '01:56',
- '02:56',
- '03:56',
- '04:56',
- '05:56',
- '06:56',
- '07:56',
- '08:56',
- '09:56',
- '10:56',
- '11:56',
- '12:56',
- '13:56',
- '14:56',
- '15:56',
- '16:56',
- '17:56 '
- ],
- series: [{
- pointShape:'triangle',
- name: this.name,
- data: [
- ],
- color: this.color,
- textColor: '#ffffff',
- textSize: this.seriesTextSize,
- /* format: val => {
- return val + 'kwh';
- }, */
- index: 0,
- legendShape: 'circle'
- },
- ]
- };
-
- Date.prototype.Format = function(fmt) {
- var o = {
- 'M+': this.getMonth() + 1, //月份
- 'd+': this.getDate(), //日
- 'h+': this.getHours(), //小时
- 'm+': this.getMinutes(), //分
- 's+': this.getSeconds(), //秒
- 'q+': Math.floor((this.getMonth() + 3) / 3), //季度
- S: this.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[
- k]).substr(('' + o[k]).length));
- return fmt;
- };
-
- this.showPicker = false;
- if(e) {
- this[this.type] = e.value;
- //选择的值
- console.log('value => '+ e.value[0]);
- console.log('value => '+ e.value[1]);
- this.beginTime = new Date(e.value[0]).getTime();
- this.endTime = new Date(e.value[1]).getTime();
- console.log(this.endTime+"结束");
- console.log(this.beginTime+"开始");
- //原始的Date对象
- /* console.log('date => ' + e.date); */
- LineC.categories = [];
- LineC.series[0].data = [];
- var j=Math.ceil(this.braceletCurve_XTPL.length/10);
- for(var i=0;i<this.braceletCurve_XTPL.length;i+=j){
- if(this.braceletCurve_XTPL[i].ts<this.endTime&&this.braceletCurve_XTPL[i].ts>this.beginTime){
- LineC.series[0].data.push(this.braceletCurve_XTPL[i].value);
- LineC.categories.push(new Date(this.braceletCurve_XTPL[i].ts).Format('MM/dd hh:mm'));
-
- }
-
- };
- /* for(var j=0;j<(LineC.series[0].data).length;j++){
- LineC.categories.push(j);
- }; */
- /* for(var i=0;i<_this.braceletCurve_XTPL.length;i++){
- if(this.braceletCurve_XTPL[i].ts<this.endTime&&this.braceletCurve_XTPL[i].ts>this.beginTime){
- LineC.categories.push(new Date(_this.braceletCurve_XTPL[i].ts).Format('hh:mm'));
- }
- } */
- this.showLineC('canvasLineC', LineC);
- }
-
- },
- choiceRange(){
- /* for(var i=0;i<braceletCurve_XTPL.length;i++){
- if(braceletCurve_XTPL[i].ts>this.endTime&&this.beginTime>braceletCurve_XTPL[i]){
- .push(braceletCurve_XTPL[i].value);
- }
- } */
-
- },
- getServerData_C() {
- // 折线图
- let LineC = {
- categories: [
- ' 17:26',
- '18:56',
- '19:56',
- '20:56',
- '21:56',
- '22:56',
- '23:56',
- '00:56',
- '01:56',
- '02:56',
- '03:56',
- '04:56',
- '05:56',
- '06:56',
- '07:56',
- '08:56',
- '09:56',
- '10:56',
- '11:56',
- '12:56',
- '13:56',
- '14:56',
- '15:56',
- '16:56',
- '17:56 '
- ],
-
- series: [{
- pointShape:'triangle',
- name: this.name,
- data: [
- ],
- color: this.color,
- textColor: '#ffffff',
- textSize: this.seriesTextSize,
- /* format: val => {
- return val + 'kwh';
- }, */
- index: 0,
- /* legendShape: 'circle' */
- },
- ]
- };
-
-
- let _this = this;
- LineC.categories = [];
- LineC.series[0].data = [];
-
- /* */
- /*
- _this.lengthDate = */
- /* console.log("---");
- console.log((LineC.categories).length); */
- /* _this.braceletCurve_SSXY = _this.braceletCurve[_this.deviceNameSsxy]; */
-
- Date.prototype.Format = function(fmt) {
- var o = {
- 'M+': this.getMonth() + 1, //月份
- 'd+': this.getDate(), //日
- 'h+': this.getHours(), //小时
- 'm+': this.getMinutes(), //分
- 's+': this.getSeconds(), //秒
- 'q+': Math.floor((this.getMonth() + 3) / 3), //季度
- S: this.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[
- k]).substr(('' + o[k]).length));
- return fmt;
- };
-
- for(let i=_this.braceletCurve_XTPL.length-7;i<_this.braceletCurve_XTPL.length;i++){
-
- LineC.series[0].data.push(_this.braceletCurve_XTPL[i].value);
- }
- /* for(let j=0;j<(LineC.series[0].data).length;j++){
- LineC.categories.push(j);
- } */
- for(let i=_this.braceletCurve_XTPL.length-7;i<_this.braceletCurve_XTPL.length;i++){
-
- LineC.categories.push(new Date(_this.braceletCurve_XTPL[i].ts).Format('MM/dd hh:mm'));
- }
- this.showLineC('canvasLineC', LineC);
- },
-
- showLineC(canvasId, chartData) {
- var _self = this;
- canvaLineC = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'line',
-
- fontSize: 8,
- legend: {
-
- show: false,
- position: 'top',
- float: 'right',
- fontColor: '#242424',
- itemGap: '4',
- itemWidth: '3',
- fontSize:'13',
- },
-
- dataLabel: false,
- dataPointShape: false,/*
- dataLabel:true, */
- background: '#242424',
- pixelRatio: _self.pixelRatio,
- categories: chartData.categories,
- series: chartData.series,
- animation: true,
- gridColor: '#2E2E2E',
- splitNumber: 5,
- gridType: 'solid',
- dashLength: 8,
- enableScroll: false,
- /* enableMarkLine:true, */
- xAxis: {
- rotateLabel:true,
- gridEval:3,
- scrollShow:false,
- scrollAlign:'left',
- disableGrid:false,
- axisLine:true,
- type: 'grid',
- disabled: false,
- gridColor: '#2E2E2E',
- fontColor: 'silver',
- gridType: 'solid',
- axisLineColor: '#2E2E2E',
- labelCount: 13,
- itemCount:10,
- scrollBackgroundColor:'#2E2E2E',
- scrollColor:'#bdbdbd',
- },
- yAxis: {
- gridColor: '#2D2D2D',
- gridType:'solid',
- splitNumber:8,
- showTitle:false,
- data: [{
-
- type: 'value',
- fontColor: 'silver',
- disabled: false, //y轴轴线
- min: 10,
- max: 180,
- position: 'left',
- axisLineColor: '#2E2E2E',
- title: this.unit,
- titleFontColor: '#BDBDBD',
- format: val => {
- return val.toFixed(0);
- }
- }
- ],
-
-
- },
- width: _self.cWidth * _self.pixelRatio ,
- height: _self.cHeight * _self.pixelRatio ,
- extra: {
- line: {
- type: 'line',
- width: '1'
- }
- }
- });
- },
-
- touchLineC(e) {
- canvaLineC.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data;
- }
- });
- },
- moveLineC(e) {
- canvaLineC.scroll(e);
- },
- },
- components: {
- MxDatePicker
- },
-
- }
- </script>
- <style>
- .horizontalSlider {
- white-space: nowrap;
- width: 100%;
- height: 400px;
- background-color: #242424;
- /* margin-top: 540px; */
- }
- .slide {
- margin-top: 6%;
- width: 900px;
- height: 350px;
- background-color: #242424;
- }
- /* .qiun-charts {
- width: 100%;
- height: 700upx;
- } */
- .charts {
- position: absolute;
- width: 100%;
- height: 600upx;
- top: 1%;
- }
- .timeSelector{
- position: absolute;
- text-align: center;
- width: 100%;
- height: 100px;
- }
- button{
- margin: 20upx;
- font-size: 28upx;
- }
- .bc{
- height: 680px;
- width: 100%;
- background-color: #242424;
- }
- .heartbeatLabel{
-
- height: 139px;
- width: 100%;
- background-color: 'silver';
- display: flex;
- align-items: center;
- justify-content:space-around ;
- /* display: flex;
- justify-content: space-between; */
- }
- .heartbeat{
- height: 50px;
- width: 30%;
- background: -webkit-linear-gradient(top, rgba(159, 131, 111, 0.1) 0%, rgba(193, 94, 21, 0.2) 100%) !important;
- /* width: 20%;
- position: absolute;
- top: 50%;
- margin-top: -25px;
-
- font-size: 18px;
- color: #bdbdbd; */
- display: flex;
- justify-content:space-around ;
- align-items: center;
-
- }
- .zhiti{
- text-align: center;
-
- /* margin-top: 12px; */
- color: #BDBDBD;
- }
- .chooseTime{
- position: relative;
- width: 100%;
- height: 100px;
- /* background-color: 'silver' ; */
- }
- .graphHeartbeat{
- position: relative;
- padding-bottom: 100px;
- width: 100%;
- height: 100%;
- }
- .titleC{
- margin-top: 3%;
- float: left;
- }
- .curveTitle{
- float: left;
- display: block;
- color: #BDBDBD;
- margin-left: 3%;
- }
- .curveTitle_1{
- float: right;
- display: block;
- color: #BDBDBD;
- margin-right: -9%;
-
- }
- .garden{
- width: 16px;
- height: 16px;
- border-radius: 50%;
- -moz-border-radius: 50%;
- -webkit-border-radius: 50%;
- float: right;
- margin-right: 8%;
- line-height: 16px;
- margin-top: 1%;
- }
- </style>
|