糖粟与秋泊

文章 评论 浏览 27

糖粟与秋泊 2025-02-20 23:29:52

在我看来,您应该在neo4j浏览器中取消选中“连接结果节点”选项:

It seems to me that you should just uncheck the "Connect result nodes" option in the Neo4j Browser:

enter image description here

密码查询 - 排除某些关系

糖粟与秋泊 2025-02-20 23:25:31

为什么人们在不需要时总是使用jQuery?
人们为什么不能只使用简单的JavaScript?

var ele = /*Your Form Element*/;
if(ele.addEventListener){
    ele.addEventListener("submit", callback, false);  //Modern browsers
}else if(ele.attachEvent){
    ele.attachEvent('onsubmit', callback);            //Old IE
}

回调 是在提交表单时要调用的函数。

关于 eventTarget.AddeventListener ,查看

要取消本机提交事件(防止表格被提交),请使用 .preventdefault() 在您的回调功能中,

document.querySelector("#myForm").addEventListener("submit", function(e){
    if(!isValid){
        e.preventDefault();    //stop form from submitting
    }
});

收听提交带有库的事件,

如果由于某种原因决定了一个库(您已经在使用一个库,或者您不想处理跨浏览器问题)在普通库中收听提交事件的方法:

  1. jQuery

      $(ele).submit(呼叫);
     

    其中 ele 是表单元素参考, callback 是回调函数参考。 参考

    <iframe width="100%" height="100%" src="http://jsfiddle.net/DerekL/wnbo1hq0/show" frameborder="0"></iframe>

  1. angularjs(1.x)

     &lt; form ng-submit =“ callback()”&gt;
    
    $ scope.callback = function(){/*....*/};
     

    非常简单,其中 $ scope “ noreferrer”>控制器参考

  2. eack

     &lt; form onSubmit = {this.handlesubmit}&gt;
    
    类YourComponent扩展了组件{
        // 东西
    
        handlesubmit(event){
            //在这里做任何您需要的事情
    
            //如果您需要停止提交事件,并且 
            //执行/派遣您自己的动作
            event.preventDefault();
        }
    
        //更多东西
    }
     

    只需将处理程序传递到 onsubmit prop。 参考

  3. 其他框架/libraries

    请参阅您的框架文档。


验证

您可以随时在JavaScript中进行验证,但是使用HTML5,我们也具有本机验证。

<!-- Must be a 5 digit number -->
<input type="number" required pattern="\d{5}">

您甚至不需要任何JavaScript!每当不支持本机验证时,您都可以退缩到JavaScript验证器。

演示:

Why do people always use jQuery when it isn't necessary?
Why can't people just use simple JavaScript?

var ele = /*Your Form Element*/;
if(ele.addEventListener){
    ele.addEventListener("submit", callback, false);  //Modern browsers
}else if(ele.attachEvent){
    ele.attachEvent('onsubmit', callback);            //Old IE
}

callback is a function that you want to call when the form is being submitted.

About EventTarget.addEventListener, check out this documentation on MDN.

To cancel the native submit event (prevent the form from being submitted), use .preventDefault() in your callback function,

document.querySelector("#myForm").addEventListener("submit", function(e){
    if(!isValid){
        e.preventDefault();    //stop form from submitting
    }
});

Listening to the submit event with libraries

If for some reason that you've decided a library is necessary (you're already using one or you don't want to deal with cross-browser issues), here's a list of ways to listen to the submit event in common libraries:

  1. jQuery

    $(ele).submit(callback);
    

    Where ele is the form element reference, and callback being the callback function reference. Reference

    <iframe width="100%" height="100%" src="http://jsfiddle.net/DerekL/wnbo1hq0/show" frameborder="0"></iframe>

  1. AngularJS (1.x)

    <form ng-submit="callback()">
    
    $scope.callback = function(){ /*...*/ };
    

    Very straightforward, where $scope is the scope provided by the framework inside your controller. Reference

  2. React

    <form onSubmit={this.handleSubmit}>
    
    class YourComponent extends Component {
        // stuff
    
        handleSubmit(event) {
            // do whatever you need here
    
            // if you need to stop the submit event and 
            // perform/dispatch your own actions
            event.preventDefault();
        }
    
        // more stuff
    }
    

    Simply pass in a handler to the onSubmit prop. Reference

  3. Other frameworks/libraries

    Refer to the documentation of your framework.


Validation

You can always do your validation in JavaScript, but with HTML5 we also have native validation.

<!-- Must be a 5 digit number -->
<input type="number" required pattern="\d{5}">

You don't even need any JavaScript! Whenever native validation is not supported, you can fallback to a JavaScript validator.

Demo: http://jsfiddle.net/DerekL/L23wmo1L/

如何在JavaScript中收听表格提交事件?

糖粟与秋泊 2025-02-20 21:39:32

您应该能够缩短此代码或为您的需求进行自定义。解释您想要的事情很漫长。在这里是:

# Using JS to get all the child nodes from div element
nodes = driver.execute_script('return document.querySelector("div").childNodes')

# Iteration over `nodes` list which modifies nodes list to:
# (1) store text value for #text nodes found in Child nodes
# (2) remove value for #text nodes which are empty lines

for c, node in enumerate(nodes):
    if isinstance(node, dict):
        node = node['textContent'].strip()
        if node:
            nodes[c] = node
        else:
            nodes.pop(c)
    else:
        nodes[c] = node


# a list that would store index of valid #text nodes in `nodes` list
index_texts = []

for c, j in enumerate(nodes):
    if isinstance(j, str):
        index_texts.append(c)

# for convenience only
def node_type(o):
    if isinstance(o, str):
        return "String     :"
    else:
        return "Web_element:"

# this is to show you a replica of elements that you posted in your sample code, 
# but it is now available in a Python list for you.

print("##Print HTML child nodes replica as a Python list##\n")
for node in nodes:
    print(node_type(node), node)

print("------------")

# self-explanatory
print("##Print all elements between first two string/text element##\n")
for x in range(index_texts[0]+1, index_texts[1]):
    v = nodes[x]
    print(node_type(v), v)


print("------------")

# self-explanatory
print("##Print all elements after second string/text element##\n")
for m in range(index_texts[1]+1, len(nodes)):
    v = nodes[m]
    print(node_type(v), v)

输出:

##Print HTML child nodes replica as a Python list##

Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="b4ea1739-3f9c-4ff2-8750-8caf7b30aad5")>
String     : Bobby gave:
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="6f45369d-7c92-4cf3-ae64-1d70f8576708")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="4e73eda0-eae0-4915-b8a8-d846e93d5552")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="bf5a0f24-8772-468a-9a68-cdb183ba23bd")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="cb3eb86f-e53d-4089-8a2c-0deb96d0eff2")>
String     : and took
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="992b0798-9738-4b72-a706-56d8b74b0065")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="21fea20b-51fd-4926-bd5e-e78b781f2850")>
------------
##Print all elements between first two string/text element##

Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="6f45369d-7c92-4cf3-ae64-1d70f8576708")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="4e73eda0-eae0-4915-b8a8-d846e93d5552")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="bf5a0f24-8772-468a-9a68-cdb183ba23bd")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="cb3eb86f-e53d-4089-8a2c-0deb96d0eff2")>
------------
##Print all elements after second string/text element##

Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="992b0798-9738-4b72-a706-56d8b74b0065")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="21fea20b-51fd-4926-bd5e-e78b781f2850")>

现在。我给了你节点列表。如果您的要求有进一步的复杂性,假设您的HTML中有三个文本/字符串值,则需要IMG或第二个文本值之间的其他类型元素,那么您应该能够从该python列表中获取这些元素使用一点逻辑。

You should be able to shorten this code or customize it for your needs. It is lengthy to explain things you want. Here it is:

# Using JS to get all the child nodes from div element
nodes = driver.execute_script('return document.querySelector("div").childNodes')

# Iteration over `nodes` list which modifies nodes list to:
# (1) store text value for #text nodes found in Child nodes
# (2) remove value for #text nodes which are empty lines

for c, node in enumerate(nodes):
    if isinstance(node, dict):
        node = node['textContent'].strip()
        if node:
            nodes[c] = node
        else:
            nodes.pop(c)
    else:
        nodes[c] = node


# a list that would store index of valid #text nodes in `nodes` list
index_texts = []

for c, j in enumerate(nodes):
    if isinstance(j, str):
        index_texts.append(c)

# for convenience only
def node_type(o):
    if isinstance(o, str):
        return "String     :"
    else:
        return "Web_element:"

# this is to show you a replica of elements that you posted in your sample code, 
# but it is now available in a Python list for you.

print("##Print HTML child nodes replica as a Python list##\n")
for node in nodes:
    print(node_type(node), node)

print("------------")

# self-explanatory
print("##Print all elements between first two string/text element##\n")
for x in range(index_texts[0]+1, index_texts[1]):
    v = nodes[x]
    print(node_type(v), v)


print("------------")

# self-explanatory
print("##Print all elements after second string/text element##\n")
for m in range(index_texts[1]+1, len(nodes)):
    v = nodes[m]
    print(node_type(v), v)

Output:

##Print HTML child nodes replica as a Python list##

Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="b4ea1739-3f9c-4ff2-8750-8caf7b30aad5")>
String     : Bobby gave:
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="6f45369d-7c92-4cf3-ae64-1d70f8576708")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="4e73eda0-eae0-4915-b8a8-d846e93d5552")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="bf5a0f24-8772-468a-9a68-cdb183ba23bd")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="cb3eb86f-e53d-4089-8a2c-0deb96d0eff2")>
String     : and took
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="992b0798-9738-4b72-a706-56d8b74b0065")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="21fea20b-51fd-4926-bd5e-e78b781f2850")>
------------
##Print all elements between first two string/text element##

Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="6f45369d-7c92-4cf3-ae64-1d70f8576708")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="4e73eda0-eae0-4915-b8a8-d846e93d5552")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="bf5a0f24-8772-468a-9a68-cdb183ba23bd")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="cb3eb86f-e53d-4089-8a2c-0deb96d0eff2")>
------------
##Print all elements after second string/text element##

Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="992b0798-9738-4b72-a706-56d8b74b0065")>
Web_element: <selenium.webdriver.remote.webelement.WebElement (session="db7d464bace423bc697cebd182a51f4d", element="21fea20b-51fd-4926-bd5e-e78b781f2850")>

Now. I gave you nodes list. If you have further complexity in your requirements, let's say you have three text/string values in your HTML and you want IMG or some other type elements between second and third text values, then you should be able to get those elements from that Python list using a little bit of logic.

硒:在Webelement中的特定文本之后获取所有元素

糖粟与秋泊 2025-02-20 12:55:37

只需循环:

while True:
    my_function()
    time.sleep(50)

Just put it in a loop:

while True:
    my_function()
    time.sleep(50)

如何在每分钟的第秒钟执行功能?

糖粟与秋泊 2025-02-20 09:31:03

而不是:

import useState from "react";

写:

import { useState } from "react";

为什么我需要将 {} 添加到 import

答案:在使用 在用默认>默认关键字导出的内容上使用 - 您无需将变量名称包装在>中{}

但是,当在导出 的东西上使用 import 不是 作为默认时,您需要包装变量名称使用 {} ,并准确地说出您要 import

Instead of:

import useState from "react";

Write:

import { useState } from "react";

Why do I need to add { } to the import?

Answer: When using import on something that was exported with the default keyword - you don't need to wrap the variable name in { }.

However, when using import on something that was exported not as default, you are required to wrap the variable name with { } and say exactly what you want to import.

为什么usestate()在react js中不起作用?

糖粟与秋泊 2025-02-20 08:13:12

代替 StringListParameter.fromstringListParamEtername ,创建 cfnParameter 构造。将参数名称作为默认值传递:

const listParam = new cdk.CfnParameter(this, 'ListParam', {
  type: 'AWS::SSM::Parameter::Value<List<String>>',
  default: '/dev/name',
});

然后在将值传递为Prop输入时选择一个元素:

slackWorkspaceId: cdk.Fn.select(0, listParam.valueAsList),
slackChannelId: cdk.Fn.select(1, listParam.valueAsList),

正在发生什么? href =“ https://docs.aws.amazon.com/awscloudformation/latest/userguide/dynamic-references.html#dynamic-references-references-references-ssm” {{resolve:ssm:/dev/name}} 。正如您发现的那样,云形式显然不能将拆分应用于动态参考。

Instead of StringListParameter.fromStringListParameterName, create a CfnParameter construct. Pass the parameter name as the default value:

const listParam = new cdk.CfnParameter(this, 'ListParam', {
  type: 'AWS::SSM::Parameter::Value<List<String>>',
  default: '/dev/name',
});

Then select an element when passing the value as prop inputs:

slackWorkspaceId: cdk.Fn.select(0, listParam.valueAsList),
slackChannelId: cdk.Fn.select(1, listParam.valueAsList),

What's going on? fromStringListParameterName synthesises to a CloudFormation dynamic reference like {{resolve:ssm:/dev/name}}. And as you discovered, CloudFormation apparently cannot apply a split to dynamic references.

如何在CDK中提取字符串列表的参数?

糖粟与秋泊 2025-02-20 00:48:39

我们可以在 MAP 中循环循环行序列,并应用该功能,在开始时附加NAS以使长度正确

library(dplyr)
library(rdist)
library(purrr)
input_labs %>%
   mutate(dist_prior = c(NA_real_, NA_real_,
    map_dbl(3:n(), ~ cdist(cur_data()[.x,], cur_data()[.x-2, ]))))

- 输出

# A tibble: 10 × 10
   sodium chloride potassium_plas co2_totl   bun creatinine calcium glucose anion_gap dist_prior
    <dbl>    <dbl>          <dbl>    <dbl> <dbl>      <dbl>   <dbl>   <dbl>     <dbl>      <dbl>
 1   140      103            3.4      31    11        0.84     9.3    102       6          NA   
 2   153.     149.           0.34      3.1   1.1      0.084    0.93    10.2     0.600      NA   
 3   138      104            4.1      22     5        0.53     9.8     99      12          13.0 
 4   152.     149            0.41      2.2   0.5      0.053    0.98     9.9     1.20        1.30
 5   140      102            3.7      23     8        0.69     9.4    115      15          16.8 
 6   153.     149.           0.37      2.3   0.8      0.069    0.94    11.5     1.50        1.68
 7   141      103            4        27    21        1.04     9.4     94      11          25.4 
 8   153.     149.           0.4       2.7   2.1      0.104    0.94     9.4     1.10        2.54
 9   141      104            3.7      20    10        1.86     9.1    122      17          31.5 
10   153.     149            0.37      2     1        0.186    0.91    12.2     1.70        3.15

或可以在原始数据上通过行分开,而 lag lag lag < /code>一个并使用 map2 以循环循环并应用

input_labs$dist_prior <- map2_dbl(
         asplit(lag(input_labs, n = 2), 1),
          asplit(input_labs, 1), 
         ~ cdist(as.data.frame.list(.x), as.data.frame.list(.y))[,1])

We could loop over the sequence of rows in map and apply the function, append NAs at the beginning to make the length correct

library(dplyr)
library(rdist)
library(purrr)
input_labs %>%
   mutate(dist_prior = c(NA_real_, NA_real_,
    map_dbl(3:n(), ~ cdist(cur_data()[.x,], cur_data()[.x-2, ]))))

-output

# A tibble: 10 × 10
   sodium chloride potassium_plas co2_totl   bun creatinine calcium glucose anion_gap dist_prior
    <dbl>    <dbl>          <dbl>    <dbl> <dbl>      <dbl>   <dbl>   <dbl>     <dbl>      <dbl>
 1   140      103            3.4      31    11        0.84     9.3    102       6          NA   
 2   153.     149.           0.34      3.1   1.1      0.084    0.93    10.2     0.600      NA   
 3   138      104            4.1      22     5        0.53     9.8     99      12          13.0 
 4   152.     149            0.41      2.2   0.5      0.053    0.98     9.9     1.20        1.30
 5   140      102            3.7      23     8        0.69     9.4    115      15          16.8 
 6   153.     149.           0.37      2.3   0.8      0.069    0.94    11.5     1.50        1.68
 7   141      103            4        27    21        1.04     9.4     94      11          25.4 
 8   153.     149.           0.4       2.7   2.1      0.104    0.94     9.4     1.10        2.54
 9   141      104            3.7      20    10        1.86     9.1    122      17          31.5 
10   153.     149            0.37      2     1        0.186    0.91    12.2     1.70        3.15

Or may split by row on the original data and the laged one and use map2 to loop over the list and apply

input_labs$dist_prior <- map2_dbl(
         asplit(lag(input_labs, n = 2), 1),
          asplit(input_labs, 1), 
         ~ cdist(as.data.frame.list(.x), as.data.frame.list(.y))[,1])

在r中找到一排的距离和上方的第2行之间的距离

糖粟与秋泊 2025-02-18 21:04:26

几乎,您只是缺少document.getElementsByClassName的索引。这返回一系列匹配项目。因为您只有一个,所以您只能在阵列中获得第一个问题。

因此,您需要更改的只是:

document.getElementsByClassName to document.getElementsByClassName [0]

,您很高兴!

let header = document.getElementsByClassName('header')[0];
let switcher = document.querySelector('#switch');

switcher.addEventListener('click',function(){
    if(this.checked){
        header.classList.add('light');
    }
    else{
     header.classList.remove('light');
     }
})
<div class="header ">
            <div class="title-section">
                <h1>Social Media Dashboard</h1>
                <p>Total Followers: 23,004</p>
            </div>
            <div class="switchbtn">
                <label for="switch" id="switchlabel">Dark Mode</label>
                <input type="checkbox" name="switch" id="switch">
            </div>
</div>

Almost, you were just missing an index for document.getElementsByClassName. This returns an array of matching items. Because you've only got one you can just get the first in the array no problem.

So all you need to change is:

document.getElementsByClassName to document.getElementsByClassName[0]

and you're good to go!

let header = document.getElementsByClassName('header')[0];
let switcher = document.querySelector('#switch');

switcher.addEventListener('click',function(){
    if(this.checked){
        header.classList.add('light');
    }
    else{
     header.classList.remove('light');
     }
})
<div class="header ">
            <div class="title-section">
                <h1>Social Media Dashboard</h1>
                <p>Total Followers: 23,004</p>
            </div>
            <div class="switchbtn">
                <label for="switch" id="switchlabel">Dark Mode</label>
                <input type="checkbox" name="switch" id="switch">
            </div>
</div>

在Javacript中检查复选框时需要添加类

糖粟与秋泊 2025-02-18 19:21:55

您正在使用两个不同的身份。只有一个身份将获取域列表。您正在使用服务帐户进行身份验证。这些域已注册为用户的身份。由于服务帐户没有注册域,因此列表为空。

解决方案是使用用户的身份授权此API调用。这意味着使用 google oauth 2.0

邮政局长工具api api atapi state:

所有向邮政局邮政局工具API的请求必须由
身份验证的用户。

用OAuth 2.0授权请求

You are using two different identities. Only one of the identities will fetch the list of domains. You are authenticating with a service account. The domains are registered to a user's identity. Since the service account does not have a registered domain, the list is empty.

The solution is to use a user's identity to authorize this API call. That means using Google OAuth 2.0

The Postmaster Tools API states:

All requests to the Postmaster Tools API must be authorized by an
authenticated user.

Authorizing requests with OAuth 2.0

为什么Google Cloud Postmaster API返回一个空数组?

糖粟与秋泊 2025-02-18 12:44:50

我接受了这个解决方案,非常感谢您...

[M 3-Period Rolling Avg] =
// Set the number of periods to calculate
// the average over.
var PeriodCount = 3
// First, get the last visible period.
var LastPeriodSeqno = MAX( Dim_Date[PeriodSeqno] )
// Then, get the periods over which to calc.
var PeriodsToAverageOver =
    CALCULATETABLE(
        DISTINCT( Dim_Date[PeriodSeqno] ),
        // Here's the place where you use the fact that
        // all the periods are consecutively numbered.
        // In fact, the counting does not have to start
        // at 1 but it has to increment by 1.
        Dim_Date[PeriodSeqno] <= LastPeriodSeqno,
        Dim_Date[PeriodSeqno] > LastPeriodSeqno - PeriodCount,
        REMOVEFILTERS( Dim_Date )
    )
// We need to make sure that there are indeed
// PeriodCount periods in the set. Otherwise,
// the average will not be correct. This could happen
// if we were too close to the beginning of the calendar.
var ShouldCalculate =
    COUNTROWS( PeriodsToAverageOver ) = PeriodCount
var Result =
    if( ShouldCalculate,
        CALCULATE(
            AVERAGEX(
                PeriodsToAverageOver,
                [M]
            ),
            REMOVEFILTERS( Dim_Date )
        )
    )
return
    Result

I accepted this solution thank you very much ...

[M 3-Period Rolling Avg] =
// Set the number of periods to calculate
// the average over.
var PeriodCount = 3
// First, get the last visible period.
var LastPeriodSeqno = MAX( Dim_Date[PeriodSeqno] )
// Then, get the periods over which to calc.
var PeriodsToAverageOver =
    CALCULATETABLE(
        DISTINCT( Dim_Date[PeriodSeqno] ),
        // Here's the place where you use the fact that
        // all the periods are consecutively numbered.
        // In fact, the counting does not have to start
        // at 1 but it has to increment by 1.
        Dim_Date[PeriodSeqno] <= LastPeriodSeqno,
        Dim_Date[PeriodSeqno] > LastPeriodSeqno - PeriodCount,
        REMOVEFILTERS( Dim_Date )
    )
// We need to make sure that there are indeed
// PeriodCount periods in the set. Otherwise,
// the average will not be correct. This could happen
// if we were too close to the beginning of the calendar.
var ShouldCalculate =
    COUNTROWS( PeriodsToAverageOver ) = PeriodCount
var Result =
    if( ShouldCalculate,
        CALCULATE(
            AVERAGEX(
                PeriodsToAverageOver,
                [M]
            ),
            REMOVEFILTERS( Dim_Date )
        )
    )
return
    Result

电源BI DAX以计算3个时期的平均值

糖粟与秋泊 2025-02-18 04:47:13

您需要传递,然后可以使用home.js文件中的props.name访问它。

You need to pass in and then you can access it using props.name in Home.js file also pass props in Home.js function.

反应,无法在上下文中消耗价值,获得undurefther typeError:无法读取未定义的属性

糖粟与秋泊 2025-02-18 01:50:16

只需

date <- c(.25,.5,.75,1,1.25,1.5,1.75,2)

quarter <- (date-floor(date))/.25
quarter <- ifelse(quarter == 0, 4, quarter)
quarter
[1] 1 2 3 4 1 2 3 4

使用(date-floor(date))您只保留数字的小数位置。然后,您按 .25 分开以查看它是什么四分之一。最后将零替换为四个。

编辑

我看到我的答案与其他答案具有相同的逻辑。无论如何,我都保留它,因为解释可能会有所帮助。

Just do

date <- c(.25,.5,.75,1,1.25,1.5,1.75,2)

quarter <- (date-floor(date))/.25
quarter <- ifelse(quarter == 0, 4, quarter)
quarter
[1] 1 2 3 4 1 2 3 4

With (date-floor(date)) you keep just the decimal places of the number. Then you divide by .25 to see what quarter it is. And finally replacing zero by four.

EDIT

I see my answer has same logic as the other one. I keep it anyway because the explanation might help.

如何将日期季度分配给整数值

糖粟与秋泊 2025-02-17 18:35:19

您的着色器绑定正确吗?我遇到了同样的问题,但是在绑定它时它是解决的。 GluSeprogram(程序);

Is your shader binding correctly? I had the same problem but it was resolve when binding it. glUseProgram(program);

OpenGL错误:设置制服时1282

糖粟与秋泊 2025-02-17 08:24:54

我遇到了同一问题。老实说,在阅读了Chart.js文档后,我只是停止尝试将 DateTime 对象直接馈送到燃料图中。根据Chart.js文档,必须将其转换为“燃烧”的某个地方,因为无论如何,日期都被送入图表。因此,我将我的 dateTime [] 转换为 String [] 带有 datetime statem staters “ o” (o格式指定器De-de Culture 2008-10-31T17:04:32.0000000),一切都很好。

此外,首先尝试 time ,而不是 limeseries 作为x刻度类型。类型 limeseries 在非均等数据上表现出奇怪的行为。

我的 linechartoptions

public static LineChartOptions CreateLineChartOptions()
    {
        return new LineChartOptions()
        {
            Scales = new ChartScales()
            {
                X = new ChartAxis()
                {
                    Type = "time",
                    Time = new ChartAxisTime()
                    {
                        Unit = "minute",
                        MinUnit = "minute"
                    }
                }
            }
        };
    }

我的标签像您一样错误地格式化;我仍在努力。

我的剃须刀调用:

<LineChart @ref="lineChart" TItem="double" Options="@LineChartOptions" />

最少的示例,您甚至可以留下 ChartAxistime()对象。它应该在没有它的情况下运行。

我的最小结果:

“在此处输入图像说明”

I ran into the same issue. Honestly, after reading the Chart.js documentation, I just stopped trying to feed DateTime objects directly into the blazorise chart. According to the Chart.js documentation, it must be converted somewhere in blazorise, because the dates are fed into Chart.js as strings anyway. So I converted my DateTime[] to a string[] with DateTime pattern "O" (o Format Specifier de-DE Culture 2008-10-31T17:04:32.0000000) and everything went fine.

Furthermore, try time first instead of timeseries as the x scale type. Type timeseries behaves strangely on non-equidistant data.

My LineChartOptions:

public static LineChartOptions CreateLineChartOptions()
    {
        return new LineChartOptions()
        {
            Scales = new ChartScales()
            {
                X = new ChartAxis()
                {
                    Type = "time",
                    Time = new ChartAxisTime()
                    {
                        Unit = "minute",
                        MinUnit = "minute"
                    }
                }
            }
        };
    }

My labels are wrongly formatted like yours; I'm still working on that.

My Razor Call:

<LineChart @ref="lineChart" TItem="double" Options="@LineChartOptions" />

For a minimum example, you can even leave the ChartAxisTime() object. It should run without it.

My minimal result:

enter image description here

带有时间剧数据的燃料图表

糖粟与秋泊 2025-02-17 04:25:29

对于 python&gt; = 3.10 attributeError 的实例具有 name obj obj attribute:

>>> try:
...     'spam'.ham
... except AttributeError as e:
...     print(f'{e.name=}; {e.obj=}')
... 
e.name='ham'; e.obj=spam

但是< /strong>如果您手动提高attributeError ,则其 name obj 将为 none


以防万一您要提高 attributeError 自己,您可以设置 name obj 手动,例如

class Readonly:
    def __setattr__(self, name, _=None):
        e = AttributeError(f'{type(self).__name__} instance is readonly')
        try:
            e.name, e.obj = name, self
            raise e from None
        finally:
            del e

    __delattr__ = __setattr__

For python >= 3.10, instances of AttributeError have a name and obj attribute:

>>> try:
...     'spam'.ham
... except AttributeError as e:
...     print(f'{e.name=}; {e.obj=}')
... 
e.name='ham'; e.obj=spam

But if you manually raise AttributeError, its name and obj will be None


In case you want to raise an AttributeError yourself, you can set the name and obj manually, e.g.

class Readonly:
    def __setattr__(self, name, _=None):
        e = AttributeError(f'{type(self).__name__} instance is readonly')
        try:
            e.name, e.obj = name, self
            raise e from None
        finally:
            del e

    __delattr__ = __setattr__

如何从AttributeError Python提取属性名称

更多

推荐作者

眼泪淡了忧伤

文章 0 评论 0

corot39

文章 0 评论 0

守护在此方

文章 0 评论 0

github_3h15MP3i7

文章 0 评论 0

相思故

文章 0 评论 0

滥情空心

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文