我正在创建一个Pentaho CDE仪表板,并且在设置折线图中如何显示日期时遇到了一些困难。下面的图表是我目前所拥有的:
如您所见,X轴的数字是1-6,它们是月。我想要做的是在此轴上显示更多信息,而不是简单地显示1,例如,我想显示“ 2013年1月”,但是我不知道如何实现此目的。我的日期维度Mondrian模式是这样的:
<Dimension type="TimeDimension" visible="true" foreignKey="data_id" highCardinality="false" name="Data">
<Hierarchy name="data" visible="true" hasAll="true">
<Table name="dimensao_data">
</Table>
<Level name="ano" visible="true" column="ano" type="Numeric" uniqueMembers="true" levelType="TimeYears" hideMemberIf="Never">
</Level>
<Level name="semestre" visible="true" column="semestre" type="Numeric" uniqueMembers="false" levelType="TimeHalfYears" hideMemberIf="Never" captionColumn="labelSemestre">
</Level>
<Level name="quarto" visible="true" column="quarto" type="Numeric" uniqueMembers="false" levelType="TimeQuarters" hideMemberIf="Never" captionColumn="labelQuarto">
</Level>
<Level name="mes" visible="true" column="mes" type="Numeric" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="Never" captionColumn="labelMes">
</Level>
<Level name="dia" visible="true" column="dia" type="Numeric" uniqueMembers="false" levelType="TimeDays" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
这是我用来检索图表数据的MDX:
SELECT NON EMPTY {[Measures].[valor]} ON COLUMNS,
NON EMPTY CrossJoin({[pagamento.forma].[moeda].MEMBERS}, {[Data.data].[mes].MEMBERS}) ON ROWS
FROM [Vendas]
WHERE {[Empresa.empresa].[MATRIZ]}
新的信息
当我使用调试模式时,我可以看到Data.data不仅带有月份值而且具有String格式:
[pvc.LineChart ]: DATA SOURCE SUMMARY
╔═════════╤═════════════════════╤═════════════╤══════════╗
║ Name │ pagamento.forma │ Data.data │ valor ║
╟─────────┼─────────────────────┼─────────────┼──────────╢
║ Label │ │ │ ║
╟─────────┼─────────────────────┼─────────────┼──────────╢
║ Type │ String │ String │ Numeric ║
╟─────────┼─────────────────────┼─────────────┼──────────╢
║ 1 │ "BOLETO BANCARIO" │ "1" │ 10469.15 ║
║ 2 │ "BOLETO BANCARIO" │ "2" │ 16279.45 ║
║ 3 │ "BOLETO BANCARIO" │ "3" │ 16279.45 ║
║ 4 │ "BOLETO BANCARIO" │ "4" │ 5810.3 ║
║ 5 │ "BOLETO BANCARIO" │ "5" │ 16279.45 ║
║ 6 │ "BOLETO BANCARIO" │ "6" │ 5810.3 ║
║ 7 │ "CARTÃO DE CRÉDITO" │ "1" │ 10243.57 ║
║ 8 │ "CARTÃO DE CRÉDITO" │ "2" │ 9178.03 ║
║ 9 │ "CARTÃO DE CRÉDITO" │ "3" │ 10273.08 ║
║ 10 │ "CARTÃO DE CRÉDITO" │ "4" │ 10110.4 ║
║ 11 │ "CARTÃO DE CRÉDITO" │ "5" │ 10366.3 ║
║ 12 │ "CARTÃO DE CRÉDITO" │ "6" │ 10768.75 ║
║ 13 │ "CARTÃO DE DÉBITO" │ "1" │ 15584.84 ║
║ 14 │ "CARTÃO DE DÉBITO" │ "2" │ 12400.53 ║
║ 15 │ "CARTÃO DE DÉBITO" │ "3" │ 13517.65 ║
╟─────────┼─────────────────────┼─────────────┼──────────╢
║ (15/41) │ │ │ ║
╚═════════╧═════════════════════╧═════════════╧══════════╝
因此,我相信问题出在Data.data的结果上。如何购买完整日期以显示在图表中?
有多种方法可以实现:
定义包含要显示的信息的度量:
With member [Measures].[Date Label] as [data].CurrentMember.Caption || " / " || Ancestor( [data].CurrentMember, [data].[ano]).Name
这应该为您提供“ 2013 /一月”作为输出。定义CDA查询时,只需过滤掉要传递给图表的列即可。
您可以通过玩转图表的PostFetch来更改图表显示的内容。就像是
function(data){
var results = data.resultset.map(function(d){
// Tweak the contents of each line of data here
// You will want to take the value of d[0] and replace it by
// something else.
return d;
});
data.resultset = results;
return data
}
我更喜欢在查询级别完成这种事情,它使仪表板更易于理解和维护。但这在很大程度上取决于细节。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句