我使用D3.js渲染大约500个节点和它们之间的链接.通常需要10秒才能使布局稳定下来(迭代收敛).
如何加速整个过程,比如节点在动画过程中移动速度提高了2倍.然后时间将是50%(用于迭代的CPU时间应远小于10秒,但我如何减少动画时间).
我试过了:
有什么建议?谢谢.
我尝试在ajax调用后更改所选的ng-options索引,但不会更改.
//Html Section...
<select id="fooId" ng-model ="foo.formula"
ng-options="formulas as name for (formulas, name) in the_formula"></select>
//End Html Section...
//js file...
//get list of formula from server...
TheSource.Get.then(function(response){
$scope.the_formula = response.the_formula;
});
//do something awesome, then..
//binding data from server...
TheData.Get.then(function(response){
//binding the data to view...
//all of the element is binding, except the ng-options part..
$scope.foo = response;
//not working..
//$scope.formula = response.formulaId //it is return integer ID like (1, 2, 3, etc..)
});
// End js file...
Run Code Online (Sandbox Code Playgroud)
这是My API发送的数据. …
我创造了js小提琴:小提琴
我创建了一个包含一些ng-options的表单,当你使用按钮而不是鼠标时它会有奇怪的行为(只需单击文本框并按"tab",你就可以使用箭头键选择它).
<form ng-controller="MyApp" id="Apps" name="Apps" ng-submit="SendApp()" role="form" novalidate>
<input type="text" name="title" ng-model="Info.Title" />
<select id="Formula" ng-model ="Info.Genre" ng-change= "ChangeGenre()"
ng-options="id as name for (id, name) in Genre" blank></select>
<select class="form-control" ng-model ="Info.Program"
ng-options="Program as Name for (Program, Name) in Program" ng-change="ChangeProgram()" blank></select>
<h3>{{Info.Genre}}</h3>
<h3>{{Info.Program}}</h3>
<button type=submit>Submit this </button>
</form>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
var theApp = angular.module("TheApp", []);
theApp.controller("MyApp", ['$scope', function($scope){
$scope.Program = {"1":"Music","2":"Theater","3":"Comedy"};
$scope.Genre = {"1":"Mystery", "2":"Thriller", "3":"Romance"};
$scope.ChangeProgram = function(){
alert($scope.Info.Program + " " + $scope.Info.Genre);
}
$scope.ChangeGenre = …Run Code Online (Sandbox Code Playgroud) 我试图从Harvest反序列化数据,但它失败了(没有错误):https://github.com/harvesthq/api#api-json
返回的数据如下所示:
更新 (请参阅底部的完整JSON响应)
我运行下面代码时的输出是一个带有x个帖子的列表,其中每个帖子包含一个id = 0
是否有一个设置或我错过的东西让它忽略/解析周围的[]?
[DeserializeAs(Name = "project")]
public class Project
{
public int id { get; set; }
//public string name { get; set; }
//[DeserializeAs(Name = "created-at")]
//public DateTime CreatedAt { get; set; }
}
// The following is the methods to request for testing
public List<Project> GetProjects()
{
var request = new RestRequest("projects", Method.GET);
request.RequestFormat = DataFormat.Json;
return Execute<List<Project>>(request);
}
private T Execute<T>(RestRequest request) where T : new()
{
var client …Run Code Online (Sandbox Code Playgroud) 我对会话文档有点困惑,所以让我说我已经从客户端发送身份验证数据并检索ss-id和ss-pid,如下所示:
var client = new JsonServiceClient("http://somewhere/theAPI/");
var response = client.Post(new Auth() {UserName = "myuser", Password = "password123"});
var myCookie= client.CookieContainer.GetCookies(new Uri("http://somewhere/theAPI"));
Run Code Online (Sandbox Code Playgroud)
我如何从服务栈中检索姓氏,电子邮件等的AuthSession信息?我需要它存储在其他地方,如在memcache服务器,并从中检索?
或者我需要在客户端构建我的身份验证?并只是使用API来检索数据?
我是使用ninject和Dependency Injection的新手,并且在使用它时遇到了问题.
我尝试在我的类库中使用Ninject,并构建集成测试.现在,我在很多例子中看到,使用ninject只是指定了DI模块,如下所示:
Public Class DIModule : NinjectModule
public override void Load()
{
Bind<IUSAServices>().To<USAServices>();
}
Run Code Online (Sandbox Code Playgroud)
然后在我的测试类中,我尝试调用我的依赖是这样的:
[TestClass]
public class USAIntegrationTests
{
private readonly IUSAServices _usaService;
public USAIntegrationTests(IUSAServices usaServices)
{
_usaService = usaServices;
}
[TestMethod]
public void ValidateUserTests()
{
Assert.IsTrue(_usaService.ValidateUser("username1", "password1"));
}
}
Run Code Online (Sandbox Code Playgroud)
并得到此错误:
Unable to get default constructor for class USATests.IntegrationTests.USAIntegrationTests.
Run Code Online (Sandbox Code Playgroud)
但是,我阅读文档并尝试这样:
[TestClass]
public class USAIntegrationTests
{
private readonly IUSAServices _usaService;
public USAIntegrationTests()
{
using (IKernel kernel = new StandardKernel(new DIModule()))
{
_usaService = kernel.Get<IUSAServices>();
}
}
[TestMethod]
public void …Run Code Online (Sandbox Code Playgroud) 我尝试创建一个重载函数,返回void或字符串,如下所示:
public string Message { get; private set; }
public void Foo (Bar bar)
{
Message = "Hello World!";
}
public string Foo (Bar bar)
{
return "Hello World!";
}
Run Code Online (Sandbox Code Playgroud)
但我得Compile Time错误说:
Type 'Foo' already defines a member called with the same parameter types.
Run Code Online (Sandbox Code Playgroud)
有什么方法可以实现那种过载吗?
我有Web API需要将日志数据写入文件和数据库.是否可以配置这样的设置?我想了解ILoggerRepository,但我很困惑.有人可以给我一些关于如何配置它以及如何在应用程序中使用它的提示吗?
c# ×3
javascript ×3
angularjs ×2
jquery ×2
ng-options ×2
ajax ×1
asp.net-mvc ×1
c#-4.0 ×1
d3.js ×1
html ×1
json ×1
log4net ×1
ninject ×1
overloading ×1
restsharp ×1
servicestack ×1