Highcharts 中文社区

查看: 10926|回复: 33

[Java 相关] 怎么将servlet中的json数据用highstock绘图呢

[复制链接]
  • TA的每日心情
    奋斗
    2016-12-23 15:22
  • 签到天数: 1 天

    [LV.1]初来乍到

    3

    主题

    22

    帖子

    75

    积分

    HC 新手

    Rank: 1

    积分
    75
    发表于 2016-12-23 15:24:52 | 显示全部楼层 |阅读模式
    在servelt已经得到数据库数据,并转换成了json格式,但是不知道highstock怎么获取这些数据。。 谁有实例参考下啊。。谢谢啊
  • TA的每日心情
    奋斗
    2016-12-23 15:22
  • 签到天数: 1 天

    [LV.1]初来乍到

    3

    主题

    22

    帖子

    75

    积分

    HC 新手

    Rank: 1

    积分
    75
     楼主| 发表于 2016-12-23 15:51:13 | 显示全部楼层

    怎么将servlet中的json数据用highstock绘图呢

    这是我从servlet中转化成的json格式数据,请问该怎么用highstock绘图啊? 请大神帮我解答下。。

    [{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:01.0","open_price":"1.04655"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:02.0","open_price":"1.04650"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:03.0","open_price":"1.04655"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:04.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:05.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:06.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:07.0","open_price":"1.04630"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:08.0","open_price":"1.04655"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:09.0","open_price":"1.04630"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:10.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:11.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:12.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:13.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:14.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:15.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:16.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:17.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:18.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:19.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:20.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:21.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:22.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:23.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:24.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:25.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:26.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:27.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:28.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:29.0","open_price":"1.04630"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:30.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:31.0","open_price":"1.04625"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:32.0","open_price":"1.04630"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:33.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:34.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:35.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:36.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:37.0","open_price":"1.04640"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:38.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:39.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:40.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:41.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:42.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:43.0","open_price":"1.04635"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:44.0","open_price":"1.04650"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:45.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:46.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:47.0","open_price":"1.04645"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:48.0","open_price":"1.04655"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:49.0","open_price":"1.04655"},{"item_code":"EUR=","data_source":"Reuters","time_start":"2016-12-19 15:30:50.0","open_price":"1.04665"}]

    请大神帮我解答下。。。
  • TA的每日心情
    擦汗
    2017-11-29 14:57
  • 签到天数: 747 天

    [LV.9]以坛为家II

    86

    主题

    1107

    帖子

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    22711

    最佳新人活跃会员热心会员突出贡献优秀版主荣誉管理论坛元老

    发表于 2016-12-23 16:45:02 | 显示全部楼层
    不是 Highstock 获取,而是用 Ajax 获取,去学习一下 Javascript,Ajax 相关内容吧。
    Highcharts 中文网论坛管理团队

    我们提供:商业授权技术支持图表定制VIP服务 等相关支持服务
    在线客服:2133220776(QQ,非技术,工作日 10:00 ~ 17:00)
    新浪微博:http://weibo.com/highcharts
  • TA的每日心情
    奋斗
    2016-12-23 15:22
  • 签到天数: 1 天

    [LV.1]初来乍到

    3

    主题

    22

    帖子

    75

    积分

    HC 新手

    Rank: 1

    积分
    75
     楼主| 发表于 2016-12-23 21:13:53 | 显示全部楼层
    群大大 发表于 2016-12-23 16:45
    不是 Highstock 获取,而是用 Ajax 获取,去学习一下 Javascript,Ajax 相关内容吧。 ...

    EUR= Reuters 2016-12-19 15:30:01.0 1.04655

    EUR= Reuters 2016-12-19 15:30:02.0 1.04650

    EUR= Reuters 2016-12-19 15:30:03.0 1.04655

    EUR= Reuters 2016-12-19 15:30:04.0 1.04640

    EUR= Reuters 2016-12-19 15:30:05.0 1.04635

    EUR= Reuters 2016-12-19 15:30:06.0 1.04640

    EUR= Reuters 2016-12-19 15:30:07.0 1.04630

    EUR= Reuters 2016-12-19 15:30:08.0 1.04655

    EUR= Reuters 2016-12-19 15:30:09.0 1.04630

    EUR= Reuters 2016-12-19 15:30:10.0 1.04645

    EUR= Reuters 2016-12-19 15:30:11.0 1.04645

    EUR= Reuters 2016-12-19 15:30:12.0 1.04645

    EUR= Reuters 2016-12-19 15:30:13.0 1.04635

    EUR= Reuters 2016-12-19 15:30:14.0 1.04635

    EUR= Reuters 2016-12-19 15:30:15.0 1.04640

    EUR= Reuters 2016-12-19 15:30:16.0 1.04635

    EUR= Reuters 2016-12-19 15:30:17.0 1.04635

    EUR= Reuters 2016-12-19 15:30:18.0 1.04635

    通过ajax取出来就这样的数据。。不知道highstock 那个 series那个data怎么把数据放进去。。。。不是说是json格式么。。。
  • TA的每日心情
    开心
    2019-12-18 13:31
  • 签到天数: 750 天

    [LV.10]以坛为家III

    14

    主题

    867

    帖子

    1万

    积分

    HC 神人

    看我签名看我签名看我签名看我签名看我签名看我签名看我签名看我

    Rank: 8Rank: 8

    积分
    11545

    最佳新人活跃会员热心会员发帖之王突出贡献论坛元老

    发表于 2016-12-26 10:35:23 | 显示全部楼层
    数据格式是这样的
    1. //
    2. [1147651200000,67.79],
    3. [1147737600000,64.98],
    4. [1147824000000,65.26],
    5. [1147910400000,63.18],
    6. [1147996800000,64.51],
    7. [1148256000000,63.38],
    8. [1148342400000,63.15],
    9. [1148428800000,63.34],
    10. [1148515200000,64.33],
    11. [1148601600000,63.55],
    12. [1148947200000,61.22],
    13. [1149033600000,59.77],
    14. //
    复制代码

    当然也可以自定义其他格式,

    http://code.hcharts.cn/highstock/hhhhio
    请用HCode:  http://code.hcharts.cn/ 创建一个在线实例重现你的问题,然后分享链接,便于共同调试。
  • TA的每日心情
    奋斗
    2016-12-23 15:22
  • 签到天数: 1 天

    [LV.1]初来乍到

    3

    主题

    22

    帖子

    75

    积分

    HC 新手

    Rank: 1

    积分
    75
     楼主| 发表于 2016-12-26 17:20:52 | 显示全部楼层
    宽宽 发表于 2016-12-26 10:35
    数据格式是这样的

    当然也可以自定义其他格式,

    嗯。。已经画出来了。。。谢谢。。。数据太多,好像X轴就会太挤了。。。能请问下你,要是我还想再画一条曲线,可以看到对比差,我该怎么做呢?  我现在又做了一个请求地址,然后不知道该怎么放了。。。囧
  • TA的每日心情
    开心
    2019-12-18 13:31
  • 签到天数: 750 天

    [LV.10]以坛为家III

    14

    主题

    867

    帖子

    1万

    积分

    HC 神人

    看我签名看我签名看我签名看我签名看我签名看我签名看我签名看我

    Rank: 8Rank: 8

    积分
    11545

    最佳新人活跃会员热心会员发帖之王突出贡献论坛元老

    发表于 2016-12-26 17:49:28 | 显示全部楼层
    请用HCode:  http://code.hcharts.cn/ 创建一个在线实例重现你的问题,然后分享链接,便于共同调试。
  • TA的每日心情
    奋斗
    2016-12-23 15:22
  • 签到天数: 1 天

    [LV.1]初来乍到

    3

    主题

    22

    帖子

    75

    积分

    HC 新手

    Rank: 1

    积分
    75
     楼主| 发表于 2016-12-27 08:37:55 | 显示全部楼层
    宽宽 发表于 2016-12-26 17:49
    这有一个例子
    http://code.hcharts.cn/highstock/ReFyL3

    看了这个demo。。。然后想去访问下他的数据,然后不想其他demo能访问到。。。所以也不知道格式怎么做成才好。。。
  • TA的每日心情
    开心
    2019-12-18 13:31
  • 签到天数: 750 天

    [LV.10]以坛为家III

    14

    主题

    867

    帖子

    1万

    积分

    HC 神人

    看我签名看我签名看我签名看我签名看我签名看我签名看我签名看我

    Rank: 8Rank: 8

    积分
    11545

    最佳新人活跃会员热心会员发帖之王突出贡献论坛元老

    发表于 2016-12-27 10:02:46 | 显示全部楼层
    如果数据源是自己开发的,可以在后台加上referer判断用户来路。
    请用HCode:  http://code.hcharts.cn/ 创建一个在线实例重现你的问题,然后分享链接,便于共同调试。
  • TA的每日心情
    奋斗
    2016-12-23 15:22
  • 签到天数: 1 天

    [LV.1]初来乍到

    3

    主题

    22

    帖子

    75

    积分

    HC 新手

    Rank: 1

    积分
    75
     楼主| 发表于 2016-12-27 11:51:18 | 显示全部楼层
    宽宽 发表于 2016-12-27 10:02
    如果数据源是自己开发的,可以在后台加上referer判断用户来路。

    恩,虽然不理解什么意思。。。也谢谢你解答了。。。我自己研究研究去啦。。。谢谢
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    快速回复 返回顶部 返回列表