制作TimeLine物流信息展示效果
var TimeLine = function (_id) {
this.id = _id;
this._top = 40;
this.vHeight = 40;
this.global_top = 40;
this.line_height = 4;
this.radius = 6;
this.startPosition = 6;
this.text_top = 40;
this.text_margin = 20;
this.text_left = [6, 15];
this.canvas = null;
this.totalWidth = 0;
this.totalHeight = 0;
this.context = null;
this.stepPosition = 100;
this.font = "bold 35px sans-serif";
this.Init();
}; TimeLine.prototype = {
Init: function () {
this.canvas = document.getElementById(this.id);
if (this.canvas == null) {
return false;
} this.totalWidth = this.canvas.clientWidth * 0.95;
this.totalHeight = this.canvas.clientHeight;
this.stepPosition = 0.1 * this.totalWidth;
this.global_top = 0.1 * this.totalHeight;
this.vHeight = 0.1 * this.totalHeight;
this.text_margin = 0.06 * this.totalHeight;
this.radius = 0.01 * this.totalHeight;
this.text_left = [0.01 * this.totalHeight, 0.01 * this.totalWidth];
this.startPosition = 0.02 * this.totalWidth; this.context = this.canvas.getContext("2d");
//每次重绘前清空
this.context.clearRect(0, 0, this.totalWidth, this.totalHeight);
}, /**
*strDate:时间
*strContent:显示文本
*direction:走势,0水平,1垂直,-1结束
*status:状态,1,2已完成,0未完成
*/
AddEvent: function (strDate, strContent, direction, status) {
if (this.canvas == null) {
return false;
}
var okColor = 'green', onColor = 'gray';
var passColor = "rgba(0,255,0,0.5)", waitColor = "rgba(99,99,99,0.5)";
var passStrokeColor = "green", waitStrokeColor = "rgba(99,99,99,0.5)";
if (direction == 0) {
this.stepPosition = strContent.length * 6;
if (this.stepPosition < 0.20 * this.totalWidth) this.stepPosition = 0.20 * this.totalWidth;
//设置透明度实践证明透明度值>0,<1值越低,越透明,值>=1时为纯色,值<=0时为完全透明
this.context.fillStyle = ((status == 1 || status == 2) ? passColor : waitColor);
this.context.fillRect(this.startPosition + this.radius, this.global_top, this.stepPosition, this.line_height); //设置新图形(红色圆形)
this.context.beginPath();
this.context.fillStyle = ((status == 1 || status == 2) ? okColor : onColor);
this.context.arc(this.startPosition + this.line_height / 2, this.global_top + this.line_height / 2, this.radius, 0, Math.PI * 2, false);
this.context.fill();
this.context.fillStyle = ((status == 1 || status == 2) ? okColor : onColor);
this.context.font = this.font;
//this.text_top=this.global_top+this.line_height+this.text_margin;
this.text_top = this.text_margin;
//context.strokeStyle = ((status==1||status==2)?passStrokeColor:waitStrokeColor);
//context.strokeText(strContent,this.startPosition+text_left[0],this.text_top);
this.context.fillText(strContent, this.startPosition + this.text_left[0], this.text_top);
this.context.fillText(strDate, this.startPosition + this.text_left[0], this.global_top + this.text_top + 10);
this.startPosition += this.stepPosition;
}
else if (direction == 1) {
stepPosition = 50;
//设置透明度实践证明透明度值>0,<1值越低,越透明,值>=1时为纯色,值<=0时为完全透明
this.context.fillStyle = ((status == 1) ? passColor : waitColor);
this.context.fillRect(this.startPosition, this.vHeight + this.radius + this.line_height / 2, this.line_height, this.stepPosition * 0.2);
this.vHeight += this.stepPosition * 0.2;
this._top += +this.stepPosition * 0.2;
//设置新图形(红色圆形)
this.context.beginPath();
this.context.fillStyle = ((status == 1) ? okColor : onColor);
this.context.arc(this.startPosition + this.line_height / 2, this.vHeight + this.line_height / 2, this.radius, 0, Math.PI * 2, false);
this.context.fill();
this.context.fillStyle = ((status == 1) ? okColor : onColor);
this.context.font = this.font;
this.text_top = this._top + this.line_height / 2;
//this.context.strokeStyle = ((status==1)?passStrokeColor:waitStrokeColor);
//this.context.strokeText(strDate+' '+strContent,this.startPosition+text_left[1],this.text_top);
this.context.fillText(strDate + ' ' + strContent, this.startPosition + this.text_left[1], this.vHeight + 10);
//this.context.fillText(strContent,this.startPosition+this.text_left[1],this.text_top+this.text_margin);
}
else if (direction == -1) {
//设置透明度实践证明透明度值>0,<1值越低,越透明,值>=1时为纯色,值<=0时为完全透明
this.context.fillStyle = ((status == 1 || status == 2) ? passColor : waitColor);
this.context.fillRect(this.startPosition + this.radius, this.global_top, this.stepPosition * 0.7, this.line_height);
//设置新图形(红色圆形)
this.context.beginPath();
this.context.fillStyle = ((status == 1 || status == 2) ? okColor : onColor);
this.context.arc(this.startPosition + this.line_height / 2 + this.stepPosition * 0.7 + this.radius, this.global_top + this.line_height / 2, this.radius, 0, Math.PI * 2, false);
this.context.fill();
this.context.fillStyle = ((status == 1 || status == 2) ? okColor : onColor);
this.context.font = this.font;
this.text_top = this.text_margin;
//context.strokeStyle = ((status==1||status==2)?passStrokeColor:waitStrokeColor);
//context.strokeText(strContent,this.startPosition+this.text_left[0]+this.stepPosition*2.5,this.text_top);
this.context.fillText(strContent, this.startPosition + this.text_left[0] + this.stepPosition * 0.4, this.text_top);
this.context.fillText(strDate, this.startPosition + this.text_left[0] + this.stepPosition * 0.4, this.global_top + this.text_margin + 10);
}
}
};
制作TimeLine物流信息展示效果的更多相关文章
- Photoshop将普通照片快速制作二次元漫画风格效果
今天为大家分享Photoshop将普通照片快速制作二次元漫画风格效果,教程很不错,对于喜欢漫画的朋友可以参考本文,希望能对大家有所帮助! 一提到日本动画电影,大家第一印象肯定是宫崎骏,但是日本除了宫崎 ...
- Simptip – 使用 Sass 制作的 CSS Tooltip 效果
Simptip 是一个简单基于 Sass 的 CSS 工具提示效果.帮助你在网站中加入在不同的方向(上.左.右.下)的工具提示,也可以设置不同的颜色如成功.信息.警告和危险.最后还有其他特性如软边.半 ...
- Elastislide - 响应式的图片循环展示效果
Elastislide 是一款非常优秀的响应式 jQuery 图片循环展示(旋转木马)插件,集成了 Touchwipe 插件以支持触屏设备.提供了四种效果:水平图片传送带.垂直图片传送带.固定在屏幕底 ...
- 利用TabHost制作QQ客户端标签栏效果(低版本QQ)
学习一定要从基础学起,只有有一个好的基础,我们才会变得更加的perfect 下面小编将利用TabHost制作QQ客户端标签栏效果(这个版本的QQ是在前几年发布的)…. 首先我们看一下效果: 看到这个界 ...
- JS实现有点炫的图片展示效果-图片解体和组合
经过4个月的努力学习,迎来了进入市场的最后一个学习项目.自己模仿了一个图片展示效果,用在了项目中,感觉挺炫的.在这里分享一下,希望大家喜欢~! bomb-showImg : 在线演示http://ru ...
- 响应式的dribbble作品集魔术布局展示效果
在线演示1 本地下载 相信做设计的朋友肯定都知道dribbble.com,它是一个非常棒的设计师分享作品的网站,全世界数以万计的设计高手和行家都在这个网站上分享自己的作品,当然,如果你常在上面闲逛的话 ...
- jQuery制作Web全屏效果
需要的资源 1.jQuery版本库是必不可少的2.jQuery FullScreen plugin如果你下载不方便的话,你可以直接把下面的代码copy到你本地JQuery FullScreen plu ...
- CSS3 实现六边形Div图片展示效果
原文:CSS3 实现六边形Div图片展示效果 效果图: 实现原理: 这个效果的主要css样式有: 1.>transform: rotate(120deg); 图片旋转 2.>overflo ...
- cesium 之地图切换展示效果篇(附源码下载)
前言 cesium 官网的api文档介绍地址cesium官网api,里面详细的介绍 cesium 各个类的介绍,还有就是在线例子:cesium 官网在线例子,这个也是学习 cesium 的好素材. 内 ...
随机推荐
- Python入门必学:数据类型和变量的用法
什么是数据类型?计算机顾名思义就是可以做数学计算的机器,因此,计算机程序理所当然地可以处理各种数值.但是,计算机能处理的远不止数值,还可以处理文本.图形.音频.视频.网页等各种各样的数据,不同的数据, ...
- python3爬取咪咕音乐榜信息(附源代码)
参照上一篇爬虫小猪短租的思路https://www.cnblogs.com/aby321/p/9946831.html,继续熟悉基础爬虫方法,本次爬取的是咪咕音乐的排名 咪咕音乐榜首页http://m ...
- strak组件(9):关键字搜索
效果图: 在列表视图函数增加搜索功能. 新增函数 def get_search_list(self) 钩子方法,获取搜索条件 一.strak组件 strak/service/core_func.py ...
- Linux基础知识与命令1(su passwd)
一.Linux的基本原则 1.linux由一个个目的单一的小程序组成,我们一般需要组合小程序来完成复杂的任务 2.Linux的一切都是文件(文件类似于一棵树,包括外设,接口) 3.Linux尽量避免捕 ...
- ABAP CDS - SELECT, WHERE
格式 ... WHERE cond_expr ... 结果 定义CDS视图结果集的Where条件.访问CDS视图时,结果集仅包含来自数据源数据源的数据,该数据源数据源满足在where之后指定的条件co ...
- 20145202马超 《Java程序设计》第六周学习总结
进程:是一个正在执行中的程序,每一个进程都有一个执行程序,该顺序是一个执行路径,或者说是一个控制单元. 线程:就是进程中的一个独立的控制单元,线程在控制着进程的执行. 一个进程至少有一线程. Java ...
- 4 . GET方法实现文章分类
复习:博客站点 <!DOCTYPE html> {% load staticfiles %} <html> <head> <meta charset=&quo ...
- 【Python】Django学习一:第一个Django程序
项目开发环境 Python 3.6 Django 1.11.5 Django安装 在开始安装Django之前,Django更新比较频繁,所以要选择合适的版本,这里选择Django1.11.5. pip ...
- python之if测试
(一)python的条件判断语句一般格式如下: if (条件1): (执行结果) elif(条件2): (执行结果) ..... else: (执行结果) 执行顺序为从上到下判断,若条件1不符合则进入 ...
- java5初学
1.Eclipse快捷键 alt + / 代码提示,例如自动创建main方法ctrl + d 删除当前行ctrl + alt + up/down 复制当前行alt + up/down 交换行ctrl ...