2015-07-17 9 views
48

मैं rvharts पर nvd3 के साथ काम कर रहा हूं और सोच रहा था कि लाइन के साथ निचले दृश्य खोजक ग्राफ के लिए अक्ष को अनुकूलित करने का कोई तरीका था WithFocusChart। मैंने नीचे एक प्रतिलिपि उदाहरण प्रदान किया है, जहां मैं हजारों स्थान को अलग करने के लिए एक्स और वाई अक्ष को अनुकूलित करता हूं, लेकिन यह स्वरूपण निचले दृश्य खोजक चार्ट पर दिखाई नहीं देता है। यह कैसे हल किया जा सकता है? धन्यवाद!rCharts nvd3 lineWithFocusChart अनुकूलन

 library(rCharts) 
     temp <- data.frame(x = 1:2000, y = 1:2000, z = c(rep(1,1000), rep(0,1000))) 
     g <- nPlot(y ~ x, group = "z", data = temp, type = "lineWithFocusChart") 
     g$templates$script <- "http://timelyportfolio.github.io/rCharts_nvd3_templates/chartWithTitle_styled.html" 
     g$set(title = "Example") 
     g$chart(transitionDuration = -1, 
       tooltipContent = "#! function(key, x, y) { 
           return 'z: ' + key + '<br/>' + 'x: ' + x + '<br/>' + 'y: ' + y 
           }!#", 
       showLegend = FALSE, margin = list(left = 200, 
               right = 100, 
               bottom = 100, 
               top = 100))    
     g$xAxis(axisLabel = "x", 
       tickFormat = "#!function(x) {return d3.format(',.0f')(x);}!#") 
     g$yAxis(axisLabel = "y", 
       width = 100, 
       tickFormat = "#!function(y) {return d3.format(',.0f')(y);}!#", 
       showMaxMin = FALSE) 
     g 
+0

हाँ मुझे विश्वास है कि आरएचएचटीएस स्थिर हो गया है। मैं y2Axis का उपयोग नहीं कर सका, इसलिए मुझे नहीं लगता कि इसमें शामिल हो गया है और मुझे नहीं लगता कि यह दुर्भाग्य से कभी भी होगा। – johnny838

+0

हाय निक, मैंने थोड़ी देर के लिए लाइन विथफोकस चार्ट छोड़ दिया, और मैं आपकी मदद करने में बहुत सराहना करता हूं। मैंने हाल ही में अपने भंडार से rCharts को स्थापित करने का प्रयास किया है, लेकिन y2Axis xAxis के रूप में एक ही प्रारूप पर ले जाता है। हैरानी की बात है कि, एक्स 2 एक्सिस वाई अक्ष प्रारूपण पर लेता है, लेकिन उसके बाद दृश्य खोजक के एक्स अक्ष को वाई अक्ष प्रारूप के साथ स्वरूपित करता है। यह समस्याग्रस्त है क्योंकि मैं अंततः निचले एक्स अक्ष को वाई अक्ष से एक अलग प्रारूप (एक दिनांक प्रारूप) रखना चाहता हूं। यदि आप एक नज़र डालने के इच्छुक हैं तो मैं एक अलग उदाहरण प्रदान कर सकता हूं। धन्यवाद! – johnny838

उत्तर

2

मैं सिर्फ यह पता चला के रूप में मैं टैग किया R अनुत्तरित प्रश्न देख रहा था। क्षमा करें मुझे याद आया। rCharts रुक गया है, लेकिन अधिक लचीला htmlwidgets आधारभूत संरचना के आधार पर एक नया संस्करण ढूंढें। मुझे यकीन है कि यह उत्तर बहुत देर हो चुकी है, लेकिन मैंने टेम्पलेट को y2Axis के प्रारूपण की अनुमति देने के लिए बदल दिया है।

# uncomment this to install the fix 
#devtools::install_github("timelyportfolio/rCharts") 

library(rCharts) 
temp <- data.frame(x = 1:2000, y = 1:2000, z = c(rep(1,1000), rep(0,1000))) 
g <- nPlot(y ~ x, group = "z", data = temp, type = "lineWithFocusChart") 
g$templates$script <- "c:/users/kent.tleavell_nt/dropbox/development/r/rCharts_nvd3_templates/chartWithTitle_styled.html" 
g$set(title = "Example") 
g$chart(transitionDuration = -1, 
     tooltipContent = "#! function(key, x, y) { 
     return 'z: ' + key + '<br/>' + 'x: ' + x + '<br/>' + 'y: ' + y 
     }!#", 
     showLegend = FALSE, margin = list(left = 200, 
              right = 100, 
              bottom = 100, 
              top = 100))    
g$xAxis(axisLabel = "x", 
     tickFormat = "#!function(x) {return d3.format(',.0f')(x);}!#") 
g$yAxis(axisLabel = "y", 
     width = 100, 
     tickFormat = "#!function(y) {return d3.format(',.0f')(y);}!#", 
     showMaxMin = FALSE) 
g$x2Axis(tickFormat = "#!function(x) {return d3.format('1.2s')(x);}!#") 

# now we have a new y2Axis function 
g$y2Axis(
    tickFormat = "#!function(y) {return d3.format('1.2s')(y);}!#" 
) 

g