微信小程序1

素颜马尾好姑娘i 2021-09-19 10:06 494阅读 0赞

小程序官方:

  1. https://mp.weixin.qq.com

小程序开发文档:

  1. https://developers.weixin.qq.com/miniprogram/dev/index.html

微信开发社区:

  1. https://developers.weixin.qq.com/

image.png

WePY命令行工具

  1. npm install wepy-cli -g

在开发目录中生成Demo开发项目

  1. wepy new myproject
  2. # 1.7.0之后的版本使用 wepy init standard myproject 初始化项目

切换至项目目录

  1. cd myproject

安装依赖

  1. npm install

开启实时编译

  1. wepy build --watch

项目的目录结构:

  1. ├── dist 小程序运行代码目录(该目录由WePYbuild指令自动编译生成,请不要直接修改该目录下的文件)
  2. ├── node_modules
  3. ├── src 代码编写的目录(该目录为使用WePY后的开发目录)
  4. | ├── components WePY组件目录(组件不属于完整页面,仅供完整页面或其他组件引用)
  5. | | ├── com_a.wpy 可复用的WePY组件a
  6. | | └── com_b.wpy 可复用的WePY组件b
  7. | ├── pages WePY页面目录(属于完整页面)
  8. | | ├── index.wpy index页面(经build后,会在dist目录下的pages目录生成index.jsindex.jsonindex.wxmlindex.wxss文件)
  9. | | └── other.wpy other页面(经build后,会在dist目录下的pages目录生成other.jsother.jsonother.wxmlother.wxss文件)
  10. | └── app.wpy 小程序配置项(全局数据、样式、声明钩子等;经build后,会在dist目录下生成app.jsapp.jsonapp.wxss文件)
  11. └── package.json 项目的package配置

wepy 微信小程序

小程序组件化开发框架 https://tencent.github.io/wepy/

image.png

image.png

  1. <style lang="less">
  2. @color: #4D926F;
  3. .userinfo {
  4. color: @color;
  5. }
  6. </style>
  7. <template lang="pug">
  8. view(class='container')
  9. view(class='userinfo' @tap='tap')
  10. mycom(:prop.sync='myprop' @fn.user='myevent')
  11. text {
  12. {now}}
  13. </template>
  14. <script>
  15. import wepy from 'wepy';
  16. import mycom from '../components/mycom';
  17. export default class Index extends wepy.page {
  18. components = { mycom };
  19. data = {
  20. myprop: {}
  21. };
  22. computed = {
  23. now () { return new Date().getTime(); }
  24. };
  25. async onLoad() {
  26. await sleep(3);
  27. console.log('Hello World');
  28. }
  29. sleep(time) {
  30. return new Promise((resolve, reject) => setTimeout(resolve, time * 1000));
  31. }
  32. }
  33. </script>

安装使用

  1. npm install wepy-cli -g
  2. wepy init standard myproject
  3. cd myproject
  4. npm install
  5. wepy build --watch

image.png

image.png

image.png

image.png

image.png

Highcharts

Report abuse

Highcharts中文官网

hcharts实现堆叠柱形图
https://www.jianshu.com/p/582299e18c7e

GIF.gif

  1. <!DOCTYPE >
  2. <html>
  3. <head>
  4. <meta charset="utf-8"><link rel="icon" href="https://static.jianshukeji.com/highcharts/images/favicon.ico">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <script src="https://img.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
  7. <script src="https://img.hcharts.cn/highcharts/highcharts.js"></script>
  8. <script src="https://img.hcharts.cn/highcharts/modules/exporting.js"></script>
  9. <script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>
  10. </head>
  11. <body>
  12. <div id="container" style="width:800px;height:400px"></div>
  13. <script>
  14. $(function () {
  15. $('#container').highcharts({
  16. chart: {
  17. type: 'column'
  18. },
  19. title: {
  20. text: '堆叠柱形图'
  21. },
  22. xAxis: {
  23. categories: ['三年级一班', '三年级二班', '三年三班', '三年级四班', '三年级五班']
  24. },
  25. yAxis: {
  26. min: 0,
  27. title: {
  28. text: ''
  29. },
  30. stackLabels: {
  31. enabled: true,
  32. style: {
  33. fontWeight: 'bold',
  34. color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
  35. }
  36. }
  37. },
  38. legend: {
  39. align: 'right',
  40. x: -30,
  41. verticalAlign: 'top',
  42. y: 25,
  43. floating: true,
  44. backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
  45. borderColor: '#CCC',
  46. borderWidth: 1,
  47. shadow: false
  48. },
  49. tooltip: {
  50. formatter: function () {
  51. return '<b>' + this.x + '</b><br/>' +
  52. this.series.name + ': ' + this.y + '<br/>' +
  53. '总量: ' + this.point.stackTotal;
  54. }
  55. },
  56. plotOptions: {
  57. column: {
  58. stacking: 'normal',
  59. dataLabels: {
  60. enabled: true,
  61. color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
  62. style: {
  63. textShadow: '0 0 3px black'
  64. }
  65. }
  66. }
  67. },
  68. series: [{
  69. name: '未到',
  70. data: [1, 1, 2, 1, 2]
  71. }, {
  72. name: '迟到',
  73. data: [2, 2, 3, 2, 1]
  74. }, {
  75. name: '已到',
  76. data: [8, 9, 10, 11, 12]
  77. }]
  78. });
  79. });
  80. </script>
  81. </body>
  82. </html>

image.png

lang:语言文字对象,所有Highcharts文字相关的设置
chart:图表区、图形区和通用图表配置选项
colors:图表数据列颜色配置,是一个颜色数组
credits: 版权信息,Highcharts在图表的右下方放置的版权信息及链
drilldown:钻取,向下钻取数据,深入到其中的具体数据
exporting:导出模块,导出功能配置,导出即将图表下载为图片或打印图表
legend:图例,用不同形状、颜色、文字等 标示不同数据列,通过点击标示可以显示或隐藏该数据列
loading:加载中,加载选项控制覆盖绘图区的加载屏的外观和文字
navigation:导航,导出模块按钮和菜单配置选项组
noData:没有数据,没有数据时显示的内容
pane:分块,针对仪表图和雷达图专用的配置,主要设置弧度及背景色
plotOptions:针对不同类型图表的配置
series:数据列,图表上一个或多个数据系列,比如图表中的一条曲线,一个柱形
title:标题,包括即标题和副标题,其中副标题为非必须的
tooltip:数据点提示框,当鼠标滑过某点时,以框的形式提示改点的数据,比如该点的值,数据单位等
Axis:坐标轴,包括x轴和y轴。多个不同的数据列可共用同一个X轴或Y轴

图表类型
line:直线图
spline:曲线图
area:面积图
areaspline:曲线面积图
arearange:面积范围图
areasplinerange:曲线面积范围图
column:柱状图
columnrange:柱状范围图
bar:条形图
pie:饼图
scatter:散点图
boxplot:箱线图
bubble:气泡图
errorbar:误差线图
funnel:漏斗图
gauge:仪表图
waterfall:瀑布图
polar:雷达图
pyramid:金字塔

  1. 全局配置
  2. Highcharts.setOptions({global: {全局参数}
  3. lang: {语言文字}
  4. });
  5. 主配置
  6. Highcharts.chart('container', {accessibility: {无障碍设计}
  7. chart: {图表配置}
  8. colors: [颜色集合]
  9. credits: {版权信息}
  10. data: {数据功能模块}
  11. drilldown: {钻取}
  12. exporting: {导出}
  13. labels: {标签}
  14. legend: {图例}
  15. loading: {加载}
  16. navigation: {导航}
  17. noData: {没有数据}
  18. pane: {…}
  19. plotOptions: {数据列配置}
  20. responsive: {响应式}
  21. series: [{数据列}]
  22. subtitle: {副标题}
  23. title: {标题}
  24. tooltip: {数据提示框}
  25. xAxis: [{X 轴}]
  26. yAxis: [{Y 轴}]
  27. zAxis: {Z 轴}
  28. });
  29. 函数及属性
  30. Axis: {坐标轴}
  31. Chart: {图表对象}
  32. Element: {SVG 元素}
  33. Highcharts: {命名空间}
  34. Legend: {图例}
  35. Point: {数据点}
  36. Renderer: {绘图工具}
  37. Series: {数据列}

补充了这位作者的效果图

https://www.jianshu.com/p/582299e18c7e

发表评论

表情:
评论列表 (有 0 条评论,494人围观)

还没有评论,来说两句吧...

相关阅读