我试图将我的谷歌图表居中对齐,但这样做并不成功.我玩过填充物将它移动到中心,但我不想坐在那里和火虫一起玩很长时间并找出正确的位置.是否有更简单的方法,如对齐文本text-align: center
.显然它不适用于谷歌图表.(我是所有这一切的新手)
var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
...some code ...
<div id='chart_div' style='width: 900px; height: 400px;'></div>
Run Code Online (Sandbox Code Playgroud)
虽然我这样做padding-left: 140px
但是有更好的方法align: center
我有一个函数使用Linq从数据库中获取数据,然后我在另一个函数中调用该函数,在每个单独的属性上使用.Sum对所有单个属性求和.我想知道是否有一种有效的方法可以立即对所有属性求和,而不是在每个属性上调用.Sum().我认为我现在正在做的方式非常缓慢(虽然未经测试).
public OminitureStats GetAvgOmnitureData(int? fnsId, int dateRange)
{
IQueryable<OminitureStats> query = GetOmnitureDataAsQueryable(fnsId, dateRange);
int pageViews = query.Sum(q => q.PageViews);
int monthlyUniqueVisitors = query.Sum(q => q.MonthlyUniqueVisitors);
int visits = query.Sum(q => q.Visits);
double pagesPerVisit = (double)query.Sum(q => q.PagesPerVisit);
double bounceRate = (double)query.Sum(q => q.BounceRate);
return new OminitureStats(pageViews, monthlyUniqueVisitors, visits, bounceRate, pagesPerVisit);
}
Run Code Online (Sandbox Code Playgroud)
编辑
private IQueryable<OminitureStats> GetOmnitureDataAsQueryable(int? fnsId, int dateRange)
{
var yesterday = DateTime.Today.AddDays(-1);
var nDays = yesterday.AddDays(-dateRange);
if (fnsId.HasValue)
{
IQueryable<OminitureStats> query = from o in lhDB.omniture_stats
where o.fns_id == …
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我使用两个库来处理两种不同类型的推送通知:Localytics 和 react-native-push-notification。
我有一个自定义 FirebaseMessagingService 来检查它是否是 Localytics 推送,然后让 Localytics 通过他们提供的方法处理它。但如果它不是 Localytics 推送,我需要将此推送数据传递给 react-native-push-notification 的 RNPushNotificationListenerService,它也是一个 FirebaseMessagingService。
我正在尝试启动 RNPushNotificationListenerService 但它似乎没有启动,因为它从不发送推送。我也试过设置断点,但没有运气。
AndroidManifest.xml
<!-- push notifications -->
<service android:name=".fcm.CustomFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- push notifications end -->
Run Code Online (Sandbox Code Playgroud)
CustomFirebaseMessagingService.java
public class CustomFirebaseMessagingService extends FirebaseMessagingService {
public CustomFirebaseMessagingService() {
super();
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> data …
Run Code Online (Sandbox Code Playgroud) android firebase react-native firebase-cloud-messaging react-native-push-notification
我有两个类,一个继承自ostream
,另一个继承自streambuf
,这就是我使用它们的方式
int main () {
stampstream ss(8,10);
}
Run Code Online (Sandbox Code Playgroud)
Stampstream
stampstream::stampstream(int r, int c) : ostream(new stampbuf(r,c))
{
std::cout << "I am in stampstream" << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
我只是调用父(ostream)类ctor并在参数中创建一个stampbuf类的对象.
Stampbuf
stampbuf::stampbuf(int r, int c)
: _row(0), _column(0), BUFFER_SIZE(10), _buffer(new char[BUFFER_SIZE])
{ //some code }
Run Code Online (Sandbox Code Playgroud)
所以当我在我的项目上运行Valgrind时,它说我有106字节的内存泄漏.其中96个来自new stampbuf(r,c)
,10个来自_buffer(new char[BUFFER_SIZE])
我有stampbuf它调用析构函数delete
在_buffer
释放内存.然而,析构函数永远不会被调用.如何摆脱这个内存泄漏并调用析构函数来设置stampbuf?
编辑
class stampstream : public ostream {
public:
stampstream(int r, int c);
virtual ~stampstream();
};
class stampbuf : public streambuf {
public:
stampbuf(int …
Run Code Online (Sandbox Code Playgroud) android ×1
c# ×1
c++ ×1
css ×1
firebase ×1
html ×1
iqueryable ×1
linq ×1
memory-leaks ×1
positioning ×1
react-native ×1