一零一、Flask-综合多图表展示(8个图表)

简介: 折线图、柱状图、散点图、条形图、饼图、雷达图、折线堆叠图、玫瑰图(8图表)目录

折线图


<script>
    var myCharts = echarts.init(document.getElementById("main1"))
    option = {
        title:{
            text: '折线图',
            textStyle:{
                color: 'red',
                fontWeight:'lighter',
                fontStyle:'italic'
            },
            subtext:'副标题'
        },
        legend: {},
        tooltip: {
            trigger : 'axis',
            axisPointer:{
                type: 'cross'
            }
        },
        xAxis:{
            type:'category',
            data: [1,2,3,4,5,6,7],
            axisLabel:{
                interval:0,
                rotate:20
            }
        },
        yAxis:{
            type: 'value',
            scale: true
        },
        series:{
            name:'数据',
            type: 'line',
            data:[12,32,34,41,31,25,21]
        }
    };
    myCharts.setOption(option);
</script>

柱状图


<script>
    var myChart1 = echarts.init(document.getElementById("main2"));
    option = {
        title: {
            text: '柱状图',
            textStyle :{
                color : 'red',
                fontWeight: 'lighter',
                fontStyle: 'italic'
            },
            subtext: '副标题'
        },
        legend: {},
        tooltip: {
            trigger : 'axis',
            axisPointer:{
                type: 'cross'
            }
        },
        xAxis:{
            type:'category',
            data: [1,2,3,4,5,6,7],
            axisLabel:{
                interval: 0,
                rotate: 20
            }
        },
        yAxis: {
            type: 'value',
            scale: true
        },
        series:[
        {
            name: '数据',
            type: 'bar',
            data: [34,23,45,27,56,21,34]
        }
        ]
    };
    myChart1.setOption(option);
</script>

散点图


<script>
    var myChart2 = echarts.init(document.getElementById("main3"));
    option = {
        title: {
            text: '散点图',
            textStyle :{
                color : 'red',
                fontWeight: 'lighter',
                fontStyle: 'italic'
            },
            subtext: '副标题'
        },
        legend: {},
        tooltip: {
            trigger : 'axis',
            axisPointer:{
                type: 'cross'
            }
        },
        xAxis:{
            type:'category',
            data: [1,2,3,4,5,6,7],
            axisLabel:{
                interval: 0,
                rotate: 20
            }
        },
        yAxis: {
            type: 'value',
            scale: true
        },
        series:[
        {
            name: '数据',
            type: 'scatter',
            data: [34,23,45,27,56,21,34]
        }
        ]
    };
    myChart2.setOption(option);
</script>

条形图


<script>
    var myChart3 = echarts.init(document.getElementById("main4"));
    option = {
        title: {
            text: '条形图',
            textStyle :{
                color : 'red',
                fontWeight: 'lighter',
                fontStyle: 'italic'
            },
            subtext: '副标题'
        },
        legend: {},
        tooltip: {
            trigger : 'axis',
            axisPointer:{
                type: 'cross'
            }
        },
        yAxis:{
            type:'category',
            data: [1,2,3,4,5,6,7],
            axisLabel:{
                interval: 0,
                rotate: 20
            }
        },
        xAxis: {
            type: 'value',
            scale: true
        },
        series:[
        {
            name: '数据',
            type: 'bar',
            data: [34,23,45,27,56,21,34]
        }
        ]
    };
    myChart3.setOption(option);
</script>

饼图


<script>
    var myChart4 = echarts.init(document.getElementById("main5"));
    option = {
        title: {
            text: '饼图',
            textStyle :{
                color : 'red',
                fontWeight: 'lighter',
                fontStyle: 'italic'
            },
            subtext: '副标题'
        },
        legend: {},
        tooltip: {
            trigger : 'item',
            formatter: '{a}<br />{b}:{c}({d}%)'
        },
        series:[
        {
            name: '数据',
            type: 'pie',
            data: [
            {value:23,name:'一号'},
            {value:20,name:'二号'},
            {value:31,name:'三号'},
            {value:26,name:'四号'}
            ]
        }
        ]
    };
    myChart4.setOption(option);
</script>

雷达图


 

<script>
    var myChart5 = echarts.init(document.getElementById("main6"));
    option = {
        title: {
            text: '雷达图',
            textStyle :{
                color : 'red',
                fontWeight: 'lighter',
                fontStyle: 'italic'
            },
            subtext: '副标题'
        },
        legend: {},
        tooltip: {
            trigger : 'item',
            formatter: '{a}<br />{b}:{c}({d}%)'
        },
        radar: {
        shape: 'circle',
        indicator: [
          { name: 'Sales', max: 6500 },
          { name: 'Administration', max: 16000 },
          { name: 'Information Technology', max: 30000 },
          { name: 'Customer Support', max: 38000 },
          { name: 'Development', max: 52000 },
          { name: 'Marketing', max: 25000 }
        ]
        },
        series: [
        {
          name: 'Budget vs spending',
          type: 'radar',
          data: [
            {
              value: [4200, 3000, 20000, 35000, 50000, 18000],
              name: 'Allocated Budget'
            },
            {
              value: [5000, 14000, 28000, 26000, 42000, 21000],
              name: 'Actual Spending'
            }
          ]
        }
        ]
    };
    myChart5.setOption(option);
</script>

折线堆叠图


<script>
    var myChart6 = echarts.init(document.getElementById("main7"));
    option = {
        title:{
            text: '折线堆叠图',
            textStyle:{
                color: 'red',
                fontWeight:'lighter',
                fontStyle:'italic'
            },
            subtext:'副标题'
        },
        legend: {},
        tooltip: {
            trigger : 'axis',
            axisPointer:{
                type: 'cross'
            }
        },
        xAxis:{
            type:'category',
            data: [1,2,3,4,5,6,7],
            axisLabel:{
                interval:0,
                rotate:20
            }
        },
        yAxis:{
            type: 'value',
            scale: true
        },
        series:[
            {
             name:'数据1',
             type: 'line',
             data:[220, 182, 191, 234, 290, 330, 310]
            },
            {
             name:'数据2',
             type: 'line',
             data:[120, 132, 101, 134, 90, 230, 210]
            },
            {
             name:'数据3',
             type: 'line',
             data:[150, 232, 201, 154, 190, 330, 410]
            },
        ]
    };
    myChart6.setOption(option);
</script>

玫瑰图


<script>
    var myChart7 = echarts.init(document.getElementById("main8"));
    option = {
        title: {
            text: '玫瑰图',
            textStyle :{
                color : 'red',
                fontWeight: 'lighter',
                fontStyle: 'italic'
            },
            subtext: '副标题'
        },
        legend: {},
        tooltip: {
            trigger : 'item',
            formatter: '{a}<br />{b}:{c}({d}%)'
        },
        series:[
        {
            name: '数据',
            type: 'pie',
            roseType: 'area',
            radius: [40,100],
            data: [
            {value:23,name:'一号'},
            {value:20,name:'二号'},
            {value:31,name:'三号'},
            {value:26,name:'四号'}
            ]
        }
        ]
    };
    myChart7.setOption(option);
</script>


效果展示


24.png

相关文章
|
19天前
|
移动开发 JavaScript 前端开发
Flask 结合 Highcharts 实现动态渲染图表
Flask 结合 Highcharts 实现动态渲染图表
|
11月前
|
前端开发 数据可视化 JavaScript
Python Flask Echarts数据可视化图表实战晋级笔记(4)ajax参数传递互动
Python Flask Echarts数据可视化图表实战晋级笔记(4)ajax参数传递互动
78 0
|
10月前
|
数据可视化 前端开发 JavaScript
利用 Flask 动态展示 Pyecharts 图表数据的几种方法
利用 Flask 动态展示 Pyecharts 图表数据的几种方法
|
11月前
|
数据可视化 Python
Python Flask Echarts数据可视化图表实战晋级笔记(3)Blueprint蓝图解决单文件url分发
Python Flask Echarts数据可视化图表实战晋级笔记(3)Blueprint蓝图解决单文件url分发
74 0
|
11月前
|
数据可视化 关系型数据库 MySQL
Python Flask Echarts数据可视化图表实战晋级笔记(2)@app.route装饰器的用法
Python Flask Echarts数据可视化图表实战晋级笔记(2)@app.route装饰器的用法
95 0
|
11月前
|
开发框架 JSON 数据可视化
Python Flask Echarts数据可视化图表实战晋级笔记(1)HTML页面渲染与参数传递
Python Flask Echarts数据可视化图表实战晋级笔记(1)HTML页面渲染与参数传递
165 1
|
移动开发 JavaScript 前端开发
Flask 结合 Highcharts 实现动态渲染图表
最近动态图表可以说火爆全网,我们当然可以通过很多第三方工具来实现该功能,既方便又美观。可是作为折腾不止的我们来说,有没有办法自己手动实现一个简易版的呢,答案当然是肯定的,今天我们就先来看一看如何基于 highcharts 完成上面的需求。
Flask 结合 Highcharts 实现动态渲染图表
|
19天前
|
API 数据库 数据安全/隐私保护
Flask框架在Python面试中的应用与实战
【4月更文挑战第18天】Django REST framework (DRF) 是用于构建Web API的强力工具,尤其适合Django应用。本文深入讨论DRF面试常见问题,包括视图、序列化、路由、权限控制、分页过滤排序及错误处理。同时,强调了易错点如序列化器验证、权限认证配置、API版本管理、性能优化和响应格式统一,并提供实战代码示例。了解这些知识点有助于在Python面试中展现优秀的Web服务开发能力。
33 1
|
13天前
|
应用服务中间件 nginx Docker
使用 Python Flask 创建简易文件上传服务
在平时工作中,文件上传是一项常见的需求,例如将应用异常时通过脚本生成的dump文件收集起来进行分析,但实现起来却可能相当复杂。幸运的是,Flask框架提供了一种简单而高效的方式来处理文件上传,代码不到100行。在本文中,我们将探讨如何使用Flask实现文件上传功能,编写Dockerfile将应用程序通过docker部署。
|
6天前
|
应用服务中间件 API nginx
使用Python和Flask构建RESTful Web API
使用Python和Flask构建RESTful Web API
17 0