精华内容
下载资源
问答
  • 动态曲线绘制

    2012-10-14 13:01:17
    在VC6.0中实现了曲线动态变化,感兴趣的可以研究研究
  • matplotlib动态显示变化曲线一级目录出现异常完整源码动图显示数据文件 一级目录 出现异常 完整源码 # %matplotlib qt import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as ...

    matplotlib动态显示变化曲线

    完整源码

    # %matplotlib qt
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.animation as animation
    import pandas as pd
    import random
    import PIL.Image
    # 字体管理
    from matplotlib import font_manager
    
    df0 = pd.read_csv("./【冰冰vlog.003】出 差 摸 鱼 逛 北 京_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili.csv")
    data = df0.copy()
    # 获取本地的字体
    my_font = font_manager.FontProperties(fname=r"C:\Windows\Fonts\SimHei.ttf",size=16)
    x1 = list(range(data.shape[0]))
    
    y = data["总播放数"].tolist()
    y2 =data["在线人数"].tolist()
    y3 =data["历史累计弹幕数"].tolist()
    y4 =data["点赞数"].tolist()
    
    # 设置画布的大小 400x800
    # fig ,ax =plt.subplots(figsize = (8,4))
    fig = plt.figure(figsize = (4,3))
    # 子图分组显示显示
    ax1 = fig.add_subplot(2, 2, 1)
    ax2 = fig.add_subplot(2, 2, 2)
    ax3 = fig.add_subplot(2, 2, 3)
    ax4 = fig.add_subplot(2, 2, 4)
    # fig.tight_layout()
    plt.tight_layout()
    
    # 动态变化函数
    def drawBarh(index):
        # 清除所有坐标
        ax1.clear()
        ax2.clear()
        ax3.clear()
        ax4.clear()
        #截取部分列表
        x = x1[:index+1]
        ax1.plot(x,y[:index+1])
        # 坐标的右侧显示序号
        ax1.set_title(f"总播放数实时变化",fontproperties=my_font)
        # x轴范围
        ax1.set_xlim(0,index+2)
        
        ax2.plot(x,y2[:index+1])
        # 坐标的右侧显示序号
        ax2.set_title("在线人数实时变化",fontproperties=my_font)
        # x轴范围
        ax2.set_xlim(0,index+2)
        
        ax3.plot(x,y3[:index+1])
        # 坐标的右侧显示序号
        ax3.set_title(f"历史累计弹幕数实时变化",fontproperties=my_font)
        # x轴范围
        ax3.set_xlim(0,index+2)
        
        ax4.plot(x,y4[:index+1])
        # 坐标的右侧显示序号
        ax4.set_title(f"点赞数实时变化",fontproperties=my_font)
        # x轴范围
        ax4.set_xlim(0,index+2)
        
    # 开启动画,左侧animator不能省略
    # func是更新图像的函数,frame是显示多少帧(100帧),interval是相邻帧的毫秒,init_func是初始时的函数
    animator = animation.FuncAnimation(fig,func=drawBarh,frames=range(100),interval=5)
    #保存到本地gif文件,figsize = (4,8),figsize乘积越大,文件越大
    animator.save(filename="dynamic.gif",writer="pillow")
    # 窗口显示
    plt.show()
    

    动图显示

    图片最大上传5M,只截取了部分

    在这里插入图片描述

    csv数据文件

    【冰冰vlog.003】出 差 摸 鱼 逛 北 京_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili.csv

    记录时间,总播放数,历史累计弹幕数,在线人数,弹幕池,点赞数,投币数/,收藏数/,分享数/,关注数/,评论数
    2021-01-21 12:54:22.845251,6273198,57283,500,2000,862306,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:54:40.911291,6273862,57283,507,2000,862312,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:54:59.270229,6273862,57283,507,2000,862319,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:55:17.436037,6273862,57283,507,2000,862324,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:55:35.819148,6273862,57283,507,2000,862334,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:55:54.241708,6274520,57283,504,2000,862342,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:56:12.486874,6274520,57283,504,2000,862355,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:56:30.809879,6274520,57283,504,2000,862362,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:56:49.145686,6274520,57283,482,2000,862368,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:57:07.642655,6275179,57283,482,2000,862376,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:57:26.322224,6275179,57283,482,2000,862389,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:57:45.412648,6275179,57283,484,2000,862397,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:58:03.619199,6275179,57283,484,2000,862405,64.9,16.3,5.7,360.1,40912
    2021-01-21 12:58:22.187356,6275179,57284,484,2000,862412,64.9,16.3,5.7,360.1,40912
    2021-01-21 13:02:00.775022,6277147,57290,537,2000,862516,64.9,16.3,5.7,360.1,40912
    2021-01-21 13:02:19.119774,6277782,57291,537,2000,862521,64.9,16.3,5.7,360.2,40912
    2021-01-21 13:02:37.351956,6277782,57291,530,2000,862529,64.9,16.3,5.7,360.2,40913
    2021-01-21 13:02:55.934714,6277782,57292,530,2000,862535,64.9,16.3,5.7,360.2,40913
    2021-01-21 13:03:14.625351,6277782,57293,530,2000,862544,64.9,16.3,5.7,360.2,40913
    2021-01-21 13:03:32.955119,6278381,57294,529,2000,862558,64.9,16.3,5.7,360.2,40913
    2021-01-21 13:03:51.317792,6278381,57297,529,2000,862570,64.9,16.3,5.7,360.2,40913
    2021-01-21 13:04:09.907611,6278381,57297,529,2000,862581,64.9,16.3,5.7,360.2,40913
    2021-01-21 13:04:28.564220,6278381,57297,529,2000,862587,64.9,16.3,5.7,360.2,40913
    2021-01-21 13:04:47.137274,6279047,57297,519,2000,862602,64.9,16.3,5.7,360.2,40913
    2021-01-21 13:05:05.438934,6279047,57297,519,2000,862618,64.9,16.3,5.7,360.2,40914
    2021-01-21 13:05:23.880210,6279047,57299,522,2000,862626,64.9,16.3,5.7,360.2,40914
    2021-01-21 13:05:42.280774,6279047,57299,522,2000,862633,64.9,16.3,5.7,360.2,40914
    2021-01-21 13:06:00.791698,6279654,57300,521,2000,862645,64.9,16.3,5.7,360.2,40914
    2021-01-21 13:06:19.404042,6279654,57301,521,2000,862654,64.9,16.3,5.7,360.2,40914
    2021-01-21 13:06:37.860494,6279654,57301,521,2000,862659,64.9,16.3,5.7,360.2,40915
    2021-01-21 13:06:56.489757,6279654,57301,521,2000,862662,64.9,16.3,5.7,360.2,40915
    2021-01-21 13:07:14.819898,6280284,57301,510,2000,862671,64.9,16.3,5.7,360.2,40915
    2021-01-21 13:07:33.471216,6280284,57301,510,2000,862682,64.9,16.3,5.7,360.2,40916
    2021-01-21 13:07:52.189844,6280284,57301,510,2000,862690,64.9,16.3,5.7,360.2,40916
    2021-01-21 13:08:10.593916,6280284,57301,514,2000,862697,64.9,16.3,5.7,360.2,40916
    2021-01-21 13:08:28.866461,6280910,57301,514,2000,862702,64.9,16.3,5.7,360.2,40917
    2021-01-21 13:08:47.076281,6280910,57301,514,2000,862709,64.9,16.3,5.7,360.2,40917
    2021-01-21 13:09:05.373801,6280910,57301,516,2000,862718,64.9,16.3,5.7,360.2,40917
    2021-01-21 13:09:23.723391,6280910,57301,516,2000,862727,64.9,16.3,5.7,360.2,40917
    2021-01-21 13:09:42.084018,6281481,57302,516,2000,862737,64.9,16.3,5.7,360.2,40918
    2021-01-21 13:10:00.470659,6281481,57302,516,2000,862740,64.9,16.3,5.7,360.2,40918
    2021-01-21 13:10:18.708522,6281481,57303,505,2000,862751,64.9,16.3,5.7,360.2,40918
    2021-01-21 13:10:37.779291,6281481,57303,505,2000,862757,64.9,16.3,5.7,360.2,40918
    2021-01-21 13:10:56.371347,6282087,57305,505,2000,862762,64.9,16.3,5.7,360.2,40918
    2021-01-21 13:11:15.181843,6282087,57308,505,2000,862769,64.9,16.3,5.7,360.2,40919
    2021-01-21 13:11:33.524795,6282087,57310,496,2000,862776,64.9,16.3,5.7,360.2,40919
    2021-01-21 13:11:51.992297,6282087,57311,496,2000,862780,64.9,16.3,5.7,360.2,40919
    2021-01-21 13:12:10.305128,6282671,57311,496,2000,862785,64.9,16.3,5.7,360.2,40919
    2021-01-21 13:12:28.602343,6282671,57312,496,2000,862795,64.9,16.3,5.7,360.2,40919
    2021-01-21 13:12:46.849825,6282671,57312,487,2000,862800,64.9,16.3,5.7,360.2,40919
    2021-01-21 13:13:05.107207,6282671,57312,487,2000,862806,64.9,16.3,5.7,360.2,40919
    2021-01-21 13:13:23.430762,6282671,57312,487,2000,862810,65.0,16.3,5.7,360.2,40919
    2021-01-21 13:13:41.777914,6283291,57313,491,2000,862819,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:14:00.257808,6283291,57313,491,2000,862826,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:14:18.508586,6283291,57313,491,2000,862835,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:14:36.682074,6283291,57313,497,2000,862847,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:14:55.066460,6283974,57313,497,2000,862851,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:15:13.326587,6283974,57314,497,2000,862860,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:15:31.637312,6283974,57314,500,2000,862868,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:15:50.245370,6283974,57314,500,2000,862874,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:16:09.854642,6284663,57314,500,2000,862884,65.0,16.3,5.7,360.2,40920
    2021-01-21 13:16:28.263861,6284663,57314,500,2000,862889,65.0,16.3,5.7,360.2,40921
    2021-01-21 13:16:46.687915,6284663,57314,500,2000,862898,65.0,16.3,5.7,360.2,40921
    2021-01-21 13:17:05.233559,6284663,57314,500,2000,862909,65.0,16.3,5.7,360.2,40921
    2021-01-21 13:17:25.477147,6285324,57314,500,2000,862918,65.0,16.3,5.7,360.2,40921
    2021-01-21 13:17:44.098271,6285324,57315,500,2000,862925,65.0,16.3,5.7,360.2,40921
    2021-01-21 13:18:02.668713,6285324,57315,505,2000,862935,65.0,16.3,5.7,360.2,40921
    2021-01-21 13:18:21.462343,6285324,57316,505,2000,862941,65.0,16.3,5.7,360.2,40922
    2021-01-21 13:18:39.847659,6285925,57316,505,2000,862948,65.0,16.3,5.7,360.2,40923
    2021-01-21 13:18:58.188437,6285925,57316,505,2000,862957,65.0,16.3,5.7,360.2,40923
    2021-01-21 13:19:16.769615,6285925,57316,505,2000,862965,65.0,16.3,5.7,360.2,40923
    2021-01-21 13:19:35.168820,6285925,57318,505,2000,862971,65.0,16.3,5.7,360.2,40923
    2021-01-21 13:19:53.536361,6286552,57318,499,2000,862981,65.0,16.3,5.7,360.2,40923
    2021-01-21 13:20:12.093410,6286552,57319,499,2000,862989,65.0,16.3,5.7,360.2,40923
    2021-01-21 13:20:30.545320,6286552,57319,499,2000,862996,65.0,16.3,5.7,360.3,40923
    2021-01-21 13:20:49.043211,6286552,57320,504,2000,863003,65.0,16.3,5.7,360.3,40923
    2021-01-21 13:21:07.439669,6287182,57320,504,2000,863012,65.0,16.3,5.7,360.3,40923
    2021-01-21 13:21:27.500054,6287182,57320,504,2000,863015,65.0,16.3,5.7,360.3,40923
    2021-01-21 13:21:46.278173,6287182,57320,503,2000,863027,65.0,16.3,5.7,360.3,40923
    2021-01-21 13:22:04.769696,6287182,57320,503,2000,863035,65.0,16.3,5.7,360.3,40923
    2021-01-21 13:22:23.847253,6287829,57320,503,2000,863042,65.0,16.3,5.7,360.3,40923
    2021-01-21 13:22:43.487747,6287829,57320,497,2000,863051,65.0,16.3,5.7,360.3,40923
    2021-01-21 13:23:02.109775,6287829,57321,497,2000,863055,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:23:20.821036,6287829,57321,497,2000,863067,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:23:39.936736,6288484,57321,496,2000,863070,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:23:58.999271,6288484,57321,496,2000,863076,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:24:17.631011,6288484,57323,496,2000,863079,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:24:36.010972,6288484,57323,496,2000,863085,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:24:54.900750,6289113,57323,493,2000,863094,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:25:13.310483,6289113,57325,493,2000,863099,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:25:31.802185,6289113,57327,493,2000,863105,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:25:50.270553,6289113,57330,491,2000,863111,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:26:09.047424,6289754,57330,491,2000,863117,65.0,16.3,5.7,360.3,40924
    2021-01-21 13:26:27.639828,6289754,57331,491,2000,863126,65.0,16.3,5.7,360.3,40925
    2021-01-21 13:26:46.256615,6289754,57332,472,2000,863131,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:27:04.710389,6289754,57332,472,2000,863141,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:27:23.222052,6290424,57332,475,2000,863148,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:27:41.748394,6290424,57333,475,2000,863153,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:28:00.135362,6290424,57333,475,2000,863158,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:28:18.350612,6290424,57333,475,2000,863164,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:28:36.791657,6291111,57333,475,2000,863175,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:28:55.063986,6291111,57333,485,2000,863187,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:29:13.523369,6291111,57334,485,2000,863198,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:29:31.762405,6291111,57335,485,2000,863211,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:29:50.050726,6291746,57336,479,2000,863220,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:30:08.731222,6291746,57337,479,2000,863230,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:30:27.078636,6291746,57337,479,2000,863239,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:30:45.510245,6291746,57337,479,2000,863249,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:31:03.703120,6292401,57340,479,2000,863256,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:31:21.885961,6292401,57340,479,2000,863260,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:31:40.236066,6292401,57340,486,2000,863264,65.0,16.3,5.7,360.3,40926
    2021-01-21 13:31:58.494969,6292401,57340,486,2000,863277,65.0,16.3,5.7,360.3,40927
    2021-01-21 13:32:16.773487,6293000,57340,486,2000,863283,65.0,16.3,5.7,360.3,40927
    2021-01-21 13:32:35.218800,6293000,57341,486,2000,863288,65.0,16.3,5.7,360.3,40927
    2021-01-21 13:32:53.379104,6293000,57342,487,2000,863294,65.0,16.3,5.7,360.3,40928
    2021-01-21 13:33:11.554672,6293000,57342,487,2000,863309,65.0,16.3,5.7,360.3,40928
    2021-01-21 13:33:29.825050,6293607,57343,487,2000,863314,65.0,16.3,5.7,360.3,40928
    2021-01-21 13:33:48.114913,6293607,57343,484,2000,863319,65.0,16.3,5.7,360.3,40929
    2021-01-21 13:34:06.435116,6293607,57343,484,2000,863325,65.0,16.3,5.7,360.3,40930
    2021-01-21 13:34:24.879506,6293607,57343,484,2000,863331,65.0,16.3,5.7,360.3,40931
    2021-01-21 13:34:43.211531,6294184,57343,478,2000,863339,65.0,16.3,5.7,360.3,40931
    2021-01-21 13:35:01.541331,6294184,57343,478,2000,863345,65.0,16.3,5.7,360.3,40931
    2021-01-21 13:35:19.873349,6294184,57346,478,2000,863352,65.0,16.3,5.7,360.3,40931
    2021-01-21 13:35:38.486096,6294184,57346,475,2000,863355,65.0,16.3,5.7,360.3,40931
    2021-01-21 13:35:57.469875,6294752,57346,475,2000,863359,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:36:16.639375,6294752,57347,475,2000,863362,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:36:36.734376,6294752,57347,478,2000,863369,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:36:56.466002,6294752,57347,478,2000,863380,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:37:14.936976,6295357,57347,478,2000,863387,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:37:33.723933,6295357,57347,479,2000,863391,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:37:54.146741,6295357,57347,479,2000,863396,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:38:12.480064,6295357,57347,479,2000,863404,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:38:31.535295,6295962,57347,463,2000,863414,65.0,16.3,5.7,360.3,40932
    2021-01-21 13:38:50.200032,6295962,57348,463,2000,863420,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:39:08.595446,6295962,57349,463,2000,863427,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:39:27.130033,6295962,57349,476,2000,863435,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:39:45.824251,6296560,57350,476,2000,863440,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:40:04.452187,6296560,57351,476,2000,863446,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:40:23.020047,6296560,57352,479,2000,863449,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:40:41.637949,6296560,57352,479,2000,863456,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:41:00.342555,6297155,57352,479,2000,863461,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:41:18.918608,6297155,57353,484,2000,863466,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:41:37.206375,6297155,57353,484,2000,863477,65.0,16.3,5.7,360.3,40933
    2021-01-21 13:42:13.988291,6297699,57354,488,2000,863494,65.0,16.3,5.7,360.4,40934
    2021-01-21 13:42:32.710200,6297699,57354,488,2000,863505,65.0,16.3,5.7,360.4,40934
    2021-01-21 13:42:51.557303,6297699,57354,483,2000,863512,65.0,16.3,5.7,360.4,40934
    2021-01-21 13:43:10.452219,6297699,57354,483,2000,863522,65.0,16.3,5.7,360.4,40934
    2021-01-21 13:43:29.106362,6298229,57354,483,2000,863530,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:43:48.136714,6298229,57354,483,2000,863540,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:44:06.676999,6298229,57354,478,2000,863553,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:44:25.036156,6298229,57354,478,2000,863561,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:44:43.770403,6298811,57354,478,2000,863565,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:45:02.082217,6298811,57355,478,2000,863575,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:45:20.589041,6298811,57355,478,2000,863579,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:45:39.178815,6298811,57355,478,2000,863588,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:45:57.494812,6299347,57355,476,2000,863594,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:46:15.873082,6299347,57355,476,2000,863600,65.0,16.3,5.7,360.4,40935
    2021-01-21 13:46:34.328208,6299347,57355,472,2000,863605,65.0,16.3,5.7,360.4,40936
    2021-01-21 13:46:52.778324,6299347,57355,472,2000,863611,65.0,16.3,5.7,360.4,40936
    2021-01-21 13:47:11.719008,6299347,57356,472,2000,863620,65.0,16.3,5.7,360.4,40936
    2021-01-21 13:47:30.054727,6299900,57356,481,2000,863625,65.0,16.3,5.7,360.4,40936
    2021-01-21 13:47:48.668631,6299900,57356,481,2000,863630,65.0,16.3,5.7,360.4,40936
    2021-01-21 13:48:07.102425,6299900,57356,481,2000,863637,65.0,16.3,5.7,360.4,40936
    2021-01-21 13:48:25.834069,6299900,57356,481,2000,863642,65.0,16.3,5.7,360.4,40936
    2021-01-21 13:48:44.628243,6300405,57357,471,2000,863647,65.0,16.3,5.7,360.4,40936
    2021-01-21 13:49:03.755301,6300405,57357,471,2000,863652,65.0,16.3,5.7,360.4,40937
    2021-01-21 13:49:22.278786,6300405,57357,473,2000,863661,65.0,16.3,5.7,360.4,40937
    2021-01-21 13:49:40.810696,6300405,57357,473,2000,863669,65.0,16.3,5.7,360.4,40937
    2021-01-21 13:49:59.731218,6300913,57357,473,2000,863679,65.0,16.3,5.7,360.4,40937
    2021-01-21 13:50:18.703496,6300913,57357,473,2000,863688,65.0,16.3,5.7,360.4,40937
    2021-01-21 13:50:37.729830,6300913,57357,473,2000,863696,65.0,16.3,5.7,360.4,40937
    2021-01-21 13:50:57.193773,6300913,57357,473,2000,863697,65.0,16.3,5.7,360.4,40937
    2021-01-21 13:51:15.761855,6301422,57357,473,2000,863700,65.0,16.3,5.7,360.4,40938
    2021-01-21 13:51:34.339963,6301422,57357,491,2000,863708,65.0,16.3,5.7,360.4,40938
    2021-01-21 13:51:52.763512,6301422,57357,491,2000,863715,65.0,16.3,5.7,360.4,40938
    2021-01-21 13:52:12.371342,6301422,57358,491,2000,863719,65.0,16.3,5.7,360.4,40938
    2021-01-21 13:52:31.889798,6301937,57359,480,2000,863730,65.0,16.3,5.7,360.4,40939
    2021-01-21 13:52:50.716041,6301937,57359,480,2000,863737,65.0,16.3,5.7,360.4,40939
    2021-01-21 13:53:09.315973,6301937,57359,480,2000,863740,65.0,16.3,5.7,360.4,40940
    2021-01-21 13:53:28.079973,6302452,57359,489,2000,863746,65.0,16.3,5.7,360.4,40940
    2021-01-21 13:53:47.284230,6302452,57359,489,2000,863749,65.0,16.3,5.7,360.4,40940
    2021-01-21 13:54:06.566459,6302452,57359,489,2000,863752,65.0,16.3,5.7,360.4,40940
    2021-01-21 13:54:25.014846,6302452,57360,479,2000,863761,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:54:43.526268,6302930,57360,479,2000,863765,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:55:01.987576,6302930,57360,479,2000,863769,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:55:20.325235,6302930,57360,469,2000,863777,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:55:38.723830,6302930,57361,469,2000,863784,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:55:57.162152,6302930,57361,469,2000,863787,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:56:15.584196,6303379,57361,461,2000,863789,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:56:33.993270,6303379,57362,461,2000,863797,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:56:52.780238,6303379,57362,461,2000,863805,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:57:11.134010,6303379,57362,461,2000,863816,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:57:29.234765,6303852,57362,463,2000,863826,65.0,16.3,5.7,360.4,40941
    2021-01-21 13:57:47.382045,6303852,57362,463,2000,863832,65.0,16.3,5.7,360.4,40943
    2021-01-21 13:58:05.494805,6303852,57362,454,2000,863840,65.0,16.3,5.7,360.4,40943
    2021-01-21 13:58:23.624442,6303852,57362,454,2000,863841,65.0,16.3,5.7,360.4,40944
    2021-01-21 13:58:41.767006,6304370,57363,454,2000,863847,65.0,16.3,5.7,360.4,40944
    2021-01-21 13:58:59.535755,6304370,57363,449,2000,863853,65.0,16.3,5.7,360.4,40945
    2021-01-21 13:59:17.431118,6304370,57363,449,2000,863859,65.0,16.3,5.7,360.4,40945
    2021-01-21 13:59:35.252657,6304370,57363,449,2000,863862,65.0,16.3,5.7,360.4,40945
    2021-01-21 13:59:53.067588,6304897,57363,449,2000,863863,65.0,16.3,5.7,360.4,40945
    2021-01-21 14:00:11.409650,6304897,57363,450,2000,863868,65.0,16.3,5.7,360.4,40945
    2021-01-21 14:00:29.865693,6304897,57363,450,2000,863874,65.0,16.3,5.7,360.4,40946
    2021-01-21 14:00:48.650979,6304897,57364,450,2000,863881,65.0,16.3,5.7,360.4,40947
    2021-01-21 14:01:09.478696,6305418,57364,455,2000,863889,65.0,16.3,5.7,360.4,40949
    2021-01-21 14:01:28.277839,6305418,57364,455,2000,863902,65.0,16.3,5.7,360.4,40949
    2021-01-21 14:01:47.285444,6305418,57364,465,2000,863903,65.0,16.3,5.7,360.4,40949
    2021-01-21 14:02:06.063115,6305418,57365,465,2000,863912,65.0,16.3,5.7,360.4,40949
    2021-01-21 14:02:24.657699,6305917,57365,465,2000,863917,65.0,16.3,5.7,360.4,40949
    2021-01-21 14:02:43.960861,6305917,57365,461,2000,863922,65.0,16.3,5.7,360.4,40949
    2021-01-21 14:03:02.899984,6305917,57366,461,2000,863926,65.0,16.3,5.7,360.4,40950
    2021-01-21 14:03:21.486061,6305917,57367,461,2000,863933,65.0,16.3,5.7,360.4,40950
    2021-01-21 14:03:41.729174,6306422,57367,476,2000,863936,65.0,16.3,5.7,360.4,40952
    2021-01-21 14:04:01.175806,6306422,57368,476,2000,863939,65.0,16.3,5.7,360.4,40952
    2021-01-21 14:04:19.468651,6306422,57369,476,2000,863942,65.0,16.3,5.7,360.4,40952
    2021-01-21 14:04:38.283728,6306422,57370,475,2000,863949,65.0,16.3,5.7,360.4,40952
    2021-01-21 14:04:56.739582,6306906,57370,475,2000,863956,65.0,16.3,5.7,360.4,40953
    2021-01-21 14:05:16.036892,6306906,57370,475,2000,863963,65.0,16.3,5.7,360.4,40953
    2021-01-21 14:05:35.687761,6306906,57370,475,2000,863966,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:05:54.406494,6306906,57370,475,2000,863971,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:06:13.296476,6307414,57371,475,2000,863975,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:06:33.131581,6307414,57371,488,2000,863982,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:06:51.710275,6307414,57372,488,2000,863988,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:07:10.583283,6307414,57372,488,2000,863999,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:07:29.379079,6307891,57373,494,2000,864004,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:07:47.752621,6307891,57373,494,2000,864010,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:08:06.913929,6307891,57374,494,2000,864014,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:08:25.639145,6307891,57374,495,2000,864021,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:08:44.461188,6308353,57374,495,2000,864028,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:09:03.145605,6308353,57374,495,2000,864032,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:09:21.595928,6308353,57374,499,2000,864041,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:09:40.106003,6308353,57374,499,2000,864048,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:09:59.791865,6308859,57376,499,2000,864051,65.0,16.3,5.7,360.4,40955
    2021-01-21 14:10:18.258786,6308859,57376,505,2000,864055,65.0,16.3,5.7,360.4,40957
    2021-01-21 14:10:36.975717,6308859,57376,505,2000,864059,65.0,16.3,5.7,360.4,40958
    2021-01-21 14:10:56.927703,6308859,57376,495,2000,864059,65.0,16.3,5.7,360.4,40959
    2021-01-21 14:11:16.165835,6309385,57378,495,2000,864074,65.0,16.3,5.7,360.5,40960
    2021-01-21 14:11:36.812213,6309385,57378,496,2000,864076,65.0,16.3,5.7,360.5,40961
    2021-01-21 14:11:55.603830,6309385,57379,496,2000,864083,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:12:14.468092,6309385,57379,496,2000,864085,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:12:33.030648,6309884,57379,494,2000,864090,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:12:55.174626,6309884,57380,494,2000,864093,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:13:16.721359,6309884,57380,494,2000,864103,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:13:36.534583,6310387,57381,496,2000,864107,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:13:56.038964,6310387,57381,496,2000,864111,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:14:14.656757,6310387,57381,496,2000,864120,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:14:33.778207,6310387,57381,483,2000,864127,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:14:53.479672,6310856,57381,483,2000,864130,65.0,16.3,5.7,360.5,40962
    2021-01-21 14:15:12.550394,6310856,57381,483,2000,864134,65.0,16.3,5.7,360.5,40963
    2021-01-21 14:15:31.736303,6310856,57381,484,2000,864144,65.0,16.3,5.7,360.5,40963
    2021-01-21 14:15:50.080530,6310856,57381,484,2000,864153,65.0,16.3,5.7,360.5,40963
    2021-01-21 14:16:08.541521,6311383,57382,484,2000,864158,65.0,16.3,5.7,360.5,40963
    2021-01-21 14:16:27.733229,6311383,57382,467,2000,864163,65.0,16.3,5.7,360.5,40963
    2021-01-21 14:16:46.215431,6311383,57382,467,2000,864168,65.0,16.3,5.7,360.5,40963
    
    
    展开全文
  • 动态曲线图.zip

    2019-08-01 14:06:04
    Android动态曲线图,实时变化,和符合初学者学习,可以下载下来研究研究
  • Android使用Echart绘制曲线,首先是对动态数据的访问以及解析,然后使用Echart将数据以曲线的形式可视化,在这一过程中,我主要是用到了两个谷歌的解析包,分别为ksoap2和gson。ksoap2用于访问发布的WebServer服务,...

    1、实现原理

    Android使用Echart绘制曲线,首先是对动态数据的访问以及解析,然后使用Echart将数据以曲线的形式可视化,在这一过程中,我主要是用到了两个谷歌的解析包,分别为ksoap2和gson。ksoap2用于访问发布的WebServer服务,gson用于对返回的数据进行解析。

    2、ksoap2访问WebServer

    不太了解ksoap2的,可以去看看ksoap2的中文开发文档,很容易了解。需要的朋友可以去这里下载解析包。下面直接看访问服务的代码。两个解析包地址:https://download.csdn.net/download/sinat_39271486/12034301

            String TJH=tjh;
            System.out.println(TJH);
    
            String k=shijian;
            System.out.println(k);
    
            String sensorID=CGQquzhi;
            String AK=sensorID.substring(0,2);
    
            sharedPreferences=getSharedPreferences("config", Context.MODE_PRIVATE);
            yonghuming=sharedPreferences.getString("user","");
            mima=sharedPreferences.getString("password","");
            if (AK.equals("02")&& getleixing.equals("油烟")) {
                SoapObject request = new SoapObject(NAMESPACE, METHON_NAME);
                request.addProperty("loginusername", yonghuming);
                request.addProperty("loginpassword", mima);
                request.addProperty("contractid", "180001");
                request.addProperty("sensorid", sensorID);
                request.addProperty("daycount", TJH);
                request.addProperty("startdate", k);
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.dotNet = true;
                envelope.bodyOut = request;
                envelope.setOutputSoapObject(request);
                HttpTransportSE httpTransportSE = new HttpTransportSE(URL);
                httpTransportSE.debug = true;
                try {
                    httpTransportSE.call(SOAP_ACTION, envelope);
    
                } catch (Exception e) {
                    e.printStackTrace();
                }
                SoapObject object = (SoapObject) envelope.bodyIn;
                System.out.println("服务返回数据---->" + object);
                String r = object.getProperty(0).toString();
                System.out.println("图表服务返回数据---->" + r);
    

    3、gson解析服务返回的json数据

    1、构造解析数据的函数

    了解返回的数据的字段,解析所需的部分,代码如下:

    
    public class User {
        private String PROJECTNAME;
        private  String CHANGEVALUE;
        private String xAxis;
        private  String yAxis;
        private  String yellowMax;
        private String redMax;
        public String getPROJECTNAME(){
            return PROJECTNAME;
        }
        public void setPROJECTNAME(String PROJECTNAME){
            this.PROJECTNAME=PROJECTNAME;
        }
        public String getCHANGEVALUE(){
            return CHANGEVALUE;
        }
        public void setCHANGEVALUE(String CHANGEVALUE){
            this.CHANGEVALUE=CHANGEVALUE;
        }
    
        public String getxAxis() {
            return xAxis;
        }
    
        public void setxAxis(String xAxis) {
            this.xAxis = xAxis;
        }
    
        public String getyAxis() {
            return yAxis;
        }
    
        public void setyAxis(String yAxis) {
            this.yAxis = yAxis;
        }
        public String getyellowMax(){
            return yellowMax;
        }
        public void setyellowMax(String yellowMax){
            this.yellowMax=yellowMax;
        }
    
        public String getredMax(){
            return  redMax;
        }
        public void setredMax(String redMax){
            this.redMax=redMax;
        }
    }
    

    2、使用Gson解析数据

     Type listType = new TypeToken<LinkedList<User>>() {
                }.getType();
     Gson gson = new Gson();
                LinkedList<User> users = gson.fromJson(r, listType);
                for (Iterator iterator = users.iterator(); iterator.hasNext(); ) {
                    User user = (User) iterator.next();
    
                    System.out.println("Y坐标值----》》" + user.getyAxis());
                    System.out.println("X坐标值----》》" + user.getxAxis());
                    System.out.println("坐标值----》》" + user.getyAxis());
                    // List<String> b = Arrays.asList(user.getyAxis());
                    //final char[] a = user.getyAxis().toCharArray();
                    // final String c= user.getyAxis();
                    final String c = user.getyAxis().substring(1, user.getyAxis().length() - 1).replace("\\", "");
                    final String A = user.getxAxis().substring(1, user.getxAxis().length() - 1).replace("\\", "");
                    final String yellow=user.getyellowMax().substring(1,user.getyellowMax().length()-1).replace("\\","");
                    final String red=user.getredMax().substring(1,user.getredMax().length()-1).replace("\\","");
                    final List<String> b = Arrays.asList(c);
                    final List<String> e = Arrays.asList(A);
                    final List<String>Yellow=Arrays.asList(yellow);
                    final List<String>Red=Arrays.asList(red);
    

    4、将解析的数据传入Echart中绘制曲线

    1、配置Echart所需的文件

    需要的朋友可以去官网看教程,主要引入echarts.min.js文件,需要的朋友可以去下载
    地址:https://download.csdn.net/download/sinat_39271486/12034395
    echart.min.js文件

    2、编写JS代码,将获取的数据传入Echart.js文件中,代码如下:

    <html>
    <head>
        <meta charset="utf-8">
        <title>ECharts</title>
        <!-- 引入 echarts.js -->
        <script src="echarts.min.js"></script>
    </head>
    <body onload="javascript:contact.showcontacts()" >
    <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
    <div id="main" style="width:400px;height:400px;"></div>
    <script  type="text/javascript">
    
           function show(params,params1,params3,params4)
            {
            var name1=params;
            var name2=params1;
            var name4=params3;
            var name5=params4;
    
    
    
           // 基于准备好的dom,初始化echarts实例
           var myChart = echarts.init(document.getElementById('main'));
    
            // 指定图表的配置项和数据
        option = {
        title:{
    
        },
        legend:{data:['油烟变化折线','预警线','报警线']},
        xAxis: {
    
            type: 'category',
    
            data: name2
        },
        yAxis: {
    
            type: 'value'
        },
        series: [{
    
            name:'油烟变化折线',
            data: name1,
            type: 'line',
            label:{
            normal:{
            show:true
            }
            },
            itemStyle:{
               normal:{
               color:'#00FF00',
               lineStyle:{
               color:'#00FF00'
               }
            }
            }
    
        },
        {
        name:'预警线',
        data: name4,
            type: 'line',
            label:{
            normal:{
            show:true
            }
            },
            itemStyle:{
               normal:{
               color:'#FFFF00  ',
               lineStyle:{
               color:'#FFFF00 '
               }
            }
            }
        },
        {
         name:'报警线',
        data: name5,
            type: 'line',
            label:{
            normal:{
            show:true
            }
            },
             itemStyle:{
               normal:{
               color:'#FF0000 ',
               lineStyle:{
               color:'#FF0000'
               }
            }
            }
        }
       ]
    };
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
           }
    
        </script>
    </body>
    </html>
    

    3、调用Echart绘制的样式

    将之前编写的Echart.js文件传入程序中。代码如下:

     final String c = user.getyAxis().substring(1, user.getyAxis().length() - 1).replace("\\", "");
                    final String A = user.getxAxis().substring(1, user.getxAxis().length() - 1).replace("\\", "");
                    final String yellow=user.getyellowMax().substring(1,user.getyellowMax().length()-1).replace("\\","");
                    final String red=user.getredMax().substring(1,user.getredMax().length()-1).replace("\\","");
                    final List<String> b = Arrays.asList(c);
                    final List<String> e = Arrays.asList(A);
                    final List<String>Yellow=Arrays.asList(yellow);
                    final List<String>Red=Arrays.asList(red);
                    chartshow_web.loadUrl("file:///android_asset/echart.html");
                    chartshow_web.setWebChromeClient(new WebChromeClient() {
                        public void onProgressChanged(WebView view, int progress) {
                            if (progress == 100) {
                                view.loadUrl("javascript:show(" + b + "," + e + ","+Yellow+","+Red+")");
    

    5、展示绘制的结果

    1、查询一天内各个时段的变化值
    一天数据展示
    2、绘制一个月内的变化曲线
    一个月数据展示

    展开全文
  • 上次我们基于小熊派光强传感器项目实现了光强读取并在LCD上显示,文章链接如下:基于小熊派光强传感器BH1750状态机驱动项目升级(带LCD屏显示)这一节,我们再次对这个项目升级下,配个带可缩放曲线的上位机读取光强...

    上次我们基于小熊派光强传感器项目实现了光强读取并在LCD上显示,文章链接如下:

    基于小熊派光强传感器BH1750状态机驱动项目升级(带LCD屏显示)

    这一节,我们再次对这个项目升级下,配个带可缩放曲线的上位机读取光强进行显示吧!

    本节,你将了解工作中上位机和MCU的是如何来配合使用的。

    在工作中,我们常常需要对一些传感器的某些数值进行长时间的测试和观察,以了解传感器的性能,在电子工程里,我们经常听到的测试曲线莫过于电池充放电曲线了,通过电池充放电曲线,我们很容易可以知道电池在实际使用过程中满电和馈电的状态以及电池的使用周期等等,今晚,我们就让光强通过曲线显示出来,用QT+QCustomPlot来实现,最终效果如下视频操作所示:

    0390064b2b30f9dba2e8d03f308382bf.png

    一、QCustomPlot简介

    以下是QCustomPlot的官网:

    https://www.qcustomplot.com/

    e090a46bb940cc1fb3ca556c8250bc31.png

    4f6783452732e4c610710598a6df19fe.png

    QCustomPlot是一个小型的Qt画图标类,支持绘制静态曲线、动态曲线、多重坐标曲线,柱状图,蜡烛图等。只需要在项目中加入头文件qcustomplot.h和qcustomplot.cpp文件,然后使一个widget提升为QCustomPlot类,即可使用。

    二、更改上节的MCU端程序

    这次,我们选用串口和上位机进行通信,所以我们需要设计一个传感器和上位机通信的协议,协议如下:

    序号 光强值 \r\n

    当序号大于等于65535时,自动清0。

    修改上节的main函数为如下:

    /**
    * @brief The application entry point.
    * @retval int
    */
    int main(void)
    {
    /* USER CODE BEGIN 1 */
    /*流水号*/
    int serial_number = 0;
    char display_buf[20] = {0};
    char procol_buf[20] = {0};
    /* USER CODE END 1 */

    /* MCU Configuration--------------------------------------------------------*/

    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();

    /* USER CODE BEGIN Init */

    /* USER CODE END Init */

    /* Configure the system clock */
    SystemClock_Config();

    /* USER CODE BEGIN SysInit */

    /* USER CODE END SysInit */

    /* Initialize all configured peripherals */
    MX_GPIO_Init();
    MX_I2C1_Init();
    MX_USART1_UART_Init();
    MX_SPI2_Init();
    /* USER CODE BEGIN 2 */
    /*串口初始化后加这个延时,防止后面的printf打印乱码*/
    HAL_Delay(200);
    LCD_Init();
    LCD_Clear(BLACK);//清屏为黑色
    LCD_ShowString(5, 10, 240, 32, 32, "BearPi LuxTest");//显示字符串,字体大小32*32
    Init_BH750();
    timer_init(&lsensor.timer1, lsensor.timeout_cb, 1, 1);
    timer_start(&lsensor.timer1);
    /* USER CODE END 2 */

    /* Infinite loop */
    /* USER CODE BEGIN WHILE */
    while (1)
    {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
    ReadBH1750(LUX_1_MODE);

    if(1 == lsensor.Conver_completed)
    {
    ++serial_number ;

    if(65535 == serial_number)
    serial_number = 0 ;

    sprintf(display_buf, "%d%d%d%dLux", lsensor.Lux / 1000 % 100, lsensor.Lux / 100 % 10, lsensor.Lux / 10 % 10, lsensor.Lux % 10);
    LCD_ShowString(80, 50 + 24 + 32, 240, 32, 32, display_buf); //显示字符串,字体大小32*32

    if(lsensor.Lux > LIGHT_SENSOR_THREHOLD)
    {
    HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
    }
    else
    {
    HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET);
    }

    sprintf(procol_buf, "%d%d%d%d%d %d%d%d%d%d",
    serial_number / 10000,
    serial_number / 1000 % 100 % 10,
    serial_number / 100 % 10,
    serial_number / 10 % 10,
    serial_number % 10,
    lsensor.Lux / 10000,
    lsensor.Lux / 1000 % 100 % 10,
    lsensor.Lux / 100 % 10,
    lsensor.Lux / 10 % 10,
    lsensor.Lux % 10
    );
    printf("%s \r\n", procol_buf);
    }

    timer_loop();

    }

    /* USER CODE END 3 */
    }

    下载后,打开串口调试助手可以看到:

    ba03f4e86faee431e84363f5cccbd3ba.png

    三、光强曲线显示上位机应用开发

    下面我先用QT画出一个简单的界面(已经将QCustomPlot用上了),如下:

    1cb5e81507f0bc7cdd8951cd41f39c33.png

    这里我们需要使用QT5的串口库,还有QCustomPlot库,所以在.pro中需要添加对应的库:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2020-04-13T20:46:41
    #
    #-------------------------------------------------

    QT += core gui serialport

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport

    TARGET = BearPi_QT
    TEMPLATE = app
    RC_FILE += app.rc

    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which as been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS

    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0


    SOURCES += \
    main.cpp \
    mainwindow.cpp \
    qcustomplot.cpp

    HEADERS += \
    mainwindow.h \
    qcustomplot.h

    FORMS += \
    mainwindow.ui

    在mainwindow.h中,需要添加头文件及变量还有相关的普通函数和槽函数的定义:

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include
    #include
    #include //提供访问串口的功能
    #include //提供系统中存在的串口的信息
    #include "qcustomplot.h" //包含Qcustomplot库
    namespace Ui {
    class MainWindow;
    }
    class MainWindow : public QMainWindow
    {
    Q_OBJECT
    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    /*初始化串口参数*/
    void Init_Serial_Para();
    /*传感器数据画图前的处理*/
    void sensor_data_preprocess(int x, int y) ;
    /*画曲线函数*/
    void Sensor_Draw_Plot(QCustomPlot *customPlot, QVector x, QVector y);
    private:
    Ui::MainWindow *ui;
    QSerialPort *Serial ;
    long last_index ;
    QVector display_x;
    QVector display_y;
    QString Serial_Port , Serial_Bauardate,Serial_PariteyBit,Serial_DataBit,Serial_StopBit ;
    private slots:
    void Update_Serial_Port(QString Currnet_Select);
    void Update_Serial_Baurdrate(QString Currnet_Select);
    void Update_Serial_ParityBit(QString Currnet_Select);
    void Update_Serial_DataBit(QString Currnet_Select);
    void Update_Serial_StopBit(QString Currnet_Select);
    void on_Connect_Device_clicked();
    void on_Disconnect_Device_clicked();
    void cmd_recv_process();
    };
    #endif // MAINWINDOW_H

    在mainwindow.cpp太长我就不全贴出来了,解读一下核心的实现思路:

    1、用户配置完串口参数,然后     连接信号与槽:

    connect(this->Serial,SIGNAL(readyRead()),this,SLOT(cmd_recv_process()));

    2、当上位机接受到MCU端发来的数据时,会触发readyRead()信号,进而调用cmd_recv_process()槽函数,实现如下:

    /*数据接收*/
    void MainWindow::cmd_recv_process()
    {
    QString data ;
    QStringList list ;
    /*光强传感器序号*/
    QString Sensor_Serial_Number ;
    /*光强传感器光强值*/
    QString Sensor_light_Value ;
    long int s1 = 0, v1 = 0;
    last_index =0;
    if(Serial->canReadLine())
    {
    QByteArray temp = Serial->readAll();

    if(!temp.isEmpty())
    {
    data = temp ;
    list = data.split(" ");
    if(3 == list.length())
    {
    Sensor_Serial_Number = list[0];
    Sensor_light_Value = list[1];
    /*取到对应参数后立刻开始画图*/
    s1 = Sensor_Serial_Number.toInt();
    v1 = Sensor_light_Value.toInt();
    ui->light_sensor_value->setText(QString::number(v1));
    if (last_index == 0 || (last_index < s1 && s1 - last_index >=1 && s1 - last_index <= 10 ))
    {
    last_index = s1;
    sensor_data_preprocess(s1,v1);
    }
    }
    }
    }
    }

    这里会判断是否满足读取一行数据的条件,如果满足则会读取一行数据,接下来对数据进行分割,取出传感器上报的序号、光强两个字段,序号作为曲线图的横坐标,光强作为曲线图的纵坐标进行显示。

    例程下载

    链接:https://pan.baidu.com/s/1ujo0TE3pS-1RFVvylnCyKQ
    提取码:48jp
    复制这段内容后打开百度网盘手机App,操作更方便哦
    ‧  END  f7f0c7734d36632861b37dee9c983f85.png

    往期回顾

    • 今天,小熊派一周年了!

    • linkboy+小熊派物联网开发实战

    • 基于LiteOS的智慧农业案例实验分享

    • 国内NB-IoT连接数量突破1亿,是慢还是快?

    • 你有没有想过,C语言 main 函数到底为啥这么写?

    • 哪些5G芯片和5G模组已经问世?| 截至2020年Q1

    • NB-IoT要不要走运营商平台?

    展开全文
  • 在VC下开发的一个动态图表工具,图中的曲线可以实时的变化,在做一些动态图标的时候能用得上。程序编译通过且能够运行
  • 动态曲线图表(Chart)效果,该项目实现了Android动态曲线图,程序是根据本地随机的数据变化来不断绘制更新出来的曲线图,,从而实现动态的效果。
  • 最近做的一个在线气象观测网站要实现一个需求:使用图表展示最近五天温湿度等气象要素的曲线变化图示如下(2016-5-25日的数据):下面就详述一下实现过程吧(注:相较于原网页我隐去了很多内容,本实现过程就只专注于...

    最近做的一个在线气象观测网站要实现一个需求:使用图表展示最近五天温湿度等气象要素的曲线变化

    图示如下(2016-5-25日的数据):

    88054616_1.png

    下面就详述一下实现过程吧(注:相较于原网页我隐去了很多内容,本实现过程就只专注于Echarts图表实现)

    一:

    HTML页面部分,代码如下:

    88054616_2.gif

    88054616_2.gif

    - 观测数据 -

    // 基于准备好的dom,初始化echarts实例

    var myChart = echarts.init(document.getElementById('main'));

    // 指定图表的配置项和数据

    var option = {

    title: { //图表标题

    text: '过去五天数据图表'

    },

    tooltip: {

    trigger: 'axis', //坐标轴触发提示框,多用于柱状、折线图中

    /*

    控制提示框内容输出格式

    formatter: '{b0} ● {a0} : {c0} ℃ ' +

    '● {a1} : {c1} % ' +

    ' ● {a3} : {c3} mm ' +

    ' ● {a4} : {c4} m/s ' +

    '    ● {a2} : {c2} hPa '

    */

    },

    dataZoom: [

    {

    type: 'slider', //支持鼠标滚轮缩放

    start: 0, //默认数据初始缩放范围为10%到90%

    end: 100

    },

    {

    type: 'inside', //支持单独的滑动条缩放

    start: 0, //默认数据初始缩放范围为10%到90%

    end: 100

    }

    ],

    legend: { //图表上方的类别显示

    show:true,

    data:['温度(℃)','湿度(%)','雨量(mm)','风速(m/s)','压强(hPa)']

    },

    color:[

    '#FF3333', //温度曲线颜色

    '#53FF53', //湿度曲线颜色

    '#B15BFF', //压强图颜色

    '#68CFE8', //雨量图颜色

    '#FFDC35' //风速曲线颜色

    ],

    toolbox: { //工具栏显示

    show: true,

    feature: {

    saveAsImage: {} //显示“另存为图片”工具

    }

    },

    xAxis: { //X轴

    type : 'category',

    data : [] //先设置数据值为空,后面用Ajax获取动态数据填入

    },

    yAxis : [ //Y轴(这里我设置了两个Y轴,左右各一个)

    {

    //第一个(左边)Y轴,yAxisIndex为0

    type : 'value',

    name : '温度',

    /* max: 120,

    min: -40, */

    axisLabel : {

    formatter: '{value} ℃' //控制输出格式

    }

    },

    {

    //第二个(右边)Y轴,yAxisIndex为1

    type : 'value',

    name : '压强',

    scale: true,

    axisLabel : {

    formatter: '{value} hPa'

    }

    }

    ],

    series : [ //系列(内容)列表

    {

    name:'温度(℃)',

    type:'line', //折线图表示(生成温度曲线)

    symbol:'emptycircle', //设置折线图中表示每个坐标点的符号;emptycircle:空心圆;emptyrect:空心矩形;circle:实心圆;emptydiamond:菱形

    data:[] //数据值通过Ajax动态获取

    },

    {

    name:'湿度(%)',

    type:'line',

    symbol:'emptyrect',

    data:[]

    },

    {

    name:'压强(hPa)',

    type:'line',

    symbol:'circle', //标识符号为实心圆

    yAxisIndex: 1, //与第二y轴有关

    data:[]

    },

    {

    name:'雨量(mm)',

    type:'bar', //柱状图表示

    //barMinHeight: 10, //柱条最小高度,可用于防止某数据项的值过小而影响交互

    /* label: { //显示值

    normal: {

    show: true,

    position: 'top'

    }

    }, */

    data:[]

    },

    {

    name:'风速(m/s)',

    type:'line',

    symbol:'emptydiamond',

    data:[]

    }

    ]

    };

    myChart.showLoading(); //数据加载完之前先显示一段简单的loading动画

    var tems=[]; //温度数组(存放服务器返回的所有温度值)

    var hums=[]; //湿度数组

    var pas=[]; //压强数组

    var rains=[]; //雨量数组

    var win_sps=[]; //风速数组

    var dates=[]; //时间数组

    $.ajax({ //使用JQuery内置的Ajax方法

    type : "post", //post请求方式

    async : true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)

    url : "ShowInfoIndexServlet", //请求发送到ShowInfoIndexServlet处

    data : {name:"A0001"}, //请求内包含一个key为name,value为A0001的参数;服务器接收到客户端请求时通过request.getParameter方法获取该参数值

    dataType : "json", //返回数据形式为json

    success : function(result) {

    //请求成功时执行该函数内容,result即为服务器返回的json对象

    if (result != null && result.length > 0) {

    for(var i=0;i

    tems.push(result[i].tem); //挨个取出温度、湿度、压强等值并填入前面声明的温度、湿度、压强等数组

    hums.push(result[i].hum);

    pas.push(result[i].pa);

    rains.push(result[i].rain);

    win_sps.push(result[i].win_sp);

    dates.push(result[i].dateStr);

    }

    myChart.hideLoading(); //隐藏加载动画

    myChart.setOption({ //载入数据

    xAxis: {

    data: dates //填入X轴数据

    },

    series: [ //填入系列(内容)数据

    {

    // 根据名字对应到相应的系列

    name: '温度',

    data: tems

    },

    {

    name: '湿度',

    data: hums

    },

    {

    name: '压强',

    data: pas

    },

    {

    name: '雨量',

    data: rains

    },

    {

    name: '风速',

    data: win_sps

    }

    ]

    });

    }

    else {

    //返回的数据为空时显示提示信息

    alert("图表请求数据为空,可能服务器暂未录入近五天的观测数据,您可以稍后再试!");

    myChart.hideLoading();

    }

    },

    error : function(errorMsg) {

    //请求失败时执行该函数

    alert("图表请求数据失败,可能是服务器开小差了");

    myChart.hideLoading();

    }

    })

    myChart.setOption(option); //载入图表

    88054616_2.gif

    88054616_2.gif

    二:

    Servlet部分,客户端请求提交到 ShowInfoIndex 处,先在 web.xml 里配置一下Servlet映射:

    88054616_2.gif

    88054616_2.gif

    BlogExample

    ShowInfoIndexServlet

    EchartsExample.ShowInfoIndexServlet

    ShowInfoIndexServlet

    /ShowInfoIndexServlet

    88054616_2.gif

    88054616_2.gif

    关于ShowInfoIndexServlet,简单说一下请求-响应中间的过程:

    客户端发送图表请求给Servlet,Servlet接收到请求后先获取客户端请求查看的气象站名称,然后从数据库(SqlServer2005 Express版)中获取最近五天内该气象站所有的采集数据(装在List中),再用Gson工具将该List转换成Json对象返回给客户端,客户端接收到返回的Json对象后对其进行解析并将相应数据填入Echarts中,然后作显示;

    其中Record.java是只对外提供get/set方法的用于封装数据的普通实体类,DBUtil.java是JDBC方式下专门提供Connection、Statement、ResultSet等的数据库工具类。

    (原本的连接数据库并获取数据过程需经过业务逻辑层与数据访问层,较为复杂,这里隐去这两层,直接在Servlet内连接数据库并拿取数据)

    Ps:墙裂建议使用PreparedStatement进行参数化查询,这样可以有效避免SQL注入!

    ShowInfoIndexServlet代码如下:

    88054616_2.gif

    88054616_2.gif

    package EchartsExample;

    import java.io.IOException;

    import java.sql.Connection;

    import java.sql.PreparedStatement;

    import java.sql.ResultSet;

    import java.sql.SQLException;

    import java.text.SimpleDateFormat;

    import java.util.*;

    import javax.servlet.ServletException;

    import javax.servlet.http.HttpServlet;

    import javax.servlet.http.HttpServletRequest;

    import javax.servlet.http.HttpServletResponse;

    import com.google.gson.Gson;

    /**

    * 响应观测记录展示页的Echarts图表数据请求(使用json格式返回客户端需要的数据)

    * @author zhong

    *

    */

    public class ShowInfoIndexServlet extends HttpServlet {

    /**

    *

    */

    private static final long serialVersionUID = 1L;

    @Override

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    doPost(req,resp);

    }

    @Override

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    request.setCharacterEncoding("UTF-8"); //设定客户端提交给servlet的内容按UTF-8编码

    response.setCharacterEncoding("UTF-8"); //设定servlet传回给客户端的内容按UTF-8编码

    response.setContentType("text/html;charset=UTF-8"); //告知浏览器用UTF-8格式解析内容

    String name = request.getParameter("name"); //获取台站名参数

    //获取当天在内的五天以前的0点格式字符串(用于数据库查询)

    Calendar cal = Calendar.getInstance();

    cal.add(Calendar.DATE, -4); //获取当天在内的五天以前的日期时间

    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); //设定日期格式

    String fiveDaysAgoStr = sdf1.format(cal.getTime()); //将五天前的日期时间按指定格式转换成字符串

    //获取当前时间并将其转换成指定格式的字符串(用于数据库查询)

    Date now = new Date();

    SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    String nowStr = sdf2.format(now);

    //System.out.println(nowStr);

    //======================================连接数据库操作============================================================================================

    /*

    * 连接数据库并获取五天内该名称的气象站的所有采集数据

    */

    List records = new ArrayList(); //用一个ArrayList来盛装封装了各气象数据的对象

    Connection conn = null;

    PreparedStatement pstmt = null;

    ResultSet rs = null;

    try {

    conn = DBUtil.getConnection(); //获取与数据库的连接

    String sql = "select * from alldata where data_taizhan_num = ? and data_date >= ? and data_date <= ? order by data_date asc"; //初始化SQL查询语句

    pstmt = conn.prepareStatement(sql); //创建preparedStatement语句对象

    pstmt.setString(1, name); //设定查询参数

    pstmt.setString(2, fiveDaysAgoStr);

    pstmt.setString(3, nowStr);

    rs = pstmt.executeQuery(); //获取查询到的结果集

    while (rs.next()) {

    //封装Record对象

    Record r = new Record();

    r.setTaizhan_num(rs.getString(1));

    r.setDate(rs.getTimestamp(2));

    r.setTem(rs.getString(3));

    r.setHum(rs.getString(4));

    r.setPa(rs.getString(5));

    r.setRain(rs.getString(6));

    r.setWin_dir(rs.getString(7));

    r.setWin_sp(rs.getString(8));

    //将时间转换成给定格式便于echarts的X轴日期坐标显示

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    String str = sdf.format(rs.getTimestamp(2));

    r.setDateStr(str);

    //System.out.println(r.getTem()+" | "+r.getHum()+" | "+r.getPa()+" | "+r.getRain()+" | "+r.getWin_dir()+" | "+r.getWin_sp());

    records.add(r); //将封装好的Record对象放入列表容器中

    }

    } catch (SQLException e) {

    System.out.println("查询出错,操作未完成!");

    e.printStackTrace();

    } finally {

    //查询结束后释放资源

    DBUtil.close(rs);

    DBUtil.close(pstmt);

    DBUtil.close(conn);

    }

    //======================================连接数据库操作(完)============================================================================================

    //将list中的对象转换为Json格式的数组

    Gson gson = new Gson();

    String json = gson.toJson(records);

    //System.out.println(json);

    //将json数据返回给客户端

    response.setContentType("text/html; charset=utf-8");

    response.getWriter().write(json);

    }

    }

    88054616_2.gif

    88054616_2.gif

    alldata表部分数据截图:

    88054616_3.png

    Record类代码如下:

    88054616_2.gif

    88054616_2.gif

    package EchartsExample;

    import java.sql.*;

    /**

    * 封装气象数据信息

    * @author zhong

    *

    */

    public class Record {

    private String taizhan_num; //台站名

    private String tem; //温度

    private String hum; //湿度

    private String pa; //压强

    private String rain; //雨量

    private String win_dir; //风向

    private String win_sp; //风速

    private String dateStr; //观测日期(用于Echarts显示格式)

    private Timestamp date; //观测日期(原始格式)

    /**

    * 获取观测日期(用于echarts图表展示);

    * @return 观测日期值

    */

    public String getDateStr() {

    return dateStr;

    }

    /**

    * 设置观测日期(用于echarts图表展示);

    * @param dateStr 待设置观测日期值

    */

    public void setDateStr(String dateStr) {

    this.dateStr = dateStr;

    }

    /**

    * 获取产生该观测记录的台站名称;

    * @return 台站名称

    */

    public String getTaizhan_num() {

    return taizhan_num;

    }

    /**

    * 设置产生该观测记录的台站名称;

    * @param taizhan_num 待设置台站名称

    */

    public void setTaizhan_num(String taizhan_num) {

    this.taizhan_num = taizhan_num;

    }

    /**

    * 获取温度;

    * @return 温度值

    */

    public String getTem() {

    return tem;

    }

    /**

    * 设置温度;

    * @param tem 待设置温度值

    */

    public void setTem(String tem) {

    this.tem = tem;

    }

    /**

    * 获取湿度;

    * @return 湿度值

    */

    public String getHum() {

    return hum;

    }

    /**

    * 设置湿度;

    * @param hum 待设置湿度值

    */

    public void setHum(String hum) {

    this.hum = hum;

    }

    /**

    * 获取压强;

    * @return 压强值

    */

    public String getPa() {

    return pa;

    }

    /**

    * 设置压强;

    * @param pa 待设置压强值

    */

    public void setPa(String pa) {

    this.pa = pa;

    }

    /**

    * 获取雨量;

    * @return 雨量值

    */

    public String getRain() {

    return rain;

    }

    /**

    * 设置雨量;

    * @param rain 待设置雨量值

    */

    public void setRain(String rain) {

    this.rain = rain;

    }

    /**

    * 获取风向;

    * @return 风向值

    */

    public String getWin_dir() {

    return win_dir;

    }

    /**

    * 设置风向;

    * @param win_dir 待设置风向值

    */

    public void setWin_dir(String win_dir) {

    this.win_dir = win_dir;

    }

    /**

    * 获取风速;

    * @return 风速值

    */

    public String getWin_sp() {

    return win_sp;

    }

    /**

    * 设置风向;

    * @param win_sp 待设置风向值

    */

    public void setWin_sp(String win_sp) {

    this.win_sp = win_sp;

    }

    /**

    * 获取观测日期;

    * @return 观测日期

    */

    public Timestamp getDate() {

    return date;

    }

    /**

    * 设置观测日期;

    * @param date 观测日期值

    */

    public void setDate(Timestamp date) {

    this.date = date;

    }

    }

    88054616_2.gif

    88054616_2.gif

    DBUitl类(数据库工具类)代码如下:

    88054616_2.gif

    88054616_2.gif

    package EchartsExample;

    import java.sql.*;

    import org.apache.tomcat.jdbc.pool.DataSource;

    import org.apache.tomcat.jdbc.pool.PoolProperties;

    /**

    * 数据库工具类(采用了tomcat jdbc pool)

    * @author zhong

    *

    */

    public class DBUtil {

    private static DataSource ds;

    static {

    //配置tomcat jdbc pool (连接池)

    PoolProperties p = new PoolProperties();

    p.setUrl("jdbc:sqlserver://localhost:1433; DatabaseName=weather"); //设置连接的url

    p.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //载入数据库驱动

    p.setUsername("sa"); //用于远程连接的用户名

    p.setPassword("2003NianDeDiYiChangXue"); //密码

    p.setJmxEnabled(true);

    p.setTestWhileIdle(false);

    p.setTestOnBorrow(true);

    p.setValidationQuery("SELECT 1");

    p.setTestOnReturn(false);

    p.setValidationInterval(30000);

    p.setTimeBetweenEvictionRunsMillis(30000);

    p.setMaxActive(100);

    p.setInitialSize(10);

    p.setMaxWait(10000);

    p.setRemoveAbandonedTimeout(60);

    p.setMinEvictableIdleTimeMillis(30000);

    p.setMinIdle(10);

    p.setLogAbandoned(true);

    p.setRemoveAbandoned(true);

    p.setJdbcInterceptors(

    "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"+

    "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");

    ds = new DataSource();

    ds.setPoolProperties(p);

    }

    private DBUtil() {}

    /**

    * 获取一个数据库连接(Connection);

    * @return Database Connection

    */

    public static Connection getConnection() {

    Connection conn = null;

    try {

    conn = ds.getConnection();

    } catch (SQLException e) {

    e.printStackTrace();

    }

    return conn;

    }

    /**

    * 关闭传入的Connection;

    * @param conn 待关闭的Connection

    */

    public static void close(Connection conn) {

    try {

    if (conn != null) {

    conn.close();

    conn = null;

    }

    } catch (SQLException e) {

    e.printStackTrace();

    }

    }

    /**

    * 关闭传入的Statement;

    * @param stmt 待关闭的Statement

    */

    public static void close(Statement stmt) {

    try {

    if (stmt != null) {

    stmt.close();

    stmt = null;

    }

    } catch (SQLException e) {

    e.printStackTrace();

    }

    }

    /**

    * 关闭传入的ResultSet;

    * @param rs 待关闭的ResultSet

    */

    public static void close(ResultSet rs) {

    try {

    if (rs != null) {

    rs.close();

    rs = null;

    }

    } catch (SQLException e) {

    e.printStackTrace();

    }

    }

    }

    88054616_2.gif

    88054616_2.gif

    ——————————————————————————我是小小分割线————————————————————————————————————

    关于远程连接(包括使用Eclipse连接)SqlServer2005我再多嘴两句:

    当确认连接的URL,驱动加载,用户名,密码都配置正确时,仍然抛出 java.lang.NullPointerException 的话,请打开开始菜单Microsoft SQL Server 2005软件目录下的SQL Server配置管理器:

    ①:启用SQL Server 2005网络配置 下的 SQLEXPRESS协议 内的 TCP/IP 协议,并右键TCP/IP协议选择属性,确保IP地址一栏最末的TCP端口为1433,具体见下图

    88054616_4.png

    ②:启用 SQL Native Client配置 下的 客户端协议 内的 TCP/IP 协议,并右键查看TCP/IP 属性,确保端口为1433,具体见下图

    88054616_5.png

    ③:重新启动 SQL Server 2005服务 下的 SQL Server服务,详情见下图

    88054616_6.png

    至此,应该就解决了java.lang.NullPointerException这个错误了。

    ————————————————————————我是小小分割线————————————————————————————————————

    让我们再回到原来的Echarts图表显示过程上,你可以试着在后台打印看看转换出的Json字符串,关于Json的使用这里我不再多言解释,具体可参考简单易懂的官方教程:http://www.w3school.com.cn/json/

    最后再贴一下实现效果吧:

    88054616_7.png

    展开全文
  • Qt Qwt 绘制动态曲线

    2015-10-09 18:01:07
    Qt 利用QWt实现绘制动态曲线 横轴随时间移动向后移动 实时显示当前数据变化
  • 易语言动态曲线源码例程程序结合易语言模块GDIPlus类.ec,实现曲线动态变化。点评:本源码是易语言模块GDIPlus类.ec的应用例程。
  • 用Python来进行多条曲线动态演示全球疫情变化
  • 作者 |周萝卜来源 |萝卜大杂烩2019已经过去,回看编程语言20年真是风云变化!从 TIOBE 榜(热门榜)上来看,Java、C 和 Python 基本锁定了前三的位置,Java 江湖老大的地位,目前还是无人能撼动呢。下面先来一张 TIOBE...
  • 实时动态曲线额绘制

    2013-04-10 10:27:16
    利用mfc绘制一个实时曲线 能够动态变化 绘制曲线的数值由随机数产生 效果可见 可以在绘图函数中自己改变其背景颜色极其曲线颜色
  • Qt绘制动态曲线

    2014-12-06 17:37:56
    功能描述:用曲线来显示数据的变化情况。横坐标表示时间T,纵坐标Y。每隔一定时间取一个Y值确定纵坐标。能够世事变化坐标。
  • R绘制动态曲线

    千次阅读 2013-12-01 11:32:49
    以之前Chrome在收集页面资料时使用的指数平滑算法为例,绘制一个在不同系数且目标值不断变化(应用场景不是页面访问统计)的情况下的曲线逼近行为。 首先要确保在R中安装了animation包, 如果需要保存成GIF动画,还...
  • 在 实时动态曲线 一节介绍了使用算法实现实时动态曲线,Qt 提供了 charts 模块,使用 QSplineSeries 就能很轻松的实现平滑曲线了,而且效果很好,但是需要注意一点的是,免费版的 Qt 中 charts 模块是 GPL 协议...
  • MFC中绘制动态曲线

    2017-08-25 19:58:17
    在工控监测领域,经常需要动态绘制曲线,观察曲线变化趋势,绘制波形图,绘制频谱等。在前面4讲中介绍了MFC经常用的TeeChart控件和Hight-Speed Chart Ctrl,这两个都是MFC绘图控件的经典(另外,在Qt中还有...
  • 01. 引言动态曲线图不同于动态气泡图,它可以查看部分指标在一段时间内的变化趋势,本期推文将推出动态曲线图的 Matplotlib 绘制过程,核心过程为 折线图 和 散点图 的绘制,详细过程如下:02. 数据处理由于需要查...
  • 在我想扩展演示动画的情节,使目前的烛台将移动和更新,以回应其OHLC数据的变化。重要的一点是,只有组件(glyphs?)最后的蜡烛应该更新,而不是整个情节。在其目的是演示一种计算量很轻的方法,可以放大到一个更大的...
  • 使用VB6.0工具,PictureBox控件实现动态曲线的类模块,直接调用类模块,传递变化量的数值,自动完成曲线的动态连续生成。
  • 安卓动态曲线的绘制

    千次阅读 2015-11-20 17:58:24
    我们在安卓开发中,有时...但有时,我们需要动态绘制一些曲线图,就像我们打开电脑的任务管理器,里面有一个CPU使用记录的动态变化的带网格的曲线图,对于这一类的曲线绘制,安卓SDK自带的绘图模块貌似就不那么好用了。
  • 在web页上划出动态变化曲线

    千次阅读 2006-12-25 11:20:00
    需求:客户有关于某仪器的运行参数(来自数据库)... 首先,是如何才能显示这些动态变化的点的曲线。这里的思路比较简单:用div的高度来显示数值(嵌套一个小的div,有高度,居顶,加色显示,形成点),夹以repeater来

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 658
精华内容 263
关键字:

动态曲线变化