常用组件的配置

 

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <!--引入ECharts脚本-->
    <script src="echarts.min.js"></script>
</head>

<body>
    <!---为ECharts准备一个具备大小(宽高)的DOM-->
    <div id="main" style="width: 900px; height: 600px"></div>
    <script type="text/javascript">
        //基于准备好的DOM,初始化ECharts图表
        var myChart = echarts.init(document.getElementById("main"));
        //指定图表的配置项和数据
        var option = {
            tooltip: {  //配置提示框组件
                trigger: 'axis',
                axisPointer:
                {
                    type: 'shadow',
                    lineStyle: {
                        color: '#48b', width: 2, type: 'solid'
                    },
                    crossStyle: {
                        color: '#0000ff', width: 1, type: 'dashed'
                    },
                    shadowStyle: {
                        color: 'rgba(999,150,150,0.2)', width: 'auto', type: 'default'
                    }
                },
                showDelay: 0, hideDelay: 0, transitionDuration: 0,
                backgroundColor: 'rgba(0,222,0,0.5)',
                borderColor: '#f50', borderRadius: 8, borderWidth: 2,
                padding: 10,
                position: function (p) {
                    //位置回调
                    //console.log && console.log(p);
                    return [p[0] + 10, p[1] - 10];
                },
                textStyle: {
                    color: 'blue', decoration: 'none', fontFamily: 'sans-serif',
                    fontSize: 15, fontStyle: 'normal', fontWeight: 'bold'
                },
                formatter: function (params, ticket, callback) {
                    console.log(params)
                    var res = '详情提示框 : <br/>' + params[0].name;
                    for (var i = 0, l = params.length; i < l; i++) {
                        res += '<br/>' + params[i].seriesName + ' : ' + params[i].value;
                    }
                    setTimeout(function () {
                        //仅为了模拟异步回调
                        callback(ticket, res);
                    }, 500)
                    return 'loading';
                }
                //formatter: "Template formatter: <br/>{b}<br/>{a}:{c}<br/>{a1}:{c1}"
            },
            toolbox: {  //配置工具箱组件
                show: true,
                feature: {
                    mark: { show: true }, dataView: { show: true, readOnly: false },
                    magicType: { show: true, type: ['line', 'bar', 'stack', 'tiled'] },
                    restore: { show: true }, saveAsImage: { show: true }
                }
            },
            calculable: true,
            xAxis: [  //配置x轴坐标系
                {   //指定第一条x轴上的类目数据及格式
                    type: 'category', position: 'bottom',
                    boundaryGap: true, show: true,
                    axisLine: {  //设置第一条x轴上的轴线
                        lineStyle: {
                            color: 'pink', type: 'solid', width: 2
                        }
                    },
                    axisTick: {  //设置第一条x轴上的轴刻度标记
                        show: true, length: 10,
                        lineStyle: {
                            color: 'blue', type: 'solid', width: 2
                        }
                    },
                    axisLabel: {  //设置第一条x轴上的轴文本标记
                        show: true, interval: 'auto',
                        rotate: 45, margin: 8,
                        formatter: '{value}',
                        textStyle: {
                            color: '#000', //fontFamily: 'sans-serif',
                            fontSize: 15, fontStyle: 'italic', fontWeight: 'bold'
                        }
                    },
                    splitLine: {  //设置第一条x轴上的轴分隔线
                        show: true,
                        lineStyle: {
                            color: 'black', type: 'dashed', width: 2
                        }
                    },
                    splitArea: {  //设置第一条x轴上的轴分隔区域
                        show: true,
                        areaStyle: {
                            color: ['rgba(255,0,255,0.3)', 'rgba(238,130,238,0.3)','rgba(240,248,255,0.3)']
                        }
                    },
                    data: [
                        '周一', '周二','周三',
                        {  //设置第一条x轴上的轴标签个性化
                            value: '周四',
                            textStyle: {
                                color: 'red', fontSize: 30, fontStyle: 'normal',
                                fontWeight: 'bold'
                            }
                        },
                        '周五','周六','周日',
                    ]
                },
                {   //设置指定第二条x轴上的类目数据
                    type: 'category',
                    data: ['Mon', 'Tue', 'Wed', 'The', 'Frl', 'Sat','Sun']
                }
            ],
            yAxis: [  //配置y轴组件
                {  //指定第一条y轴上的数值型数据及格式
                    type: 'value', position: 'left',
                    boundaryGap: [0, 0.1],
                    axisLine: {  //设置第一条y轴上的轴线
                        show: true,
                        lineStyle: {
                            color: 'pink', type: 'dashed', width: 2
                        }
                    },
                    axisTick: {  //设置第一条y轴上的轴标记
                        show: true,
                        length: 10,
                        lineStyle: {
                            color: 'blue', type: 'solid', width: 2
                        }
                    },
                    axisLabel: {  //设置第一条y轴上的标签
                        show: true, interval: 'auto', margin: 18,
                        formatter: '{value}',
                
                    },
                    // splitLine: {  //设置第一条y轴上的分隔线
                    //     show: true,
                    //     lineStyle: {
                    //         color: '#483d8b', type: 'dotted', width: 2
                    //     }
                    // },
                    splitArea: {  //设置第一条y轴上的分隔区域
                        show: true,
                        areaStyle: {
                            color: ['rgba(652,511,92,0.3)', 'rgba(221,550,0,0.3)']
                        }
                    }
                },
                {   //指定第二条y轴上的数值型数据及格式
                    type: 'value',
                    splitNumber: 10,
                    axisLabel: {  //设置第二条y轴上的数轴标签
                        formatter: function (value) {
                            return value + ' °C'
                        }
                    },
                    splitLine: {  //设置第二条y轴上的分隔线
                        show: false
                    }
                }
            ],
                series: [  //配置数据系列
                    {   //设置数据系列1
                        name: '坐标轴触发1', type: 'bar',
                        data: [
                            { value: 320, extra: 'Hello~' },
                            332, 300, 334, 390, 330, 320
                        ],
                        markLine: {  //设置标记线
                            data: [
                                {
                                    type: 'average', name: '平均值',
                                    itemStyle:  //设置标记点的样式
                                    {
                                        normal: { borderType: 'dotted', color: 'darkred' }
                                    },
                                }],
                        }
                    },
                    {   //设置数据系列2
                        name: '坐标轴触发2', type: 'bar',
                        data: [862, 1018, 964, 1026, 1679, 1600, 157],
                        markPoint: {  //设置标记点
                            data: [
                                {
                                    type: 'max', name: '最大值', symbol: 'diamond', symbolSize: 25,
                                    itemStyle: {  //设置标记点的样式
                                        normal: { color: 'red' }
                                    },
                                },
                                {
                                    type: 'min', name: '最小值', symbol: 'arrow', symbolSize: 20,
                                    itemStyle: {  //设置标记点的样式
                                        normal: { color: 'blue' }
                                    },
                                },
                            ]
                        },
                    },
                    {   //设置数据系列3
                        name: '数据项触发1', type: 'bar',
                        tooltip: {
                            trigger: 'item', backgroundColor: 'black', position: [0, 0],
                            formatter: "Series formatter: <br/>{a}<br/>{b}:{c}"
                        },
                        stack: '数据项',
                        data: [
                            120, 132,
                            {
                                value: 301, itemStyle: { normal: { color: 'red' } },
                                tooltip: {
                                    backgroundColor: 'blue',
                                    formatter: "Data formatter: <br/>{a}<br/>{b}:{c}"
                                }
                            },
                            134, 90,
                            { value: 230, tooltip: { show: false } },
                            210
                        ]
                    },
                    {   //设置数据系列4
                        name: '数据项触发2', type: 'bar',
                        tooltip: {
                            show: false, trigger: 'item'
                        },
                        stack: '数据项', data: [150, 232, 201, 154, 190, 330, 410]
                    }
                ]
        };

        //使用刚指定的配置项和数据显示图表
        myChart.setOption(option); 
    </script>
</body>

</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Flume是一个分布式、高可靠、高可用的日志收集系统,它的主要作用是将分布式环境中产生的海量数据进行汇聚和传输。Flume的核心组件包括Source、Channel和Sink,下面是这些组件常用配置: 1. Source组件配置:Source组件是Flume的数据输入源,常用的Source组件有ExecSource、AvroSource、NetcatSource等。它们的配置主要包括监听地址、端口号、日志格式、字符集等,具体如下: ``` # 监听地址和端口号 a1.sources.r1.type = netcat a1.sources.r1.bind = 0.0.0.0 a1.sources.r1.port = 44444 # 日志格式和字符集 a1.sources.r1.interceptors = i1 a1.sources.r1.interceptors.i1.type = regex_filter a1.sources.r1.interceptors.i1.regex = ^\[\d{4}-\d{2}-\d{2} a1.sources.r1.interceptors.i1.excludeEvents = false a1.sources.r1.interceptors.i1.charset = UTF-8 ``` 2. Channel组件配置:Channel组件是Flume的数据传输通道,常用的Channel组件有MemoryChannel、FileChannel、JDBCChannel等。它们的配置主要包括内存大小、数据保留时间、事务容量等,具体如下: ``` # 内存大小和事务容量 a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 # 数据保留时间 a1.channels.c1.keep-alive = 3m ``` 3. Sink组件配置:Sink组件是Flume的数据输出目标,常用的Sink组件有HDFS Sink、Kafka Sink、Avro Sink等。它们的配置主要包括输出地址、序列化格式、批处理大小等,具体如下: ``` # 输出地址和序列化格式 a1.sinks.k1.type = hdfs a1.sinks.k1.hdfs.path = /flume/%Y/%m/%d/%H/ a1.sinks.k1.hdfs.filePrefix = events- a1.sinks.k1.hdfs.fileSuffix = .log a1.sinks.k1.hdfs.rollInterval = 3600 a1.sinks.k1.hdfs.fileType = DataStream a1.sinks.k1.serializer = org.apache.flume.sink.hdfs.AvroEventSerializer$Builder # 批处理大小 a1.sinks.k1.batchSize = 1000 ``` 以上是Flume组件常用配置的一些示例,具体的配置内容和参数取决于具体的场景和需求。Flume支持丰富的配置选项,可以根据实际需要进行灵活配置

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值