PHP+table生成柱状图

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<center>
<div style="border: 1px solid green; text-align: center; width: 1060px; font-size: 12px; height: 430px;">
<table width="1040" border="0">
  <tr>
    <td width="20" valign="top">
        <div style="height: 15px; margin-top: 45px;">600</div>
        <div style="height: 15px; margin-top: 45px;">500</div>
        <div style="height: 15px; margin-top: 45px;">400</div>
        <div style="height: 15px; margin-top: 45px;">300</div>
        <div style="height: 15px; margin-top: 45px;">200</div>                
        <div style="height: 15px; margin-top: 45px;">100</div>
        <div style="height: 15px; margin-top: 45px;">0</div>
    </td>
    <td valign="bottom">
<table width="1000" border="0" style="background: url(1.jpg)" height="420">
  <tr>
          <td> </td>
<?php 
for($i=0; $i<30; $i++){
?>
    <td height="400" width="10" valign="bottom" align="center"><?php $a=rand(0,360);echo intval($a/36*60)?><span style="background: pink; width: 20px; height: <?php echo $a?>px; display: inline-block;"></span></td>
    <td> </td>        
<?php        
}
?>
  </tr>
</table>    
    </td>
  </tr>
</table>
</div>
</center>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是基于 Vue.js 和 Element UI 组件库实现的柱状图示例: 1. 安装 Element UI 组件库并按需引入相应组件: ``` npm i element-ui -S ``` ```js // 在 main.js 中按需引入组件 import Vue from 'vue'; import { Button, Select, Option, Row, Col, Input, Form, FormItem, Loading, Message, MessageBox, Notification, Container, Header, Aside, Main, Menu, Submenu, MenuItem, MenuItemGroup, Breadcrumb, BreadcrumbItem, Card, Table, TableColumn, Pagination, Dialog, Dropdown, DropdownMenu, DropdownItem, Tabs, TabPane, Checkbox, CheckboxGroup, Radio, RadioGroup, Switch, DatePicker, TimePicker, Upload, Steps, Step, Carousel, CarouselItem, Tooltip, Popover, Alert, Tag, Badge, Progress, Tree, Cascader, Avatar, Divider, Image, Popconfirm, Slider, Transfer, ColorPicker, Scrollbar, Collapse, CollapseItem } from 'element-ui'; Vue.use(Button); Vue.use(Select); Vue.use(Option); Vue.use(Row); Vue.use(Col); Vue.use(Input); Vue.use(Form); Vue.use(FormItem); Vue.use(Loading.directive); Vue.prototype.$loading = Loading.service; Vue.prototype.$message = Message; Vue.prototype.$msgbox = MessageBox; Vue.prototype.$alert = MessageBox.alert; Vue.prototype.$confirm = MessageBox.confirm; Vue.prototype.$prompt = MessageBox.prompt; Vue.prototype.$notify = Notification; Vue.use(Container); Vue.use(Header); Vue.use(Aside); Vue.use(Main); Vue.use(Menu); Vue.use(Submenu); Vue.use(MenuItem); Vue.use(MenuItemGroup); Vue.use(Breadcrumb); Vue.use(BreadcrumbItem); Vue.use(Card); Vue.use(Table); Vue.use(TableColumn); Vue.use(Pagination); Vue.use(Dialog); Vue.use(Dropdown); Vue.use(DropdownMenu); Vue.use(DropdownItem); Vue.use(Tabs); Vue.use(TabPane); Vue.use(Checkbox); Vue.use(CheckboxGroup); Vue.use(Radio); Vue.use(RadioGroup); Vue.use(Switch); Vue.use(DatePicker); Vue.use(TimePicker); Vue.use(Upload); Vue.use(Steps); Vue.use(Step); Vue.use(Carousel); Vue.use(CarouselItem); Vue.use(Tooltip); Vue.use(Popover); Vue.use(Alert); Vue.use(Tag); Vue.use(Badge); Vue.use(Progress); Vue.use(Tree); Vue.use(Cascader); Vue.use(Avatar); Vue.use(Divider); Vue.use(Image); Vue.use(Popconfirm); Vue.use(Slider); Vue.use(Transfer); Vue.use(ColorPicker); Vue.use(Scrollbar); Vue.use(Collapse); Vue.use(CollapseItem); ``` 2. 在组件中使用 echarts 绘制柱状图并绑定数据: ```html <template> <div class="chart-container"> <div ref="chart" class="chart"></div> </div> </template> <script> import echarts from 'echarts'; export default { name: 'BarChart', data() { return { chartData: [ { month: '一月', sales: 1000 }, { month: '二月', sales: 1200 }, { month: '三月', sales: 800 }, { month: '四月', sales: 1500 }, { month: '五月', sales: 1300 }, { month: '六月', sales: 1700 }, { month: '七月', sales: 900 } ] } }, mounted() { // 基于准备好的dom,初始化echarts实例 let myChart = echarts.init(this.$refs.chart); // 指定图表的配置项和数据 let option = { title: { text: '月度销售额', subtext: '单位:元' }, tooltip: {}, xAxis: { data: this.chartData.map(item => item.month), axisLabel: { interval: 0, // 强制显示所有刻度标签 rotate: 45, // 旋转角度 margin: 10 // 刻度标签与轴线之间的距离 } }, yAxis: {}, series: [{ name: '销售额', type: 'bar', data: this.chartData.map(item => item.sales), itemStyle: { // 柱形图圆角 barBorderRadius: 5 } }] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); } } </script> <style scoped> .chart-container { width: 100%; height: 400px; display: flex; justify-content: center; align-items: center; } .chart { width: 80%; height: 80%; } </style> ``` 以上就是基于 Vue.js 和 Element UI 组件库实现的柱状图示例。其中,echarts 是一个非常强大的数据可视化库,可以通过配置项和数据来绘制各种类型的图表。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值