jfreechart - StackedBarChart customization

流过昼夜 提交于 2019-12-02 15:56:17

问题


I have below mentioned 4 xml files in which i have state & key & BuildDate. I need to represent the "state" information of "key" in a graph based on BuildDate.

The x-axis should have past 6 days (w.r.t current date. suppose today is 7th Sept then the entry should be from 1st to 6th Sept). If there is an entry for the corresponding date in BuildDate feild then the state should be displayed as red or green (Failed - red, Success - green). Otherwise black should be displayed.

I am mainly struggling in adding the value & displaying according to date.

How can i do this via jfreechart? (StackedBarChart?)

        inupt_1.xml:

        <?xml version="1.0" encoding="UTF-8"?>
        <results>
        <result id="1" number="10" lifeCycleState="Finished" state="Failed" key="PLAN-A" BuildDate="2014 Sept 1">
        </result>
        <result id="2" number="20" lifeCycleState="Finished" state="Success" key="PLAN-A" BuildDate="2014 Sept 2">
        </result>
        <result id="3" number="30" lifeCycleState="Finished" state="Failed" key="PLAN-A" BuildDate="2014 Sept 3">
        </result>
        <result id="4" number="40" lifeCycleState="Finished" state="Success" key="PLAN-A" BuildDate="2014 Sept 4">
        </result>
        <result id="5" number="50" lifeCycleState="Finished" state="Failed" key="PLAN-A" BuildDate="2014 Sept 5">
        </result>
        <result id="6" number="60" lifeCycleState="Finished" state="Failed" key="PLAN-A" BuildDate="2014 Sept 7">
        </result>
        </results>


       inupt_2.xml:

        <?xml version="1.0" encoding="UTF-8"?>
        <results>
        <result id="1" number="10" lifeCycleState="Finished" state="Success" key="PLAN-B" BuildDate="2014 Sept 1">
        </result>
        <result id="2" number="20" lifeCycleState="Finished" state="Failed" key="PLAN-B" BuildDate="2014 Sept 2">
        </result>
        <result id="3" number="30" lifeCycleState="Finished" state="Success" key="PLAN-B" BuildDate="2014 Sept 4">
        </result>
        <result id="4" number="40" lifeCycleState="Finished" state="Success" key="PLAN-B" BuildDate="2014 Sept 5">
        </result>
        <result id="5" number="50" lifeCycleState="Finished" state="Failed" key="PLAN-B" BuildDate="2014 Sept 6">
        </result>
        <result id="6" number="60" lifeCycleState="Finished" state="Failed" key="PLAN-B" BuildDate="2014 Sept 7">
        </result>
        </results>


        inupt_3.xml:

        <?xml version="1.0" encoding="UTF-8"?>
        <results>
        <result id="1" number="10" lifeCycleState="Finished" state="Failed" key="PLAN-C" BuildDate="2014 Sept 1">
        </result>
        <result id="2" number="20" lifeCycleState="Finished" state="Success" key="PLAN-C" BuildDate="2014 Sept 3">
        </result>
        <result id="3" number="30" lifeCycleState="Finished" state="Failed" key="PLAN-C" BuildDate="2014 Sept 4">
        </result>
        <result id="4" number="40" lifeCycleState="Finished" state="Success" key="PLAN-C" BuildDate="2014 Sept 5">
        </result>
        <result id="5" number="50" lifeCycleState="Finished" state="Success" key="PLAN-C" BuildDate="2014 Sept 6">
        </result>
        <result id="6" number="60" lifeCycleState="Finished" state="Failed" key="PLAN-C" BuildDate="2014 Sept 7">
        </result>
        </results>

        inupt_4.xml:

        <?xml version="1.0" encoding="UTF-8"?>
        <results>
        <result id="1" number="10" lifeCycleState="Finished" state="Failed" key="PLAN-D" BuildDate="2014 Sept 1">
        </result>
        <result id="2" number="20" lifeCycleState="Finished" state="Success" key="PLAN-D" BuildDate="2014 Sept 2">
        </result>
        <result id="3" number="30" lifeCycleState="Finished" state="Success" key="PLAN-D" BuildDate="2014 Sept 4">
        </result>
        <result id="4" number="40" lifeCycleState="Finished" state="Success" key="PLAN-D" BuildDate="2014 Sept 5">
        </result>
        <result id="6" number="60" lifeCycleState="Finished" state="Failed" key="PLAN-D" BuildDate="2014 Sept 7">
        </result>
        </results>

Graph:

来源:https://stackoverflow.com/questions/25751516/jfreechart-stackedbarchart-customization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!