Echarts自定义tootips

由于业务需求,现在要自定义tootips;

设计稿如下:

代码如下:

app.title = ‘坐标轴刻度与标签对齐‘;
var str1 = "top:-20px;border:0px solid #000;position:relative;width:100px;height:60px;line-height:60px;background:rgba(50,50,50,0.7);;border-radius:4px;text-align:center;";
var arrow="position:absolute;color:rgba(50,50,50,0.7);width: 0px;height:0px;height:0px;line-height: 0px;border-width: 10px 15px 0;border-style: solid dashed dashed dashed;border-left-color: transparent;border-right-color: transparent;bottom: -10px;right: 50%;margin-right:-15px";
option = {
    color: [‘#3398DB‘],
    tooltip : {
        trigger: ‘item‘,
        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
            type : ‘shadow‘        // 默认为直线,可选为:‘line‘ | ‘shadow‘
        },
        position:"top",
        formatter:function(params)
        {

            return "<div style=‘"+str1+"‘><div style=‘"+arrow+"‘></div>"+params.value+"</div>";
        },
        backgroundColor:‘transparent‘
    },
    grid: {
        left: ‘3%‘,
        right: ‘4%‘,
        bottom: ‘3%‘,
        containLabel: true
    },
    xAxis : [
        {
            type : ‘category‘,
            data : [‘13:00‘, ‘13:05‘, ‘13:10‘, ‘13:15‘, ‘13:20‘, ‘13:25‘, ‘13:30‘,‘13:35‘,‘13:40‘,‘13:45‘,‘13:50‘,‘13:55‘],
            axisTick: {
                alignWithLabel: true
            }
        }
    ],
    yAxis : [
        {
            // type : ‘category‘,
            // data : [‘10‘,‘20‘,‘30‘,‘40‘],
            axisTick: {
                alignWithLabel: true
            }
        }
    ],
    series : [
        {
            name:‘直接访问‘,
            type:‘bar‘,
            barWidth: ‘40%‘,
            data:[1, 3, 2, 3, 4, 2, 1,3,3,2,3,2]
        },

    ],
    label: {
            normal: {
                show: true,
                position: ‘top‘,
                formatter: ‘{c}‘
            }
        },
    itemStyle: {
                normal: {

                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: ‘rgba(17, 168,171, 1)‘
                    }, {
                        offset: 1,
                        color: ‘rgba(17, 168,171, 0.1)‘
                    }]),
                    shadowColor: ‘rgba(0, 0, 0, 0.1)‘,
                    shadowBlur: 10
                }
            }
};

更多 :http://gallery.echartsjs.com/editor.html?c=xB1DgDmtmb

原文地址:https://www.cnblogs.com/lguow/p/9540341.html

时间: 2024-07-31 19:48:35

Echarts自定义tootips的相关文章

Echarts自定义折线图例,增加选中功能

用Echarts图表开发,原本的Echarts图例不一定能满足我们的视觉要求. 下面是Echarts 折线图自定义图例,图例checked选中,相应的折线线条会随之checked,其余未选中的图例对应的折线opacity会降低,(柱状图,饼图等等也类似于此),这是一个小例子(如果满足不了您的视觉要求,您可以自己定义css样式,达到自己想要的视觉效果): <!doctype html> <html> <head> <meta charset="utf-8&

百度echarts自定义主题使用

1.百度echarts官网主题构建,自定义主题 主题在线构建  http://echarts.baidu.com/theme-builder/ 构建完成后下载并保存js文件 2.html导入保存的js文件 <!-- 引入 ECharts 文件 --> <script src="echarts.js"></script> <!-- 引入 自定义主题customed --> <script src="customed.js&q

ECharts自定义toolbox中增加自定义按钮

今天想能不能在ECharts中的ToolBox增加自己的按钮,然后读了一下ToolBox代码,自己试了试,验证是可以的. 1.效果图 图片中红色框起来的按钮 2.代码 selfButtons:{//自定义按钮 danielinbiti,这里增加,selfbuttons可以随便取名字 show:true,//是否显示 title:'自定义', //鼠标移动上去显示的文字 icon:'test.png', //图标 option:{}, onclick:function(option1) {//点击

echarts自定义折线图横坐标时间间隔踩坑总结

折线图需求:横坐标为时间,要求按一定间隔展示,鼠标移至折线上间隔时间内的数据也可展示 其实很简单的一个配置就可搞定,但在不熟悉echarts配置的情况下,就很懵逼 xAxis: { boundaryGap: false, // 距离坐标原点是否有间隙 axisLabel: { //  如果这个字段不设置,echarts会根据屏宽及横坐标数据自动给出间隔 interval: 30, // 间隔长度,可自定义(如果是时间格式,echarts会自动处理) rotate: 40 // 横坐标上label

echarts自定义y轴刻度信息

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ECharts</title> <!-- 引入 echarts.js --> <script src="echarts.common.min.js"></script> </head> <body> <!-- 为

echarts自定义饼图

在网上看到一张图,便想要用echarts实现: 原网图 现图 <!--原代码--> <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>普通饼图</title></head><script src="echarts.common.min.js"></s

echarts自定义提示框数据

tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "line" // 默认为直线,可选为:'line' | 'shadow' }, formatter: function(params) { var texts = ""; for (var i = 0; i < params.length; i++) { if (i == 0) { texts += par

Echarts自定义图表显隐开关

插入折线 // 插入折线 function appendLineToChart(name, data, zeroData) { var line = { name: name, type: 'line', xAxisIndex: 0, smooth: false, connectNulls: true, data: data, markLine: { lineStyle: { type: 'dashed' }, data: zeroData } } option.series.push(line

Echarts 相关用例

Echarts 自定义保存为图片按钮的样式及icon toolbox: {     feature: {     saveAsImage: {         pixelRatio: 2,         title:'下载',         icon:'image://<?php echo base_url();?>common/images/icon-top.png'         }     } }, Echarts 自定义按钮实现保存图片 $("#button-downl