如何在一个折线图中制作4条折线?

如何在一个折线图中制作4条折线,我的4条折线都来自于同一张数据库表,第一条是不加任何条件的,后面3条分别加了不通的条件,横轴是时间,纵轴是个数,请问这个要怎么做?

ds1.

select 

a.id,

a.yhsx,

a.fxrq,

a.zgsx,

a.yhstate,

a.createOrgPath

from aj_yinh a

ds2.加上条件:where NOW()>a.zgsx AND a.yhstate<>'yibihuan'

ds3.加上条件:where NOW()<a.zgsx AND a.yhstate<>'yibihuan'

ds4.加上条件:where a.yhstate='yibihuan'

FineReport fuzao1314 发布于 2019-4-12 09:58
1min目标场景问卷 立即参与
回答问题
悬赏:4 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
firegunzxLv6高级互助
发布于2019-4-12 10:17(编辑于 2019-4-12 10:28)

你这sql出来之后,取出来的时间都是不一样的,横轴数据都不一致,怎么玩?

要想4条折线都在一个图里,必须横轴单位统一,就是按时间group by,然后分类按时间,系列名是折线分类,值正常取就行了。

  • fuzao1314 fuzao1314(提问者) 横轴时间按1个月作为间距,这样不可以吗?
    2019-04-12 10:19 
  • firegunzx firegunzx 回复 fuzao1314(提问者) 可以,这样写sql,select 时间,sum(值),\'折线1\' as type from 表名 union select 时间,sum(值),\'折线2\' as type from 表名 where ds2条件 union select 时间,sum(值),\'折线3\' as type from 表名 where ds3条件 union select 时间,sum(值),\'折线4\' as type from 表名 where ds4条件 然后再折线图里,分类用 时间 , 系列名用type ,值用sum(值)
    2019-04-12 10:26 
  • fuzao1314 fuzao1314(提问者) 回复 firegunzx select zgsx,sum(zgsx), as type from aj_yinh union select 时间,sum(zgsx), as type from aj_yinh where NOW()>a.zgsx AND a.yhstate<>\'yibihuan\' union select zgsx,sum(zgsx), as type from aj_yinh where NOW()\'yibihuan\' union select zgsx,sum(zgsx), as type from aj_yinh where a.yhstate=\'yibihuan\' union select zgsx,sum(zgsx) 是这样吗?预览就报错了。实在不好意思,我是初学,如果你会麻烦告诉我下,谢谢了
    2019-04-12 10:38 
  • firegunzx firegunzx 回复 fuzao1314(提问者) 你没学过sql啊,哪个字段是日期?
    2019-04-12 10:59 
  • firegunzx firegunzx 回复 fuzao1314(提问者) 527420260,加我QQ,我远程看看
    2019-04-12 11:01 
最佳回答
0
luozhiweiLv5见习互助
发布于2019-4-12 10:25(编辑于 2019-4-12 10:33)

类似这样的吗?image.pngimage.png

  • fuzao1314 fuzao1314(提问者) 嗯嗯,我要4条,后面3条就是分别加了上面的条件
    2019-04-12 10:28 
  • luozhiwei luozhiwei 回复 fuzao1314(提问者) 再看一下,sql写好了,然后想要几条折线就直接新增几个字段
    2019-04-12 10:34 
  • 3关注人数
  • 2111浏览人数
  • 最后回答于:2019-4-12 10:33
    请选择关闭问题的原因
    确定 取消
    返回顶部