Skip to content

Commit

Permalink
push updated cluster titles to svg data
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbc committed Aug 31, 2017
1 parent 615e0a4 commit a9e13ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
7 changes: 7 additions & 0 deletions src/shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ function(input, output) {
#write assignemnts to topics text file
})

observeEvent(input$topics, {
if (is.null(data()))
return(NULL)

js$updateTitles(cluster.titles())
})

bubbles.data <- reactive({
if (is.null(data()))
return(NULL)
Expand Down
4 changes: 2 additions & 2 deletions src/shiny/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ fluidPage(
includeCSS("www/styling.css"),
#tags$script(src="https://d3js.org/d3.v3.min.js"),
#tags$script(src="bubbles.js"),
#useShinyjs(),
#extendShinyjs(script="www/bubbles.js"),
useShinyjs(),
extendShinyjs(script="www/bubbles.js"),
sidebarLayout(
sidebarPanel(width=3,
titlePanel("Topic Aggregation"),
Expand Down
25 changes: 5 additions & 20 deletions src/shiny/www/bubbles.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
shinyjs.init = function() {
//Circle Data Set
var circleData = [
{ "cx": 20, "cy": 20, "radius": 20, "color" : "green" },
{ "cx": 70, "cy": 70, "radius": 20, "color" : "purple" }];
shinyjs.updateTitles = function(titles) {
var svg = d3.select(".bubbles svg");

//Create the SVG Viewport
var svgContainer = d3.select("svg");

//Add circles to the svgContainer
var circles = svgContainer.selectAll("circle")
.data(circleData)
.enter()
.append("circle");

//Add the circle attributes
var circleAttributes = circles
.attr("cx", function (d) { return d.cx; })
.attr("cy", function (d) { return d.cy; })
.attr("r", function (d) { return d.radius; })
.style("fill", function (d) { return d.color; });
svg.traverseTree(svg.data, function(node) {
node.terms = titles[node.id].split(" ");
});
};

0 comments on commit a9e13ae

Please sign in to comment.