Pentaho - 如何在折线图的 X 轴中显示完整日期
Pentaho - How to show complete date in line chart's X axis
我正在创建一个 Pentaho CDE 仪表板,但在设置日期在折线图中的显示方式时遇到了一些困难。下面的图表是我此时的:
如您所见,X 轴有 1-6 的数字,它们是月份。我想要做的是在此轴上显示更多信息,而不是简单地显示 1,例如,我想显示 "January / 2013",但我不知道如何实现这一点。
我的日期维度蒙德里安模式是这样的:
<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 不仅带有月份值而且采用字符串格式:
[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 / January”作为输出。在定义 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
}
我更喜欢在查询级别完成此类操作,它使仪表板更易于理解和维护。但这在很大程度上取决于具体情况。
我正在创建一个 Pentaho CDE 仪表板,但在设置日期在折线图中的显示方式时遇到了一些困难。下面的图表是我此时的:
如您所见,X 轴有 1-6 的数字,它们是月份。我想要做的是在此轴上显示更多信息,而不是简单地显示 1,例如,我想显示 "January / 2013",但我不知道如何实现这一点。 我的日期维度蒙德里安模式是这样的:
<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 不仅带有月份值而且采用字符串格式:
[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 / January”作为输出。在定义 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
}
我更喜欢在查询级别完成此类操作,它使仪表板更易于理解和维护。但这在很大程度上取决于具体情况。