git clone https://github.com/juldebar/IndicatorsForFisheries.git
setwd("/home/tomcat7/IndicatorsForFisheries/") devtools::build() install.packages("/home/tomcat7/IndicatorsForFisheries_0.2.tar.gz", type="source", repo=NULL)
Si besoin remettre les codes du serveur Github (dans un terminal dans le répertoire du package):
git fetch --all git reset --hard origin/master
This is a short tutorial on how to use NVD3 with rCharts. The source for this tutorial can be found here
library(rCharts) library(knitr) opts_chunk$set(tidy = F, results = 'asis', comment = NA)
require(IndicatorsForFisheries) df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i1i2_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>', withSparql=FALSE) indicator1 <- Atlas_i1_SpeciesByOcean_julien(df=df, yearAttributeName="year", oceanAttributeName="ocean", speciesAttributeName="species", valueAttributeName="value")
aggData <-indicator1 plotRchartsNVD3 <- nPlot(value ~ year, group = 'ocean', data = aggData, type = 'stackedAreaChart', id = 'chart') plotRchartsNVD3$xAxis(axisLabel = 'Year') plotRchartsNVD3$yAxis(axisLabel = 'Catches') plotRchartsNVD3$chart(width = 1000, height = 300, useInteractiveGuideline=TRUE) plotRchartsNVD3$print('chart_i1_d3js')
plotRchartsNVD3bis <- nPlot(value ~ year, group = 'ocean', data = aggData, type = 'lineChart') plotRchartsNVD3bis$print('chart_i1_d3js_bis')
aggData <-indicator1 plotRchartsRickshaw <- Rickshaw$new() plotRchartsRickshaw$layer(value ~ year, data = aggData, group='ocean', type = 'area', title = "C'est de la balle") plotRchartsRickshaw$yAxis(orientation = 'right') plotRchartsRickshaw$set(width = 500, height = 200, legend = TRUE, slider = TRUE) plotRchartsRickshaw$print('chart_i1_Rickshaw')
plotRchartsRickshaw$print('chart_i1_Rickshaw')
ggplot_i1<-indicator1[2]
print(ggplot_i1)
See other rCharts examples here
require(IndicatorsForFisheries) df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i1i2_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>',withSparql=FALSE) indicator2 <- Atlas_i2_SpeciesByGear_julien(df=df, yearAttributeName="year", gearTypeAttributeName="gear_type", speciesAttributeName="species", valueAttributeName="value")
print(indicator2)
require(rCharts) aggData <-indicator2 plotRchartsHighcharts <- hPlot(value ~ year, data = aggData, type = 'column', group = 'gear_type', radius = 6, title = "Catches per month per fishing gear",width = "100%") plotRchartsHighcharts$xAxis(labels = list(rotation = -45, align = 'right', style = list(fontSize = '13px', fontFamily = 'Verdana, sans-serif')), replace = F) plotRchartsHighcharts$plotOptions(column = list(stacking = "normal", dataLabels = list(enabled = T, rotation = -90, align = 'right', color = '#FFFFFF', x = 4, y = 10, style = list(fontSize = '13px', fontFamily = 'Verdana, sans-serif')))) plotRchartsHighcharts$legend(align = 'center', verticalAlign = 'top', y = 30, margin = 20) # plotRchartsHighcharts$chart(width = 800,height = 400, zoomType = "xy") plotRchartsHighcharts$chart(zoomType = "xy") plotRchartsHighcharts$exporting(enabled = T) plotRchartsHighcharts$print('chart_i2_Highcharts')
require(IndicatorsForFisheries) df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2005</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>', layer="ns11:i3_mv") #build the I3 indicator indicator3 <- Atlas_i3_SpeciesYearByGearMonth_julien(df=df, yearAttributeName="year", monthAttributeName="month", gearTypeAttributeName="gear_type", speciesAttributeName="species", valueAttributeName="value", meanPrev5YearsAttributeName="mean_prev_5_years", stddevPrev5YearsAttributeName="stddev_prev_5_years")
print(indicator3)
library(IndicatorsForFisheries) df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i4_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsLessThanOrEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2005</ogc:Literal></ogc:PropertyIsLessThanOrEqualTo><ogc:PropertyIsGreaterThanOrEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2000</ogc:Literal></ogc:PropertyIsGreaterThanOrEqualTo></ogc:And></ogc:Filter>') #build the I4 indicator indicator4 <- Atlas_i4_SpeciesMonthByOcean_julien(df=df, oceanAttributeName="ocean", yearAttributeName="year", monthAttributeName="month", speciesAttributeName="species", valueAttributeName="value")
print(indicator4)
no rCharts version for now
require(IndicatorsForFisheries) #fetch data from IRD WFS for indicator I6, with restriction on species="YFT" and year=2000 df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i6i7i8_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>',withSparql=FALSE) #build the I6 indicator indicator6 <- Atlas_i6_SpeciesMap_julien(df=df, geomIdAttributeName="geom_id", yearAttributeName="year", speciesAttributeName="species", valueAttributeName="value")
print(indicator6)
library(IndicatorsForFisheries) #fetch data from IRD WFS for indicator I7, with restriction on species="YFT" and year=2000 df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i6i7i8_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>') #build the I7 indicator indicator7 <- Atlas_i7_SpeciesMapRelativeCatches(df=df, geomIdAttributeName="geom_id", yearAttributeName="year", speciesAttributeName="species", valueAttributeName="value")
print(indicator7)
no rCharts version but Openlayers possible thourgh netCDF export and Thredds ncWMS
library(IndicatorsForFisheries) #fetch data from IRD WFS for indicator I8, with restriction on species="YFT" and year=2000 df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i6i7i8_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>') #build the I8 indicator with targeted species = "YFT" indicator8 <- Atlas_i8_SpeciesMapRelativeCatchesOtherSpecies(df=df, targetedSpecies="YFT", geomIdAttributeName="geom_id", yearAttributeName="year", speciesAttributeName="species", valueAttributeName="value")
print(indicator8)
require(IndicatorsForFisheries) df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i9i10_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>') #build the I9 indicator indicator9 <- Atlas_i9_RelativeSizeFrequenciesBySchoolType_julien(df=df, yearAttributeName="year", speciesAttributeName="species", schoolAttributeName="school", sizeClassLowerBoundAttributeName="class_low", sizeClassUpperBoundAttributeName="class_up", fishCountAttributeName="fish_count")
print(indicator9)
library(IndicatorsForFisheries) #fetch data from IRD WFS for indicators I10, with restriction on species="YFT" and year >= 1980 and year <= 2005 df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i9i10_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsLessThanOrEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2005</ogc:Literal></ogc:PropertyIsLessThanOrEqualTo><ogc:PropertyIsGreaterThanOrEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>1980</ogc:Literal></ogc:PropertyIsGreaterThanOrEqualTo></ogc:And></ogc:Filter>') #build the I10 indicator indicator10 <- Atlas_i10_RelativeSizeFrequenciesByDecade(df=df, temporalAgg=10, yearAttributeName="year", speciesAttributeName="species", sizeClassLowerBoundAttributeName="class_low", sizeClassUpperBoundAttributeName="class_up", fishCountAttributeName="fish_count")
print(indicator10)
library(IndicatorsForFisheries) #fetch data from IRD WFS for indicators I11 with restriction on species="YFT" and year=2000 df <- readData(connectionType="remote", dataType="WFS", url="http://mdst-macroes.ird.fr:8080/constellation/WS/wfs/tuna_atlas", layer="ns11:i6i7i8_mv", ogcFilter='<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>species</ogc:PropertyName><ogc:Literal>YFT</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>year</ogc:PropertyName><ogc:Literal>2000</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>') #build the I11 indicator indicator11 <- Atlas_i11_CatchesByCountry(df=df, geomIdAttributeName="geom_id", countryAttributeName="country", speciesAttributeName="species", valueAttributeName="value")
print(indicator11)
This is a short tutorial on how to use NVD3 with rCharts. The source for this tutorial can be found here
library(rCharts) options( rcharts.mode = 'iframesrc', rcharts.cdn = TRUE, RCHART_WIDTH = 700, RCHART_HEIGHT = 400 ) library(knitr) opts_chunk$set(tidy = F, results = 'asis', comment = NA) library(datasets)
require(rCharts) haireye = as.data.frame(HairEyeColor) n1 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(haireye, Sex == 'Male'), type = 'multiBarChart' ) n1$print('chart10')
p1 <- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterChart') p1$xAxis(axisLabel = 'Weight') p1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.