highchart 图标 时钟的使用

$(function () {
    $(‘#container‘).highcharts({
        chart: {
            type: ‘line‘
        },
        title: {
            text: ‘月平均气温‘
        },
        subtitle: {
            text: ‘数据来源: WorldClimate.com‘
        },
        xAxis: {
            categories: [‘一月‘, ‘二月‘, ‘三月‘, ‘四月‘, ‘五月‘, ‘六月‘, ‘七月‘, ‘八月‘, ‘九月‘, ‘十月‘, ‘十一月‘, ‘十二月‘]
        },
        yAxis: {
            title: {
                text: ‘气温 (°C)‘
            }
        },
        plotOptions: {
            line: {
                dataLabels: {
                    enabled: true          // 开启数据标签
                },
                enableMouseTracking: false // 关闭鼠标跟踪,对应的提示框、点击事件会失效
            }
        },
        series: [{
            name: ‘东京‘,
            data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
        }, {
            name: ‘伦敦‘,
            data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
        }]
    });
});
<div id="container" style="min-width:400px;height:400px"></div>
//外部引入
<link rel="icon" href="https://static.jianshukeji.com/hcode/images/favicon.ico">
    <script type="text/javascript" src="https://img.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="https://img.hcharts.cn/highcharts/highcharts.js"></script>
    <script type="text/javascript" src="https://img.hcharts.cn/highcharts/highcharts-more.js"></script>
    <script type="text/javascript" src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>

//这里是我自定义三十天日期的数组  还有 处理对应格式数据的方法
 var myDate = new Date(); //获取今天日期
           myDate.setDate(myDate.getDate() - 30);
           var dateTemp;
           var flag = 1;
           for (var i = 0; i < 30; i++) {
                dateTemp = (myDate.getMonth()+1)+"月"+myDate.getDate()+‘日‘;
                dayArray.push(dateTemp);
                myDate.setDate(myDate.getDate() + flag);
            }
                    for (var i = 0; i < 30; i++) {
                 dateTemp = (myDate.getMonth()+1)+"月"+myDate.getDate()+‘日‘;
                 sevenArray.push(dateTemp);
                 myDate.setDate(myDate.getDate() + flag);
             }
                    for (var i = 0; i < 24; i++) {
                 dateTemp = 1+"时";
                 timeArray.push(dateTemp);
                 myDate.setDate(myDate.getDate() + flag);
             }
 var day = new Date(item.receivetime).getMonth()+1+"月"+new Date(item.receivetime).getDate()+‘日‘;
                         // console.log(item.totalsteps.split(‘|‘));
                        //  console.log(day);
                         var steps = item.totalsteps.split(‘|‘);
                            data.data.forEach(function(item){

                                if(obj[day]){
                                     obj[day]+=Number(steps[steps.length-1])
                                    //  stepss.push(steps)
                                }else{
                                        obj[day]=Number(steps[steps.length-1])
                                }
                        })
                        // console.log(dayArray) ;
                });
                // console.log(obj)
                dayArray.forEach(function(item){

                    if(obj[item]){
                        // console.log(obj[item]);
                        totalsteps.push(obj[item]);

                    }else{
                        totalsteps.push(0); //每天步数
                    }
                });

感觉最烦的就是处理数据了,给一打数据。 每个公司的套路不同,我也没法完全展现   下面是时钟的

<div id="container" style="width: 400px; height: 400px; margin: 0 auto"></div>
<script type="text/javascript">
            $(function () {
            /**
             * Get the current time
             */
            function getNow() {
                var now = new Date();
                return {
                    hours: now.getHours() + now.getMinutes() / 60,
                    minutes: now.getMinutes() * 12 / 60 + now.getSeconds() * 12 / 3600,
                    seconds: now.getSeconds() * 12 / 60
                };
            }
            /**
             * Pad numbers
             */
            function pad(number, length) {
                // Create an array of the remaining length + 1 and join it with 0‘s
                return new Array((length || 2) + 1 - String(number).length).join(0) + number;
            }
            var now = getNow();
            // Create the chart
            $(‘#container‘).highcharts({
                chart: {
                    type: ‘gauge‘,
                    plotBackgroundColor: null,
                    plotBackgroundImage: null,
                    plotBorderWidth: 0,
                    plotShadow: false,
                    height: 400
                },
                credits: {
                    enabled: false
                },
                title: {
                    text: ‘时钟‘
                },
                pane: {
                    background: [{
                        // default background
                    }, {
                        // reflex for supported browsers
                        backgroundColor: Highcharts.svg ? {
                            radialGradient: {
                                cx: 0.5,
                                cy: -0.4,
                                r: 1.9
                            },
                            stops: [
                                [0.5, ‘rgba(255, 255, 255, 0.2)‘],
                                [0.5, ‘rgba(200, 200, 200, 0.2)‘]
                            ]
                        } : null
                    }]
                },
                yAxis: {
                    labels: {
                        distance: -20
                    },
                    min: 0,
                    max: 12,
                    lineWidth: 0,
                    showFirstLabel: false,
                    minorTickInterval: ‘auto‘,
                    minorTickWidth: 1,
                    minorTickLength: 5,
                    minorTickPosition: ‘inside‘,
                    minorGridLineWidth: 0,
                    minorTickColor: ‘#666‘,
                    tickInterval: 1,
                    tickWidth: 2,
                    tickPosition: ‘inside‘,
                    tickLength: 10,
                    tickColor: ‘#666‘,
                    title: {
                        text: ‘君子一诺lv<br/>Highcharts‘,
                        style: {
                            color: ‘#BBB‘,
                            fontWeight: ‘normal‘,
                            fontSize: ‘8px‘,
                            lineHeight: ‘10px‘
                        },
                        y: 10
                    }
                },
                tooltip: {
                    formatter: function () {
                        return this.series.chart.tooltipText;
                    }
                },
                series: [{
                    data: [{
                        id: ‘hour‘,
                        y: now.hours,
                        dial: {
                            radius: ‘60%‘,
                            baseWidth: 4,
                            baseLength: ‘95%‘,
                            rearLength: 0
                        }
                    }, {
                        id: ‘minute‘,
                        y: now.minutes,
                        dial: {
                            baseLength: ‘95%‘,
                            rearLength: 0
                        }
                    }, {
                        id: ‘second‘,
                        y: now.seconds,
                        dial: {
                            radius: ‘100%‘,
                            baseWidth: 1,
                            rearLength: ‘20%‘
                        }
                    }],
                    animation: false,
                    dataLabels: {
                        enabled: false
                    }
                }]
            },
                                       // Move
                                       function (chart) {
                setInterval(function () {
                    now = getNow();
                    var hour = chart.get(‘hour‘),
                        minute = chart.get(‘minute‘),
                        second = chart.get(‘second‘),
                        // run animation unless we‘re wrapping around from 59 to 0
                        animation = now.seconds === 0 ?
                        false :
                    {
                        easing: ‘easeOutElastic‘
                    };
                    // Cache the tooltip text
                    chart.tooltipText =
                        pad(Math.floor(now.hours), 2) + ‘:‘ +
                        pad(Math.floor(now.minutes * 5), 2) + ‘:‘ +
                        pad(now.seconds * 5, 2);
                    hour.update(now.hours, true, animation);
                    minute.update(now.minutes, true, animation);
                    second.update(now.seconds, true, animation);
                }, 1000);
            });
        });
        // Extend jQuery with some easing (copied from jQuery UI)
        $.extend($.easing, {
            easeOutElastic: function (x, t, b, c, d) {
                var s=1.70158;var p=0;var a=c;
                if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
                if (a < Math.abs(c)) { a=c; var s=p/4; }
                else var s = p/(2*Math.PI) * Math.asin (c/a);
                return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
            }
        });

</script>
时间: 2024-08-24 20:11:30

highchart 图标 时钟的使用的相关文章

AppWidget 如android桌面上的时钟

一. 1.App widget 是在home桌面的一个空间,比如时钟,播放器播放时小图标可以点击下一首等那个. 2.AppWidgetProviderInfo 对象: 为App Widget 提供元数据,包括布局,更新频率等数据,这个对象被定义在xml文件当中. 3.AppWidgetProvider : 定义一个App Widget 的基本生命周期函数. 二.创建App Widget步骤: 1.定义AppWidgetProviderInfo : 在res/xml文件夹中定义 example_a

【微收藏】FourShadows.js – 时间感知的算法驱动的图标阴影JS库

废话一箩筐,筐筐有心得 不小心养成了一个刷微博的习惯,主要还是关注一些前端人士,学习一些前端方面的知识,看到大家都有一些刷微博的小习惯.有的是转发一下,转发内容来一个标记(MARK).也有评论中标记为Mark的,这种完全不知道是干什么?不过有一个比较好的@我的印象笔记 不过,我不怎么喜欢使用这些小工具,因为怎么的我都不喜欢详细看,实际上这不是一个好习惯,我最常用的还是微博的收藏功能,最后找个时间再细看一下这些内容,今天就分享一篇收藏的内容.(吐槽一下:微博的某设备官方客户端真心不好用,主要是针对

我的第一个chrome扩展(1)——读样例,实现时钟

学习chrome扩展开发: 与网页类似,需要的知识:html,javascript chrome扩展程序的构成: manifest.json:对扩展程序的整体描述文件 { "manifest_version": 2, //manifest_version:默认为2,可不写 //在第2版manifest下chrome出于安全不会运行html内的js代码 "name": "我的时钟", "version": "1.0&q

【UWP通用应用开发】编辑文本、绘制图形、3D透视效果及绘制时钟实战

编辑文本及键盘输入 相信大家都会使用TextBox,但如果要让文本在TextBox中换行该怎么做呢?将TextWrapping属性设置为Wrap,将AcceptsReturn属性设置为True就好咯. PasswordBox很明显就是一个密码框了,和其他的控件相比其有2个特殊之处,一个是其可以用MaxLength来控制最大的长度,一个是用PasswordChanged来捕捉密码的改名.显然比如QQ密码的MaxLength就是16位了,而PasswordChanged可以用来监测比如用户设置的密码

Quartz2D复习(四) --- 时钟器和各种动画

1.CALayer 1).在ios中,能看得见摸得着的东西基本上都是UIView, 比如按钮.文本标签.文本输入框.图标等,这些都是UIView 2).UIView之所以能显示在屏幕上,完全是因为它内部的一个图层 3).在创建UIView对象时,UIView内部会自动创建一个图层(即CALayer对象),通过UIView的layer属性可以访问这个层:@property (nonatomic,readonly,retain) CALayer *layer; 4).当UIView需要显示到屏幕上时

我的app JustDoIt 番茄时钟

好吧,现在来介绍一下我的一个app吧,名字叫JustDoIt.是一款番茄时钟类型的app.我想很快就要把它发布了.说不上开心或者不开心.首先它并非我的第一个app,之所以拿出来介绍,可能是想以后做得更好吧,相比于以前至少我的能力和美感都有了一定的提升. 图标可能有些呆萌(丑),还请见谅,因为所有都是LZ自己一个人做的,可能能力有限吧,不过我会努力的. 首先,这个是app的图标,红底白钩,象征待办事项与番茄. 接下来介绍一下JustDoIt的基本功能.首先进入的是任务列表模块,用户可以在此添加,删

java代码实现highchart与数据库数据结合完整案例分析(一)---饼状图

作者原创:转载请注明出处 在做项目的过程中,经常会用到统计数据,同时会用到highchart或echart进行数据展示,highchart是外国开发的数据统计图插件, echart是我们国家开发的数据统计插件,我比较喜欢highchart的统计插件,在这里展示的也是highchart插件的应用. 应用highchart插件并不难,找到官方文档,copy代码,就能把图标呈现出来,难的是如何将本地数据库中的数据与其结合.因此, 在这里主要分析将数据库数据和插件结合的过程,我用的是java代码实现的.

Swing带TrayIcon(托盘小图标)的Hello world示例

首先上一个经典的Hello world示例: 1 package com.xxx.yyy.zzz; 2 3 import javax.swing.JFrame; 4 5 public class MainFrame extends JFrame { 6 7 private static final long serialVersionUID = -3059928131346032935L; 8 public MainFrame() { 9 super(); 10 this.setSize(300

进一步封装highchart,打造自己的图表插件:jHighChart.js

Highcharts 是一个用纯JavaScript编写的一个图表库, 能够很简单便捷的在web网站或是web应用程序添加有交互性的图表.支持的图表类型有曲线图.区域图.柱状图.饼状图.散状点图和综合图表.但是参考官网的实例,我发现如果在项目中频繁使用highchart,按照它的方式还是挺复杂的,我这里所谓的复杂并不是难而是麻烦,因为你每写一个图表你就必须重新写类似于下面结构的javascript代码: $('#container').highcharts({ title: { text: 'M