2013-10-25 3 views
2

입니다 코드 내가 가진 :rCharts 인력거 차트에 호버 매개 변수를 설정하려면 어떻게해야합니까?

#Start up rickshaw charts 
library(rCharts) 
df.plot <- Rickshaw$new() 

#Set chart parameters 
df.plot$layer(
    y ~ x, 
    data = df.aggregate2, 
    type = "area", 
    groups = "var2", 
    colors= c("#E1CA4C","#74D2E3","#B70002","#987989","#9A9A9A","#ACD759","#5FCC5C","#4C6676"), 
    height = 500, 
    width = 800 
) 
df.plot$set(
    hoverDetail = TRUE, 
    yAxis = TRUE, 
    xAxis = TRUE, 
    shelving = FALSE, 
    legend = TRUE, 
    slider = TRUE, 
    highlight = TRUE, 
    unstack = TRUE,  
) 

df.plot$xAxis(tickFormat= 
        "#!function(d) { 
        return d3.time.format('%Y-%m-%d')(new Date(d * 86400000)); 
        } 
        !#") 
#Plot 
df.plot$print('Performance', include_assets = TRUE, cdn = TRUE) 

내 호버은 다음과 같습니다

2013년 (월) 9월 23일 그리니치 표준시 00시 00분 0초 VAR 1045.00

그리고 나는 그것을보고 싶어 다음과 같이하십시오. 월요일, 9 월 23 일 var 1045 * 시간이없는 경우 & 소수점이 없습니다.

답변

3

hoverDetail 메서드를 사용하여 포맷터 함수를 전달할 수 있습니다. 원하는 문자열을 출력하는 javascript 함수를 작성해야합니다.

moods.plot$hoverDetail(formatter = "#! function(series, x, y){ 

} !#") 

this page

의 출처를 확인하여 formatter 함수의 예를 볼 수있다
관련 문제