output$plot <- renderImage({
outfile <- tempfile(fileext = '.png')
png(outfile, width = 400, height = 300)
venn.diagram(
x = list(
T = T,
I = I
),
main = "Venn Diagram ",
filename =outfile, output=TRUE,
lwd = 2,na = "remove",
fill = c("orange", "blue"),
alpha = c(0.5,0.5),
label.col = "black",
cex=1.5,
fontface = "plain",
cat.col = c("cornflowerblue", "pink"),
cat.cex = 1.5,
cat.fontfamily = "serif",
cat.fontface = "plain",
cat.dist = c(0.05, 0.05),
cat.pos = c(-20, 14),
cat.default.pos = "text",
scaled = FALSE
)
dev.off()
list(src = outfile,
contentType = 'image/png',
width = 400,
height = 300,
alt = "This is alternate text")
}, deleteFile = TRUE)
I was trying plot a venn diagram using this code. But it only displays This is alternate text and not outputting any image on the app, Any Idea ?
Try to create a reactive graph as shown below
output$plot <- renderImage({
vennd <- reactive({venn.diagram(
x = list(
T = T,
I = I
),
main = "Venn Diagram ",
filename =outfile, output=TRUE,
lwd = 2,na = "remove",
fill = c("orange", "blue"),
alpha = c(0.5,0.5),
label.col = "black",
cex=1.5,
fontface = "plain",
cat.col = c("cornflowerblue", "pink"),
cat.cex = 1.5,
cat.fontfamily = "serif",
cat.fontface = "plain",
cat.dist = c(0.05, 0.05),
cat.pos = c(-20, 14),
cat.default.pos = "text",
scaled = FALSE
)
})
outfile <- tempfile(fileext = '.png')
png(outfile, width = 400, height = 300)
vennd()
dev.off()
list(src = outfile,
contentType = 'image/png',
width = 400,
height = 300,
alt = "This is alternate text")
}, deleteFile = TRUE)
output$plot <- renderImage({
vennd <- reactive({venn.diagram(
x = list(
T = T,
I = I
),
main = "",
filename =outfile, output=TRUE,
lwd = 2,na = "remove",imagetype="png",
fill = c("orange", "blue"),
alpha = c(0.5,0.5),
label.col = "black",
cex=1.5,
fontface = "plain",
cat.col = c("cornflowerblue", "pink"),
cat.cex = 1.5,
cat.fontfamily = "serif",
cat.fontface = "plain",
cat.dist = c(0.05, 0.05),
cat.pos = c(-20, 14),
cat.default.pos = "text",
scaled = FALSE
)
})
outfile <- tempfile(fileext = '.png')
png(outfile, width = 500, height = 500,type="cairo")
vennd()
dev.off()
list(src = outfile,
contentType = 'image/png',
width = 500,
height = 500,
alt = "This is alternate text")
}, deleteFile = TRUE)
Need to add imagetype="png" and type="cairo" thank you #YBS
At the end, I'm trying to detect collision, and delete the marble as it touches the rectangle. How do I do that?
import CoreMotion
import SpriteKit
import GameplayKit
class GameScene: SKScene, SKPhysicsContactDelegate{
let marbleSprite = SKSpriteNode(imageNamed: "marble")
let marbleSprite1 = SKSpriteNode(imageNamed: "marble")
let marbleSprite2 = SKSpriteNode(imageNamed: "marble")
let marbleSprite3 = SKSpriteNode(imageNamed: "marble")
let marbleSprite4 = SKSpriteNode(imageNamed: "marble")
let marbleSprite5 = SKSpriteNode(imageNamed: "marble")
let marbleSprite6 = SKSpriteNode(imageNamed: "marble")
let marbleSprite7 = SKSpriteNode(imageNamed: "marble")
let marbleSprite8 = SKSpriteNode(imageNamed: "marble")
let marbleSprite9 = SKSpriteNode(imageNamed: "marble")
let rectSprite = SKSpriteNode(imageNamed: "rect")
let rectSprite1 = SKSpriteNode(imageNamed: "rect")
let motionManager = CMMotionManager()
let marbleCategory: UInt32 = 1 << 0
let wallCategory: UInt32 = 2 << 0
let rectCategory: UInt32 = 3 << 0
var teal = SKColor(red: 0, green: 128, blue: 128, alpha: 1)
override func didMove(to view: SKView) {
backgroundColor = teal
marbleSprite.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite.setScale(0.5)
marbleSprite.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite.size.width / 2)
marbleSprite.physicsBody?.allowsRotation = true
marbleSprite.physicsBody?.categoryBitMask = marbleCategory
marbleSprite.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite1.name = "Marble"
marbleSprite1.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite1.setScale(0.5)
marbleSprite1.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite1.size.width / 2)
marbleSprite1.physicsBody?.allowsRotation = true
marbleSprite1.physicsBody?.categoryBitMask = marbleCategory
marbleSprite1.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite1.name = "Marble"
marbleSprite2.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite2.setScale(0.5)
marbleSprite2.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite2.size.width / 2)
marbleSprite2.physicsBody?.allowsRotation = true
marbleSprite2.physicsBody?.categoryBitMask = marbleCategory
marbleSprite2.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite2.name = "Marble"
marbleSprite3.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite3.setScale(0.5)
marbleSprite3.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite3.size.width / 2)
marbleSprite3.physicsBody?.allowsRotation = true
marbleSprite3.physicsBody?.categoryBitMask = marbleCategory
marbleSprite3.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite3.name = "Marble"
marbleSprite4.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite4.setScale(0.5)
marbleSprite4.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite4.size.width / 2)
marbleSprite4.physicsBody?.allowsRotation = true
marbleSprite4.physicsBody?.categoryBitMask = marbleCategory
marbleSprite4.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite4.name = "Marble"
marbleSprite5.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite5.setScale(0.5)
marbleSprite5.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite5.size.width / 2)
marbleSprite5.physicsBody?.allowsRotation = true
marbleSprite5.physicsBody?.categoryBitMask = marbleCategory
marbleSprite5.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite5.name = "Marble"
marbleSprite6.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite6.setScale(0.5)
marbleSprite6.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite6.size.width / 2)
marbleSprite6.physicsBody?.allowsRotation = true
marbleSprite6.physicsBody?.categoryBitMask = marbleCategory
marbleSprite6.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite6.name = "Marble"
marbleSprite7.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite7.setScale(0.5)
marbleSprite7.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite7.size.width / 2)
marbleSprite7.physicsBody?.allowsRotation = true
marbleSprite7.physicsBody?.categoryBitMask = marbleCategory
marbleSprite7.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite7.name = "Marble"
marbleSprite8.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite8.setScale(0.5)
marbleSprite8.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite8.size.width / 2)
marbleSprite8.physicsBody?.allowsRotation = true
marbleSprite8.physicsBody?.categoryBitMask = marbleCategory
marbleSprite8.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite8.name = "Marble"
marbleSprite9.position = CGPoint(x: self.frame.width / 15, y: self.frame.height / 15)
marbleSprite9.setScale(0.5)
marbleSprite9.physicsBody = SKPhysicsBody(circleOfRadius: marbleSprite9.size.width / 2)
marbleSprite9.physicsBody?.allowsRotation = true
marbleSprite9.physicsBody?.categoryBitMask = marbleCategory
marbleSprite9.physicsBody?.collisionBitMask = wallCategory | marbleCategory
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
self.physicsBody?.isDynamic = false
self.physicsBody?.categoryBitMask = wallCategory
marbleSprite9.name = "Marble"
rectSprite.position = CGPoint(x: 0, y: self.frame.height / 2)
rectSprite.setScale(3.0)
rectSprite.physicsBody = SKPhysicsBody(rectangleOf: rectSprite.size)
rectSprite.physicsBody?.allowsRotation = false
rectSprite.physicsBody?.categoryBitMask = rectCategory
rectSprite.physicsBody?.collisionBitMask = marbleCategory
rectSprite.physicsBody?.affectedByGravity = false
rectSprite.physicsBody?.isDynamic = false
rectSprite.name = "Rect"
rectSprite1.position = CGPoint(x: 410, y: self.frame.height / 2)
rectSprite1.setScale(3.0)
rectSprite1.physicsBody = SKPhysicsBody(rectangleOf: rectSprite1.size)
rectSprite1.physicsBody?.allowsRotation = false
rectSprite1.physicsBody?.categoryBitMask = rectCategory
rectSprite1.physicsBody?.collisionBitMask = marbleCategory
rectSprite1.physicsBody?.affectedByGravity = false
rectSprite1.physicsBody?.isDynamic = false
rectSprite1.name = "Rect"
physicsWorld.gravity = CGVector(dx: 0, dy: 0)
addChild(marbleSprite)
addChild(marbleSprite1)
addChild(marbleSprite2)
addChild(marbleSprite3)
addChild(marbleSprite4)
addChild(marbleSprite5)
addChild(marbleSprite6)
addChild(marbleSprite7)
addChild(marbleSprite8)
addChild(marbleSprite9)
addChild(rectSprite)
addChild(rectSprite1)
motionManager.startAccelerometerUpdates()
}
override func update(_ currentTime: TimeInterval) {
if let accelerometerData = motionManager.accelerometerData {
print(accelerometerData)
physicsWorld.gravity = CGVector(dx: accelerometerData.acceleration.x * 10, dy: accelerometerData.acceleration.y * 10)
}
}
func didBegin(_ contact: SKPhysicsContact) {
var firstBody = SKPhysicsBody()
var secondBody = SKPhysicsBody()
if contact.bodyA.node?.name == "Marble" {
firstBody = contact.bodyA
secondBody = contact.bodyB
} else {
firstBody = contact.bodyB
secondBody = contact.bodyA
}
if firstBody.node?.name == "Marble" && secondBody.node?.name == "Rect" {
secondBody.node?.removeFromParent()
}
}
}
What I thought that would happen was that once the marble touches the rectangle, the marble would disappear, and be gone. What actually happens is when the marble hits the rectangle, nothing happens. Am I doing something wrong?
Try making these changes and set the contact delegate.
let marbleCategory: UInt32 = 0x1 << 0
let wallCategory: UInt32 = 0x1 << 1
let rectCategory: UInt32 = 0x1 << 2
override func didMove(to view: SKView) {
physicsWorld.contactDelegate = self
}
func didBegin(_ contact: SKPhysicsContact) {
let collision: UInt32 = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask
if collision == marbleCategory | rectCatagory {
rectSprite.removeFromParent()
}
}
I am trying to implement a drill in or drill down in a pie chart. I actually have a working drill down pie chart, however, when I changed the values of the collection, it did not work. I am wondering what went wrong as I completely followed the working code and just replaced its values. The chart simply does not show up and has an error: Uncaught Error: Unknown header type: 17format+en,default+en,ui+en,controls+en,corechart+en.I.js:191. I am not sure though whether this error is related to the problem.
Javascript:
google.load('visualization', '1', {packages: ['corechart', 'controls']});
google.setOnLoadCallback(drawChart1);
var index = 0;
function drawChart1() {
<%
int aku = 0, cdu = 0, ls = 0, ptr = 0, rad = 0, oper = 0;
int aku1 = 0, aku2 = 0, aku3 = 0, aku4 = 0, aku5 = 0;
int cdu1 = 0, cdu2 = 0, cdu3 = 0, cdu4 = 0, cdu5 = 0, cdu6 = 0;
int ls1 = 0, ls2 = 0, ls3 = 0, ls4 = 0, ls5 = 0, ls6 = 0, ls7 = 0, ls8 = 0, ls9 = 0, ls10 = 0;
int ptr1 = 0, ptr2 = 0, ptr3 = 0, ptr4 = 0;
int rad1 = 0, rad2 = 0, rad3 = 0;
int oper1 = 0;
%> //Dummy values
//Main
var main = [
['Artificial Kidney Unit', <%=aku%>],
['Cardiac Diagnostic Unit', <%=cdu%>],
['Laboratory Services', <%=ls%>],
['Physical Therapy and Rehabilitation', <%=ptr%>],
['Radiology', <%=rad%>],
['Operations', <%=oper%>]
];
//Aku
var akuu = [
['Hemodialysis', <%=aku1%>],
['Peritoneal Dialysis', <%=aku2%>],
['Continuous Renal Replacement Therapy', <%=aku3%>],
['Sustained Low Efficient Dialysis', <%=aku4%>],
['Private Dialysis Suite', <%=aku5%>]
];
//Cdu
var cduu = [
['Electrocardiography', <%=cdu1%>],
['Ambulatory Electrocardiography', <%=cdu2%>],
['Exercise Stress Test', <%=cdu3%>],
['2D Echo', <%=cdu4%>],
['Lower Extremity Arterial & Venous Color Duplex Scan', <%=cdu5%>],
['Carotid Artery Duplex Scan', <%=cdu6%>]
];
//Ls
var lss = [
['Hematology', <%=ls1%>],
['Blood Chemistry', <%=ls2%>],
['Immunology and Serology', <%=ls3%>],
['Clinical Microscopy', <%=ls4%>],
['Microbiology', <%=ls5%>],
['Blood Bank and Transfusion Services', <%=ls6%>],
['Drug Testing', <%=ls7%>],
['Parasitology', <%=ls8%>],
['Surgical Pathology', <%=ls9%>],
['Cytopathology', <%=ls10%>]
];
//Ptr
var ptrr = [
['Physical Therapy', <%=ptr1%>],
['Occupational Therapy', <%=ptr2%>],
['Ultrasound Diagnostic Therapy', <%=ptr3%>],
['Orthotics and Prosthetic Evaluation', <%=ptr4%>]
];
//rad
var radd = [
['X-ray', <%=rad1%>],
['Ultrasound', <%=rad2%>],
['CT Scan', <%=rad3%>]
];
//oper
var operr = [
['Surgery', <%=oper1%>]
];
var collection = [];
collection[0] = google.visualization.arrayToDataTable(main);
collection[1] = google.visualization.arrayToDataTable(akuu);
collection[2] = google.visualization.arrayToDataTable(cduu);
collection[3] = google.visualization.arrayToDataTable(lss);
collection[4] = google.visualization.arrayToDataTable(ptrr);
collection[5] = google.visualization.arrayToDataTable(radd);
collection[6] = google.visualization.arrayToDataTable(operr);
var options1 = {
title: 'Departments',
animation: {'duration': 500,
'easing': 'in'},
action: function() {
button.onclick = function() {
recreateDashboard(0);
};
}
};
var chart1 = new google.visualization.PieChart(document.getElementById('chart1'));
google.visualization.events.addListener(chart1, 'select', drillIn);
google.visualization.events.addListener(chart1, 'click', drillOut);
chart1.draw(collection[0], options1);
function drillIn() {
var sel = chart1.getSelection();
var row = chart1.getSelection()[0].row;
options1['title'] = collection[index].getValue(sel[0].row, 0);
if(index === 0) {
if(row === 0) {
index = 1;
}
if(row === 1) {
index = 2;
}
if(row === 2) {
index = 3;
}
if(row === 3) {
index = 4;
}
if(row === 4) {
index = 5;
}
if(row === 5) {
index = 6;
}
}
else if(index === 1 || index === 2 || index === 3 || index === 4 || index === 5 || index === 6) {
options1['title'] = '# of services rendered in <%=year%>';
index = 0;
}
chart1.draw(collection[index], options1);
}
function drillOut(e) {
if(e.targetID === "title") {
if(index !== 0)
index--;
else if(index === 4 || index === 6 || index === 8)
index -= 2;
chart1.draw(collection[index], options1);
}
}
Html:
<div id="chart1">
</div>
I have figured out the mistake. All of these need a title before inputting the values.
Revised code:
//Main
var main = [
['Department', 'Value'],
['Cardiac Diagnostic Unit', <%=cdu%>],
['Laboratory Services', <%=ls%>],
['Physical Therapy and Rehabilitation', <%=ptr%>],
['Radiology', <%=rad%>],
['Operations', <%=oper%>]
];
//Aku
var akuu = [
['Service', 'Value'],
['Hemodialysis', <%=aku1%>],
['Peritoneal Dialysis', <%=aku2%>],
['Continuous Renal Replacement Therapy', <%=aku3%>],
['Sustained Low Efficient Dialysis', <%=aku4%>],
['Private Dialysis Suite', <%=aku5%>]
];
//Cdu
var cduu = [
['Service', 'Value'],
['Electrocardiography', <%=cdu1%>],
['Ambulatory Electrocardiography', <%=cdu2%>],
['Exercise Stress Test', <%=cdu3%>],
['2D Echo', <%=cdu4%>],
['Lower Extremity Arterial & Venous Color Duplex Scan', <%=cdu5%>],
['Carotid Artery Duplex Scan', <%=cdu6%>]
];
//Ls
var lss = [
['Service', 'Value'],
['Hematology', <%=ls1%>],
['Blood Chemistry', <%=ls2%>],
['Immunology and Serology', <%=ls3%>],
['Clinical Microscopy', <%=ls4%>],
['Microbiology', <%=ls5%>],
['Blood Bank and Transfusion Services', <%=ls6%>],
['Drug Testing', <%=ls7%>],
['Parasitology', <%=ls8%>],
['Surgical Pathology', <%=ls9%>],
['Cytopathology', <%=ls10%>]
];
//Ptr
var ptrr = [
['Service', 'Value'],
['Physical Therapy', <%=ptr1%>],
['Occupational Therapy', <%=ptr2%>],
['Ultrasound Diagnostic Therapy', <%=ptr3%>],
['Orthotics and Prosthetic Evaluation', <%=ptr4%>]
];
//rad
var radd = [
['Service', 'Value'],
['X-ray', <%=rad1%>],
['Ultrasound', <%=rad2%>],
['CT Scan', <%=rad3%>]
];
//oper
var operr = [
['Service', 'Value'],
['Surgery', <%=oper1%>]
];
I am trying to retrieve Fb comments on a particular post. I tried to implement following method:
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost1:#"3788106577940/comments" withPostVars1:[[NSDictionary alloc]initWithObjectsAndKeys:#"Hello",#"Hi", nil]];
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil];
//[parser release];
//let's save the 'id' Facebook gives us so we can delete it if the user presses the 'delete /me/feed button'
self.feedPostId = (NSString *)[facebook_response objectForKey:#"id"];
NSLog(#"feedPostId, %#", feedPostId);
But i am getting the following error:
<CFBasicHash 0x6a64360 [0x1751b38]>{type = mutable dict, count = 1,
entries =>
11 : <CFString 0x6a64e30 [0x1751b38]>{contents = "error"} = <CFBasicHash 0x6a64170 [0x1751b38]>{type = mutable dict, count = 3,
entries =>
2 : <CFString 0x6a64410 [0x1751b38]>{contents = "type"} = <CFString 0x6a645f0 [0x1751b38]>{contents = "OAuthException"}
3 : <CFString 0x6a64590 [0x1751b38]>{contents = "message"} = <CFString 0x6a644f0 [0x1751b38]>{contents = "(#1705) : You cannot make blank posts. Please enter some text and try again."}
6 : <CFString 0x6a64200 [0x1751b38]>{contents = "code"} = 1705
}
}
i have accessed following permissions:
[fbGraph authenticateUserWithCallbackObject:self andSelector:#selector(fbGraphCallback)
andExtendedPermissions:#"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins,read_stream"];
Please do help.Thanks!!