效果图:
实现思路一:
交叉表
另一个思路:
普通表格
缺点:无法实现内容 垂直居中显示
准备工作
一、数据准备
DROP TABLE IF EXISTS `address_item_sex_value`;
CREATE TABLE `address_item_sex_value` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`address` varchar(255) DEFAULT NULL,
`sex` varchar(255) DEFAULT NULL,
`item` varchar(255) DEFAULT NULL,
`value` int(11) DEFAULT NULL,
`proportion` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of address_item_sex_value
-- ----------------------------
INSERT INTO `address_item_sex_value` VALUES ('', '城区', '男生', '指标1', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '远郊', '男生', '指标1', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '近郊', '男生', '指标1', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '城区', '女生', '指标1', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '远郊', '女生', '指标1', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '近郊', '女生', '指标1', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '城区', '男生', '指标2', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '远郊', '男生', '指标2', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '近郊', '男生', '指标2', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '城区', '女生', '指标2', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '远郊', '女生', '指标2', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '近郊', '女生', '指标2', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '城区', '男生', '指标3', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '远郊', '男生', '指标3', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '近郊', '男生', '指标3', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '城区', '女生', '指标3', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '远郊', '女生', '指标3', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '近郊', '女生', '指标3', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '城区', '男生', '指标4', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '远郊', '男生', '指标4', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '近郊', '男生', '指标4', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '城区', '女生', '指标4', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '远郊', '女生', '指标4', '', '');
INSERT INTO `address_item_sex_value` VALUES ('', '近郊', '女生', '指标4', '', '');
二、设置SQL与字段
SELECT report.address_item_sex_value.id,
report.address_item_sex_value.address,
report.address_item_sex_value.sex,
report.address_item_sex_value.item,
report.address_item_sex_value.value,
1 a
FROM report.address_item_sex_value order by report.address_item_sex_value.address
SQL中有一个空闲的字段a、有一个默认值。很重要、是为了X轴的交叉表做考虑
三、设计列表
设置横列
1、选择字段a
2、设置total(按需要、这里不需要汇总列)
设置竖列
设置交叉值
四、设计显示
删除横列值
设置Column groups高度
设置高度为 0px
效果图
设置 水平居中、垂直居中
表头部分说一下
表头放在ColumnHeader里面,按需自己组装即可。
最终效果图