可视化工具分享

Flask

简介

  • Flask是一个使用 Python 编写的轻量级 web 应用框架
  • 简单易用,上手快

安装使用

  • pip install flask

一个具体应用

  • 结构

    cloud/
    • static/
    • templates/
    • a.py
  • a.py解析
#!/usr/bin/env python
#encoding:utf-8
import sys
import time
import datetime
from flask import Flask,render_template,request,Markup

reload(sys)
sys.setdefaultencoding('utf8')

app=Flask(__name__)

def fun(position):
    f = open(position,"r")
    data = []
    for line in f:
        line = line.strip()
        li = line.split("|")
        if li[0]=='part' or li[0]=='plan':
            s = li[1]+":"+li[2]
            data.append(s)
    f.close()
    return data

@app.route("/C/<i>")
def indexC(i):
    dt = str(i)
    position = '/home/auto/'+dt+'_c_tag/'+'000000_0'
    data_C = fun(position)
    return render_template('cloud_C.html',data = data_C)

@app.route("/G/<i>")
def indexG(i):
    dt = str(i)
    position = '/home/auto/'+dt+'_g_tag/'+'000000_0'
    data_G = fun(position)
    return render_template('cloud_G.html',data = data_G)

if __name__=="__main__":
        app.run(host='0.0.0.0',debug=True)
  • 源数据格式
项目关键词人数时间项目标记
part鼻翼缩小111120160410wzx
planV脸11520160410wzx
planbotox26520160410wzx
plan下颌角磨削术19620160410wzx
plan中胚层疗法1020160410wzx
  • html所需数据格式
关键词人数
鼻翼缩小1111
V脸115
{"name": "微整形数据", "children": [{"name": "C", "children": [{"name": "atte", "children": [{"name": "1:1683"}, {"name": "2:228"}, {"name": "3:92"}, {"name": "4:51"}, {"name": "5:197"}]}, {"name": "part", "children": [{"name": "下巴:2552"}, {"name": "双眼皮:22552"}, {"name": "嘴部:982"}, {"name": "开眼角:2989"}, {"name": "毛发:2224"}, {"name": "泪沟:181"}....

Echart

一个词云的例子
<!DOCTYPE html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>微整形C网关键词热度预览</title>
</head>
<body>
    <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
    <div id="main" style="height:400px"></div>
    <!-- ECharts单文件引入 -->
    <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
    <script type="text/javascript">
        // 路径配置
        require.config({
            paths: {
                echarts: 'http://echarts.baidu.com/build/dist'
            }
        });

        // 使用
        require(
            [
                'echarts',
                'echarts/chart/wordCloud' // 使用什么图就对照官网加载什么模块,按需加载
            ],
            function (ec) {
                // 基于准备好的dom,初始化echarts图表
                var myChart = ec.init(document.getElementById('main'));



                        function createRandomItemStyle() {
                                return {
                                  normal: {
                                        color: 'rgb(' + [
                                        Math.round(Math.random() * 160),
                                        Math.round(Math.random() * 160),
                                        Math.round(Math.random() * 160)
            ].join(',') + ')'
        }
    };
}

var option = {
    title: {
        text: '微整形C网关键词热度预览',
        link: ''
    },
    tooltip: {
        show: true
    },
    series: [{
        name: '详情',
        type: 'wordCloud',
        size: ['49%', '95%'],
        textRotation : [0, 0, 0, 0],
        textPadding: 0,
        autoSize: {
            enable: true,
            minSize: 18
        },
        data: [
           {% for item in data %}
                   {
                   name:"{{item}}".split(":")[0],
                        value:"{{item}}".split(":")[1],
                        itemStyle: createRandomItemStyle()
                   },
                   {% endfor %}

        ]
    }]
};



                                // 为echarts对象加载数据
                myChart.setOption(option);
            }
        );
    </script>
</body>

ElasticSearch

简介

  • Lucene基于java,是一个库,需要在程序中引用,逻辑复杂
  • 分布式、实时、易扩展的全文搜索引擎,基于 Lucene
  • 简单易用,上手快

安装启动

重要概念

  • 集群
  • 节点
  • 分片和复制
  • 索引,类型,文档,域

使用

  • 可以直接将语句写进sh文件执行,也可以直接在命令行执行,查询语句是DSL语言,json格式
  • 检查集群健康 curl ‘localhost:9200/_cat/health?v’
epochtimestampclusterstatusnode.totalnode.datashardsprireloinitunassign
146482225507:04:15zl-esgreen225427000
  • 查看所有节点列表 curl ‘localhost:9200/_cat/nodes?v’
  • 查看所有索引列表 curl ‘localhost:9200/_cat/indices?v’
healthindexprirepdocs.countdocs.deletedstore.sizepri.store.size
greenmarvel-2016.06.011130227068.4mb35.1mb
greenbank15110000842.3kb423.6kb
greenbank5110000837.2kb418.6kb
greencustomer513016kb8kb
  • 创建索引curl -XPOST ‘localhost:9200/bank/account/_bulk?pretty’ –data-binary @/home/accounts.json
  • 更新update,删除delete,聚合操作,过滤查询……
  • DSL查询特点 curl -<REST Verb> <Node>:<Port>/<Index>/<Type><ID>
    更新一个字段的值
     curl -XPUT 'localhost:9200/customer/external/1?pretty' -d '
            {
              "name": "Jane Doe"
            }'

删除一个文档

curl -XDELETE 'localhost:9200/customer/external/_query?pretty' -d '
        {
          "query": { "match": { "name": "John" } }
        }'

返回地址中包含“mill”或者包含“lane”的账户

curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
        {
          "query": { "match": { "address": "mill lane" } }
        }' 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值