BIRT:复杂的折线图

时间:2016-03-25 10:20:40

标签: java eclipse charts birt

我想绘制一张如下图所示的图表: enter image description here

我使用soap服务作为数据源。我有目的使用数据结构。

<return>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>725072</powerValue>
           <xCategory>2015-12-10T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>679679</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-10T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>247</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-10T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>701065</powerValue>
           <xCategory>2015-12-11T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>653653</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-11T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>121</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-11T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>499024</powerValue>
           <xCategory>2015-12-12T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>477477</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-12T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>52</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-12T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>544024</powerValue>
           <xCategory>2015-12-13T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>522522</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-13T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>53</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-13T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>744066</powerValue>
           <xCategory>2015-12-14T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>699699</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-14T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>264</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-14T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>659054</powerValue>
           <xCategory>2015-12-15T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>614614</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-15T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>273</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-15T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>582055</powerValue>
           <xCategory>2015-12-16T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>534534</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-16T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>263</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-16T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>518052</powerValue>
           <xCategory>2015-12-17T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>473473</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-17T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>323</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-17T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>512031</powerValue>
           <xCategory>2015-12-18T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>476476</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-18T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>148</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-18T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>407020</powerValue>
           <xCategory>2015-12-19T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>383383</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-19T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>23</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-19T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>410020</powerValue>
           <xCategory>2015-12-20T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>386386</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-20T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>24</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-20T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>564054</powerValue>
           <xCategory>2015-12-21T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>508508</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-21T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>136</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-21T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>534062</powerValue>
           <xCategory>2015-12-22T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>492492</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-22T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>146</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-22T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>518065</powerValue>
           <xCategory>2015-12-23T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>473473</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-23T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>218</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-23T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>482021</powerValue>
           <xCategory>2015-12-24T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>450450</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-24T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>64</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-24T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>426018</powerValue>
           <xCategory>2015-12-25T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>402402</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-25T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>0</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-25T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>417019</powerValue>
           <xCategory>2015-12-26T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>394394</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-26T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>0</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-26T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>438020</powerValue>
           <xCategory>2015-12-27T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>415415</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-27T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>0</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-27T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>525022</powerValue>
           <xCategory>2015-12-28T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>496496</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-28T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>91</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-28T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>483023</powerValue>
           <xCategory>2015-12-29T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>457457</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-29T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>95</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-29T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>528024</powerValue>
           <xCategory>2015-12-30T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>499499</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-30T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>135</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-30T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <elecGroupName>Electricité</elecGroupName>
           <powerValue>460020</powerValue>
           <xCategory>2015-12-31T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>436436</capacityValue>
           <groupName>Eau</groupName>
           <xCategory>2015-12-31T00:00:00+07:00</xCategory>
        </labChartLst>
        <labChartLst>
           <capacityValue>14</capacityValue>
           <groupName>Gaz</groupName>
           <xCategory>2015-12-31T00:00:00+07:00</xCategory>
        </labChartLst>
     </return>

但我无法配置birt的图表模板,如上图所示。

1 个答案:

答案 0 :(得分:1)

由于有两个Y轴,您需要对规范进行非规范化。如果你不能改变肥皂服务,在BIRT中做一个简单的方法就是在数据集中创建三个计算列,每列代表一个度量:&#34; Water&#34;,&#34; Gas&#34;,&#34; Electricity&#34;。例如,在您的样本中,&#34; waterValue&#34;表达式将是:

row["groupName"]=="Eau"?row["capacityValue"]:0

因此我们最终得到了这些新列:

enter image description here

最后:

  • 通过启用&#34;辅助轴&#34;来创建标准折线图。选项
  • 使用&#34; elecValue&#34;将系列1设置为第一轴。柱
  • 使用&#34; gasValue&#34;将系列2和3设置到辅助轴。和&#34; waterValue&#34;分别为

其余的工作只是装饰性的:你实际上可以得到完全预期的输出