我正在使用CLLocationManager在swift 3中编写一个OSX应用程序,根据文档和我发现的所有示例应该没问题(这是一个类中的一个CLLocationManagerDelegate)
if CLLocationManager.locationServicesEnabled() {
let lm = CLLocationManager()
lm.requestWhenInUseAuthorization()
lm.delegate = self
lm.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
lm.startUpdatingLocation()
print("should start getting location data")
} else {
print("Location service disabled");
}
Run Code Online (Sandbox Code Playgroud)
但似乎requestWhenInUseAuthorization(和requestAlwaysAuthorization)似乎不适用于OSX.我目前有这些函数调用包裹在#if块中:
#if os(macOS)
// can't find way for MacOSX to request auth
#endif
#if os(watchOS) || os(tvOS)
lm.requestWhenInUseAuthorization()
#endif
#if os(iOS)
lm.requestAlwaysAuthorization()
#endif
Run Code Online (Sandbox Code Playgroud)
那么有谁知道如何在macOS桌面应用程序中使用它?
我一直在寻找各种方法来生成webapps中的图形,并发现HighCharts特别有用.该应用程序需要迎合色盲,所以我正在寻找使用模式而不是填充颜色 - 如本问题所述.
这样的东西需要<defs>在SVG 的部分:
<pattern id="triangles" width="10" height="10" patternUnits="userSpaceOnUse">
<polygon points="5,0 10,10 0,10"/>
</pattern>
<pattern id="diagonal-hatch" patternUnits="userSpaceOnUse" width="4" height="4">
<path d="M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2"/>
</pattern>
<pattern id="cross-hatch" patternUnits="userSpaceOnUse" x="0" y="0" width="6" height="6">
<g style="fill:none; stroke:#22fa23; stroke-width:1">
<path d="M0,0 l10,10"/>
<path d="M10,0 l-10,10"/>
</g>
</pattern>
Run Code Online (Sandbox Code Playgroud)
然后而不是fill="#0d233a"我fill="url(#triangles)"
还有其他人用HighCharts做过这件事吗?甚至可以让HighCharts这样做而不会将其破坏成碎片?
我使用过各种IDE(Eclipse,NetBeans,Intellij IDEA),尽管它们都有GUI构建工具,但它们都以一种将开发人员与使用该IDE联系起来的方式生成GUI.
我目前正在开发一个开源项目,其中GUI已经使用Netbeans构建,因此在另一个IDE中打开时它将无法工作.这对我没有好处,部分原因是因为我使用了Intellij IDEA,但主要是因为该项目正在设置用Maven构建.
从事物的外观来看,Netbeans似乎在项目构建时添加代码,因此当我通过subversion检查时会丢失一些东西.
我正在处理的Web应用程序有一个REST接口,它返回与此类似的对象数组:
[{"id":110, "time":1360580745797, "userName":"pinky", "activity":"respawn"},
{"id":111, "time":1360580745797, "userName":"perky", "activity":"change direction"},
{"id":112, "time":1360580745797, "userName":"clyde", "activity":"caught pacman"},
{"id":113, "time":1360580745797, "userName":"perky", "activity":"respawn"},
{"id":114, "time":1360580745797, "userName":"perky", "activity":"caught pacman"},
{"id":115, "time":1360580745797, "userName":"clyde", "activity":"respawn"}]
Run Code Online (Sandbox Code Playgroud)
我想使用这些数据来渲染一个线图,每个活动都有一条线,并显示每天活动的总和.不使用id,在此阶段不使用userName(但我希望稍后可能会在用户名上过滤结果).
我已经看过使用map reduce函数来对数据进行排序,但之后一直在尝试使用D3的嵌套功能.
我目前有一些看起来像这样的代码:
d3.json(url, function(error, json) {
if (error) return console.warn(error);
console.log(json);
d3.nest()
.key(function(d) { return d.activity; })
.key(function(d) {return d3.time.format('%x')(new Date(d.time));})
.entries(json);
};
Run Code Online (Sandbox Code Playgroud)
这会将我的json数据分组为按活动键入的对象数组,然后按日期键入.接下来我需要总结那天的活动量.
从这里虽然我不完全确定如何将我的数据转换为可以由d3线图使用的格式.