我目前有一个使用D3的网站,我希望用户可以选择将SVG保存为SVG文件.我正在使用crowbar.js来做这件事,但它只适用于chrome.safari没有任何反应,IE click()
在crowbar.js中使用的方法提供了访问权限,无法下载文件.
var e = document.createElement('script');
if (window.location.protocol === 'https:') {
e.setAttribute('src', 'https://raw.github.com/NYTimes/svg-crowbar/gh-pages/svg-crowbar.js');
} else {
e.setAttribute('src', 'http://nytimes.github.com/svg-crowbar/svg-crowbar.js');
}
e.setAttribute('class', 'svg-crowbar');
document.body.appendChild(e);
Run Code Online (Sandbox Code Playgroud)
如何在safari,IE和chrome中基于我网站上的SVG元素下载SVG文件?
我有一个有角度的2 webpack项目,我目前有一些功能在几个组件中重复.我想从"master"类OR组件(无论哪种方法)继承所有这些组件,以便能够从我需要它们的所有组件中调用我的函数.
例如,如果我在3个不同的组件中有一个函数foo:
foo(s: string){
console.log(s);
}
Run Code Online (Sandbox Code Playgroud)
我希望您将此函数移动到另一个文件/类/组件:
class parent{
foo(s: string){
console.log(s);
}
}
Run Code Online (Sandbox Code Playgroud)
并且从某个给定的组件调用我的foo函数.例如:
class child{
constructor(){
foo("Hello");
}
}
Run Code Online (Sandbox Code Playgroud)
我如何使用Angular 2/Typescript做到这一点?
我正在尝试在特定字段上创建条件所需的验证.我尝试通过在我的函数中返回Validators.required来做到这一点,但这似乎不起作用.我该怎么做呢?这是我的代码:
private _ansat: AbstractControl = new FormControl('', Validators.required);
private _helbred: AbstractControl = new FormControl('', Validators.compose([this.useValidateIfRadio(this._ansat, 0, Validators.required)]) );
constructor(private _fb: FormBuilder) {
this.myForm = this._fb.group({
ansat: this._ansat,
helbred: this._helbred
});
}
useValidateIfRadio (c: AbstractControl, n: number, v) {
return function (control) {
return new Promise(resolve => {
// this.msg = ansatControl.value;
console.log(v);
if (c.value === n) {
resolve(v);
}
else {
resolve(null);
}
});
};
};
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏.
我正在尝试创建一种散点图形式.我有一个自定义的x轴和a轴的特定比例.我也为它实现了缩放功能.到目前为止一切都很好,但是当我最终尝试将数据绘制为圆圈时,我得到两个错误:
.
我的图表可以在这个网站上查看:http://servers.binf.ku.dk/hemaexplorerbeta/ (圈子很大,因为我想确保在我设计它们之前大致知道它们的位置)
我根据从MYSQL服务器读取的数据创建我的圈子.我检查了所有数据,数字是正确的.他们要么错误地绘图,要么我的刻度/缩放有问题.
您也可能会注意到我创建了我的轴并最初使用某些值进行缩放,并在之后的某些函数中更改它们.这是因为我计划在网站上加载一个空图表,用户可以决定加载它的数据集,其中函数必须自定义加载数据的比例和轴.
我在下面粘贴了我的源代码:
//Setting generic width and height values for our SVG.
var margin = {top: 60, right: 0, bottom: 70, left: 40},
genWidth = 1024;
genHeight = 768;
width = genWidth - 70 - margin.left - margin.right,
height = genHeight - 100 - margin.top - margin.bottom;
//Other variable declarations.
var valueY = 0;
var graphData = Array();
//Creating scales used to scale everything to the size of the SVG.
var xScale = …
Run Code Online (Sandbox Code Playgroud) 我有一个MVC项目,我希望用户能够通过单击按钮下载excel文件.我有文件的路径,我似乎无法通过谷歌找到我的答案.
我希望能够通过我的cshtml页面上的一个简单按钮来完成此操作:
<button>Button 1</button>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?任何帮助是极大的赞赏!
我在 SVG 框架中使用 D3 制作了一个图表。我想在其他地方的较小框架中显示此副本。
我使用以下方法收集了我的 SVG:
var svg = document.getElementById("mainSVG");
Run Code Online (Sandbox Code Playgroud)
或者
var svg_inner = document.getElementById("mainSVG").innerHTML;
Run Code Online (Sandbox Code Playgroud)
我想将“svg_inner”中的数据放入另一个 svg:
<svg id="svgMini" class"picMenu" viewBox="0 0 918 598">
</svg>
Run Code Online (Sandbox Code Playgroud)
或以某种方式更改“svg”的id并将其放入div或div或类似的东西中。
是否有可能做到这一点?我想要实现的是获取当前 SVG 的内容,并将其显示在其他地方。
我正在使用Bootstrap为我的网站创建一个下拉列表,但我遇到了一些问题.
在我的网站上,如果点击"选择人群",将出现弹出窗口(仅供参考:单击"提交"将显示其中的内容).当我点击它内部时,它总是关闭.我怎么能阻止它这样做?我只希望它在场外点击时关闭.
这是我使用的代码:
CSS:
@import url('http://getbootstrap.com/dist/css/bootstrap.css');
.dropdown-menu:before {
position: absolute;
top: -7px;
left: 9px;
display: inline-block;
border-right: 7px solid transparent;
border-bottom: 7px solid #ccc;
border-left: 7px solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.2);
content: '';
}
.dropdown-menu:after {
position: absolute;
top: -6px;
left: 10px;
display: inline-block;
border-right: 6px solid transparent;
border-bottom: 6px solid #ffffff;
border-left: 6px solid transparent;
content: '';
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="dropdown">
<button data-toggle="dropdown" id="submitButton" type="button" id="pops" >Select Populations</button>
<ul id="popupDropDown" class="dropdown-menu" role="menu" aria-labelledby="dLabel">
</ul>
</div>
Run Code Online (Sandbox Code Playgroud) 您好,我有一个带有以下 @input 的子组件:
@Input() inputEvents: EventEmitter<{ type: string, data: string | DateModel }>;
this.inputEvents.subscribe((e: any) => {
if (e.type === 'action') {
if (e.data === 'toggle') {
this.toggle();
}
if (e.data === 'close') {
this.close();
}
if (e.data === 'open') {
this.open();
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何触发父级的订阅?我在父组件中尝试了以下操作,但它不起作用:
@Output() datePickerAction: EventEmitter<{ type: string, data: string }>;
this.datePickerAction.next({ type: 'action', data: 'toggle' });
Run Code Online (Sandbox Code Playgroud) 我想在Android中有一个EditText,我有一个占位符,如果用户没有输入任何内容,它将用作我的输入.在我的案例中,编辑文本用于提示中.
我知道"提示"是一个占位符,但不会将其用作输入.如果我将提示设置为"AAA"并且用户没有输入任何内容并按"OK",我将得到一个空字符串,而不是"AAA".
这是我的代码:
private void promptForUsername(){
// get prompts.xml view
LayoutInflater layoutInflater = LayoutInflater.from(context);
View promptView = layoutInflater.inflate(R.layout.prompts, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
// set prompts.xml to be the layout file of the alertdialog builder
alertDialogBuilder.setView(promptView);
final EditText input = (EditText) promptView.findViewById(R.id.userInput);
//setup a dialog window
alertDialogBuilder
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// get user input and set it to result
addEvent(levelSelected, input.getText().toString(), Integer.parseInt(points), time + "s");
sqlLogic();
}
})
.setNegativeButton("Cancel",
new …
Run Code Online (Sandbox Code Playgroud) 我正在使用MVC,我有一个字符串列表,我想指向一个新页面.我正在使用Razor,我对MVC很新,似乎无法通过谷歌找到我的问题的答案.
我的清单可能包含以下内容:
"hello"
"goodbye"
"seeya"
Run Code Online (Sandbox Code Playgroud)
我知道如何使用ViewBag将控制器中的字符串插入到html页面,如果我有一组固定的字符串,我会使用以下actionlink:
@Html.ActionLink("viewedName", "ChemicalClass", new { mystring = "hello" })
@Html.ActionLink("viewedName", "ChemicalClass", new { mystring = "goodbye" })
@Html.ActionLink("viewedName", "ChemicalClass", new { mystring = "seeya" })
Run Code Online (Sandbox Code Playgroud)
据我了解,这将生成3个链接,重定向到子页面"ChemicalClass",它将包含3个参数之一,具体取决于被点击的链接.
我的问题是,我怎么能这样做,但动态创建了ActionLinks,因为我不知道要创建多少链接,也不知道字符串的内容.我的目标是在(最好是)列表表单中显示网页上的这些链接,例如:
<ol>
<li>
hello
</li>
<li>
goodbye
</li>
<li>
seeya
</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
列表中的每个元素都是链接而不仅仅是字符串.
javascript ×5
d3.js ×3
angular ×2
asp.net-mvc ×2
css ×2
jquery ×2
svg ×2
android ×1
angularjs ×1
button ×1
c# ×1
class ×1
download ×1
eventemitter ×1
formbuilder ×1
geometry ×1
html ×1
inheritance ×1
input ×1
nan ×1
placeholder ×1
razor ×1
typescript ×1
validation ×1