羁绊已千年

文章 评论 浏览 26

羁绊已千年 2025-02-17 16:46:22

第113行是

v_html_msg :=
              v_html_msg
           || '<tr align="left"><td>'
           ...

声明变量的,

v_html_msg             VARCHAR2(32672)

这意味着 - 当您在循环中处理数据时,其长度超过了32672个字符的长度。

该怎么办?改用 clob ,或检查是否真的有很多数据(即光标返回的行比您预期的更多 - 检查其 select 语句)。

Line 113 is

v_html_msg :=
              v_html_msg
           || '<tr align="left"><td>'
           ...

That variable is declared as

v_html_msg             VARCHAR2(32672)

which means that - as you're processing data in a loop - its length exceeds 32672 characters in length.

What to do? Use CLOB instead, or check whether there's really that much data (i.e. maybe cursor returned more rows than you'd expect - check its SELECT statement).

varchar2的替代?

羁绊已千年 2025-02-17 11:19:49

它显示了例外。
您能分享这个例外吗?如下所述,图像显示在图像中。

It shows exception.
Can you please share this exception. Thats is display in image as i mentioned below.

当我尝试运行它时,我的Flutter应用不会出现在模拟器中

羁绊已千年 2025-02-17 05:46:40
library(tidyverse)
library(lubridate)

一些其他数据清洁

d %>% 
  janitor::clean_names() %>%  
  as_tibble() %>% 
  select(ind, cancer_date, everything()) %>%  
  mutate(across(2:6, ~ as.Date(.x))) %>% 
  gather(-c(ind, cancer_date), key = "inclusion_id", value = "inclusion_date") %>%  
  drop_na() %>%  
  mutate(diff = interval(cancer_date, inclusion_date) %>% 
           as.numeric('years'))

计算癌症日期和纳入日期之间的

# A tibble: 5 x 5
    ind cancer_date inclusion_id    inclusion_date  diff
  <dbl> <date>      <chr>           <date>         <dbl>
1     1 2004-11-01  inclusion_date0 2014-11-01     10.0 
2     2 2000-08-02  inclusion_date2 2016-01-18     15.5 
3     3 2011-01-14  inclusion_date2 2016-01-18      5.01
4     5 2009-01-02  inclusion_dat4  2018-12-11      9.94
5     4 2016-03-16  inclusion_date6 2020-07-11      4.32

时间差,以年度过滤给出

d %>%  
  filter(diff <= 10)

# A tibble: 4 x 5
    ind cancer_date inclusion_id    inclusion_date  diff
  <dbl> <date>      <chr>           <date>         <dbl>
1     1 2004-11-01  inclusion_date0 2014-11-01     10.0 
2     3 2011-01-14  inclusion_date2 2016-01-18      5.01
3     5 2009-01-02  inclusion_dat4  2018-12-11      9.94
4     4 2016-03-16  inclusion_date6 2020-07-11      4.32
library(tidyverse)
library(lubridate)

Some additional data cleaning

d %>% 
  janitor::clean_names() %>%  
  as_tibble() %>% 
  select(ind, cancer_date, everything()) %>%  
  mutate(across(2:6, ~ as.Date(.x))) %>% 
  gather(-c(ind, cancer_date), key = "inclusion_id", value = "inclusion_date") %>%  
  drop_na() %>%  
  mutate(diff = interval(cancer_date, inclusion_date) %>% 
           as.numeric('years'))

Time difference between cancer date and inclusion date is calculated, given in years

# A tibble: 5 x 5
    ind cancer_date inclusion_id    inclusion_date  diff
  <dbl> <date>      <chr>           <date>         <dbl>
1     1 2004-11-01  inclusion_date0 2014-11-01     10.0 
2     2 2000-08-02  inclusion_date2 2016-01-18     15.5 
3     3 2011-01-14  inclusion_date2 2016-01-18      5.01
4     5 2009-01-02  inclusion_dat4  2018-12-11      9.94
5     4 2016-03-16  inclusion_date6 2020-07-11      4.32

Filtering

d %>%  
  filter(diff <= 10)

# A tibble: 4 x 5
    ind cancer_date inclusion_id    inclusion_date  diff
  <dbl> <date>      <chr>           <date>         <dbl>
1     1 2004-11-01  inclusion_date0 2014-11-01     10.0 
2     3 2011-01-14  inclusion_date2 2016-01-18      5.01
3     5 2009-01-02  inclusion_dat4  2018-12-11      9.94
4     4 2016-03-16  inclusion_date6 2020-07-11      4.32

数据框中的子集以使行保持少于R中的给定日期

羁绊已千年 2025-02-17 00:11:05

如果您正在使用 jayway jsonpath 您可以使用过滤器操作员 in

$..[?('loks3123' in @.plans[*].plan.planId)].skuId

在这里尝试: https://jsonpath.herokuapp.com/


如果您正在使用 newtonsoft.json

$..[?(@.plans[*].plan.planId == 'loks3123')].skuId

在这里尝试:

If you are using Jayway JsonPath you can use filter operator in

$..[?('loks3123' in @.plans[*].plan.planId)].skuId

Try here : https://jsonpath.herokuapp.com/


If you are using Newtonsoft.json

$..[?(@.plans[*].plan.planId == 'loks3123')].skuId

Try here : https://dotnetfiddle.net/6n4vAd

JSONPATH:如何过滤嵌套数组?

羁绊已千年 2025-02-16 23:09:04

Simple

You need it when you call a templated function from inside a templated class:

LiveDemo

#include <iostream>
#include <string>

struct printable {
    std::string mystr = "Hello World";
    template <typename T>
    auto print() {
        if constexpr (std::same_as<T, std::string>) {
            std::cout << mystr << std::endl;
        }
    }
};


template <typename Printable>
struct entity {
    auto print(Printable& myprintable) {
        myprintable.template print<std::string>();
    }
};

int main() {

    entity<printable> e;
    printable p;

    e.print(p);
}

Will output

Hello World

from the templated print() function在可打印中。

Simple

You need it when you call a templated function from inside a templated class:

LiveDemo

#include <iostream>
#include <string>

struct printable {
    std::string mystr = "Hello World";
    template <typename T>
    auto print() {
        if constexpr (std::same_as<T, std::string>) {
            std::cout << mystr << std::endl;
        }
    }
};


template <typename Printable>
struct entity {
    auto print(Printable& myprintable) {
        myprintable.template print<std::string>();
    }
};

int main() {

    entity<printable> e;
    printable p;

    e.print(p);
}

Will output

Hello World

from the templated print() function in printable.

我必须在何处以及为什么要放置“模板”。和“ typename”关键字?

羁绊已千年 2025-02-16 17:11:03
useEffect(()=>{
        const email = user?.user?.email;
        const currentUser = {email:email};
        console.log(currentUser,'hfghfh')
        if(email){

            fetch(`http://localhost:5000/user/${currentUser.email}`,{
                method: 'PUT',
                headers: {
                    'content-type': 'application/json'
                },
                body:JSON.stringify(currentUser)
            })
            .then(res=>res.json())
            .then(data=>{
                console.log(data);
                const accessToken = data.token;
                localStorage.setItem('accessToken',accessToken);
                setToken(accessToken);
            })
        }
    },[user])

在我的前端代码中,我犯了一个错误。我正在通过并对准透彻的电子邮件,但没有提取电子邮件值。传递currentuser.email fetch( http:// localhost:5000/user/$ {currentuser.email} 我正在通过Currentuser

useEffect(()=>{
        const email = user?.user?.email;
        const currentUser = {email:email};
        console.log(currentUser,'hfghfh')
        if(email){

            fetch(`http://localhost:5000/user/${currentUser.email}`,{
                method: 'PUT',
                headers: {
                    'content-type': 'application/json'
                },
                body:JSON.stringify(currentUser)
            })
            .then(res=>res.json())
            .then(data=>{
                console.log(data);
                const accessToken = data.token;
                localStorage.setItem('accessToken',accessToken);
                setToken(accessToken);
            })
        }
    },[user])

In my frontend code I made a mistake. I am passing and object thorough email and didn't extract the email value. Insepect of passing currentUser.email fetch(http://localhost:5000/user/${currentUser.email} I was passing just currentUser.

Thanks everyone for helping me for this problem.

jwt.verify(token,process.env.access_token_secret,function(err,解码)未正确解码

羁绊已千年 2025-02-16 09:53:27

如果您始终期望如图所示,请完全格式化三个冲刺,则可以使用以下查询获得所有行的总和,而该行名为“ Tigers”,该行中最高的Sprint值正好为11。

=QUERY({A2:A,B2:B,ARRAYFORMULA(INT(SPLIT(REGEXREPLACE(C2:C,"[a-zA-Z ]",""),";")))},"select sum(Col2) where Col1='Tigers' and (Col3>=11 or Col4>=11 or Col5>=11) and not (Col3>=12 or Col4>=12 or Col5>=12) label sum(Col2) ''")

如果您期望这样冲刺的数量可能会更改(例如,一个具有“ Sprint 2; Sprint 3; Sprint 3; Sprint 11; Sprint 12”的单元格中的单元格,则此公式将起作用。

=QUERY({FILTER(A2:A,NOT(ISBLANK(C2:C))),FILTER(B2:B,NOT(ISBLANK(C2:C))),QUERY(TRANSPOSE(QUERY(TRANSPOSE(ARRAYFORMULA(IF(ISBLANK(C2:C),,INT(SPLIT(REGEXREPLACE(C2:C,"[a-zA-Z ]",""),";"))))),"select "®EXREPLACE(JOIN("",ARRAYFORMULA(IF(LEN(C2:C),"max(Col"&ROW(C2:C)-ROW(C2)+1&"), ",""))),"..\z",""))),"select Col2")},"select sum(Col2) where Col1='Tigers' and Col3=11 label sum(Col2) ''")

If you always expect to have exactly three sprints formatted as shown, you can use the following query to get the sum of all rows where the Squad Name is "Tigers" and the highest Sprint value in that row is exactly 11.

=QUERY({A2:A,B2:B,ARRAYFORMULA(INT(SPLIT(REGEXREPLACE(C2:C,"[a-zA-Z ]",""),";")))},"select sum(Col2) where Col1='Tigers' and (Col3>=11 or Col4>=11 or Col5>=11) and not (Col3>=12 or Col4>=12 or Col5>=12) label sum(Col2) ''")

If you expect that the number of sprints might change (for example, a cell in column C with the value "Sprint 2;Sprint 3;Sprint 11;Sprint 12") then this formula will work instead.

=QUERY({FILTER(A2:A,NOT(ISBLANK(C2:C))),FILTER(B2:B,NOT(ISBLANK(C2:C))),QUERY(TRANSPOSE(QUERY(TRANSPOSE(ARRAYFORMULA(IF(ISBLANK(C2:C),,INT(SPLIT(REGEXREPLACE(C2:C,"[a-zA-Z ]",""),";"))))),"select "®EXREPLACE(JOIN("",ARRAYFORMULA(IF(LEN(C2:C),"max(Col"&ROW(C2:C)-ROW(C2)+1&"), ",""))),"..\z",""))),"select Col2")},"select sum(Col2) where Col1='Tigers' and Col3=11 label sum(Col2) ''")

在单元格中获取最大的半分离值字符串

羁绊已千年 2025-02-16 02:50:19

以下评论的批处理文件可以用于此任务:

@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "DataFile=\\server\share\MyDataFile.txt"
set "VersionInfo="

rem The command line below for getting the version information works even for Windows XP.
for /F "tokens=2 delims=[]" %%G in ('ver') do for /F "tokens=2" %%H in ("%%G") do set "VersionInfo=%%H"
rem Do nothing if the command line above fails which is very unlikely.
if not defined VersionInfo goto EndBatch

rem Do not change the data file on containing already a line with
rem the name of this computer and identical version data. Date
rem and time are not updated in this case which should not matter.
if exist "%DataFile%" %SystemRoot%\System32\findstr.exe /I /R /X /C:"%COMPUTERNAME%;.*;%VersionInfo%" "%DataFile%" >nul && goto EndBatch

rem Get current date/time in the format yyyy-MM-dd;HH:mm:ss independent
rem on which country/region is configured for the current user account.
for /F "tokens=1-6 delims=/: " %%G in ('%SystemRoot%\System32\robocopy.exe "%SystemDrive%\|" . /NJH') do set "DateTime=%%I-%%H-%%G;%%J:%%K:%%L" & goto CheckFile

:CheckFile
rem Create the data file if not existing at all with the data of current computer.
if not exist "%DataFile%" goto AppendData

rem Create a copy of the data file in temporary files directory of the
rem current user with omitting the line of the current computer. Then
rem move the filtered data file back to original storage location. If
rem that process fails because of the data file is opened currently by
rem another process which denies read and/or write access on the data file,
rem then exit processing of the batch file without updating the data file.
rem There will be one more chance in the near future to update the data file.
(
    %SystemRoot%\System32\findstr.exe /B /I /L /V /C:"%COMPUTERNAME%;" "%DataFile%" >"%TEMP%\%~n0.tmp" 2>nul
    if not exist "%TEMP%\%~n0.tmp" goto EndBatch
    if exist "%TEMP%\%~n0.tmp" move /Y "%TEMP%\%~n0.tmp" "%DataFile%" >nul 2>nul
    if exist "%TEMP%\%~n0.tmp" del "%TEMP%\%~n0.tmp" & goto EndBatch
) 2>nul

:AppendData
rem Append the data of current computer to the data file and next sort the
rem data file to have the lines sorted by computer names in the data file.
setlocal EnableDelayedExpansion
(echo !COMPUTERNAME!;!DateTime!;!VersionInfo!>>"%DataFile%") 2>nul
endlocal
%SystemRoot%\System32\sort.exe "%DataFile%" /O "%DataFile%" 2>nul

:EndBatch
endlocal

注1:批处理文件可以同时由多台计算机运行,这仅导致一个批处理文件可以读取/写入访问数据文件而其他文件未能读/写数据文件。上面的批处理文件将其考虑在内,但没有100%失败。最好是在C或C ++中编码Windows控制台应用程序,该应用程序处理共享的文件访问拒绝,以等待短时文件被保护以读取和/或写入更长的时间。

注2:计算机名称可以包含一个半隆,如果将计算机名称写入数据文件,则需要将计算机名称包含在中,如果数据文件应为CSV 也应有效。

对于此特殊用例 href =“ https://stackoverflow.com/a/60126994/3074564”>时间在午夜之后不正确地设置以说明命令行以以特定格式获得当前日期/时间以确保所有人都确保所有 时间数据始终以国际日期/时间格式写入数据文件。

日期/ 打开命令键入的方法in-windows-10/“ rel =“ nofollow noreferrer”>命令提示符窗口,执行以下命令,并读取每个命令的显示的帮助页,完全和小心。

  • call/? ...说明%〜n0 ...参数0,即无文件扩展名的批处理文件名,没有路径
  • del/?
  • echo /?< /code>
  • endlocal /?< /code>
  • findstr /?
  • < /code> < /code> for /?
  • < /code > goto /?< /?代码>
  • <代码>如果 /?< /code>
  • 移动 /?
  • < /code> rem /?
  • < /code> robocopy /?< /code>
  • set /?< /code> < /code> < /?代码>
  • setLocal/?
  • sort/?
  • ver/?

另请参见:

  • 有关
  • ​https://stackoverflow.com/a/25344009/3074564"> single line line windows batch file 带有多个命令

The following commented batch file could be used for this task:

@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "DataFile=\\server\share\MyDataFile.txt"
set "VersionInfo="

rem The command line below for getting the version information works even for Windows XP.
for /F "tokens=2 delims=[]" %%G in ('ver') do for /F "tokens=2" %%H in ("%%G") do set "VersionInfo=%%H"
rem Do nothing if the command line above fails which is very unlikely.
if not defined VersionInfo goto EndBatch

rem Do not change the data file on containing already a line with
rem the name of this computer and identical version data. Date
rem and time are not updated in this case which should not matter.
if exist "%DataFile%" %SystemRoot%\System32\findstr.exe /I /R /X /C:"%COMPUTERNAME%;.*;%VersionInfo%" "%DataFile%" >nul && goto EndBatch

rem Get current date/time in the format yyyy-MM-dd;HH:mm:ss independent
rem on which country/region is configured for the current user account.
for /F "tokens=1-6 delims=/: " %%G in ('%SystemRoot%\System32\robocopy.exe "%SystemDrive%\|" . /NJH') do set "DateTime=%%I-%%H-%%G;%%J:%%K:%%L" & goto CheckFile

:CheckFile
rem Create the data file if not existing at all with the data of current computer.
if not exist "%DataFile%" goto AppendData

rem Create a copy of the data file in temporary files directory of the
rem current user with omitting the line of the current computer. Then
rem move the filtered data file back to original storage location. If
rem that process fails because of the data file is opened currently by
rem another process which denies read and/or write access on the data file,
rem then exit processing of the batch file without updating the data file.
rem There will be one more chance in the near future to update the data file.
(
    %SystemRoot%\System32\findstr.exe /B /I /L /V /C:"%COMPUTERNAME%;" "%DataFile%" >"%TEMP%\%~n0.tmp" 2>nul
    if not exist "%TEMP%\%~n0.tmp" goto EndBatch
    if exist "%TEMP%\%~n0.tmp" move /Y "%TEMP%\%~n0.tmp" "%DataFile%" >nul 2>nul
    if exist "%TEMP%\%~n0.tmp" del "%TEMP%\%~n0.tmp" & goto EndBatch
) 2>nul

:AppendData
rem Append the data of current computer to the data file and next sort the
rem data file to have the lines sorted by computer names in the data file.
setlocal EnableDelayedExpansion
(echo !COMPUTERNAME!;!DateTime!;!VersionInfo!>>"%DataFile%") 2>nul
endlocal
%SystemRoot%\System32\sort.exe "%DataFile%" /O "%DataFile%" 2>nul

:EndBatch
endlocal

Note 1: The batch file could be run by multiple computers exactly at the same time which results in only one batch file can read/write access the data file while the others fail to read/write the data file. The batch file above takes that into account, but not 100% fail safe. It would be better to code a Windows console application in C or C++ which handles shared file access denials with waiting a short time to give the other process the time to finish and with using a loop with a counter to avoid running in an endless loop on file being protected for read and/or write for a longer time.

Note 2: The computer name could contain a semicolon which would require enclosing the computer name in " on writing the computer name into the data file if the data file should be a CSV file which should be valid also for this special use case. The batch file above is not designed for correct handling computer names with a semicolon regarding to CSV specification, but it handles correct computer names with an ampersand in name.

Read my answer on Time is set incorrectly after midnight for an explanation of the command line to get current date/time in a specific format to make sure that all date/time data are written into the data file always in the international date/time format.

To understand the commands used and how they work, open a command prompt window, execute there the following commands, and read the displayed help pages for each command, entirely and carefully.

  • call /? ... explains %~n0 ... name of argument 0, i.e. batch file name without file extension and without path
  • del /?
  • echo /?
  • endlocal /?
  • findstr /?
  • for /?
  • goto /?
  • if /?
  • move /?
  • rem /?
  • robocopy /?
  • set /?
  • setlocal /?
  • sort /?
  • ver /?

See also:

如何避免在批处理文件创建的日志文件中重复?

羁绊已千年 2025-02-15 22:37:57

当您按值 s传递 std :: string s,就像在第二个示例中一样,每次都要复制它们。这需要时间(和内存),并解释了超出限制。您也可能无法超过内存限制。当您通过参考将它们传递时,您不会制作字符串的副本。而是引用已经存在的字符串。

When you pass std::strings by value, like you do in your second example, you copy them every time. That takes time (and memory) and explains the limit exceeded. You could also have failed on exceeding the memory limit. When you pass them by reference, you don't make a copy of the string. You instead reference the already existing string.

通过参考的字符串正常工作,而不是在LCS问题中

羁绊已千年 2025-02-15 21:12:50

这是一个lambda函数,此代码意味着这是返回字符串的lambda函数:

() -> String

此处是作为名为消息的参数传递:

fun sampleFun(message: ()-> String)

您需要添加消息参数:

sampleFun(
    message = {
        "Hello" // this means that when you call message it will return this String
    }
)

因此,当您调用示例娱乐时, link 如果想了解有关Kotlin中的Lambda功能的更多信息,

this is a lambda function, this code means that this is a lambda function that return a string:

() -> String

and here it's passed as a parameter named message:

fun sampleFun(message: ()-> String)

so when you call sample fun you need to add message parameter like that:

sampleFun(
    message = {
        "Hello" // this means that when you call message it will return this String
    }
)

take a look on this link if want to learn more about lambda functions in kotlin and how to use them correctly

Kotlin数据类型语法

羁绊已千年 2025-02-15 12:37:04

根据 sidstart ,是的, sizeof ace_header )+ size> size of access_mask )= 8byte。

According to ACCESS_DENIED_ACE structure, You can refer to SidStart directly And Yes, sizeof(ACE_HEADER)+sizeof(ACCESS_MASK)=8BYTE.

c#获取psid,sidstart access_allowed_ace的字符串sid

羁绊已千年 2025-02-15 07:48:36

具有自定义资源的机器类型可以具有此形式:“ E2-CUSTOM-10-24576”,以便您需要10VCPU和24GB RAM。

您可以在此文档中拥有更多详细信息:

A machine type with custom resources can have this form : "e2-custom-10-24576" for your requirement of 10vCPU and 24GB of RAM.

You can have more details in this documentation : https://cloud.google.com/compute/docs/general-purpose-machines#custom_machine_types

Anisble:如何使用自定义资源创建为GCP VM?

羁绊已千年 2025-02-14 23:49:56

找不到解决方案的原因是您有2个不同的接口,一个用于慢速访问,一个用于快速访问。他们可以共享相同的基础界面,这意味着它们本身可能是空的,但是两者都应该存在,因为它们解决了2个不同的问题。

此外,其中有两个允许您延长每个接口的需求,而无需触摸另一个接口。例如:您的快速接口需要返回扩展对象,最初不是预期的。您只需实施它,就完成了。 慢速接口保持不变,因为此特定功能或要求不适用于它。

另一方面,如果以后您的慢界面需要新的查询才能返回一些数据,则可以实现它,而不必担心如何在<<<<强>快速接口,仅仅是因为您没有它。

请记住:保持简单,每个类/接口的一个责任。您可以“减少”代码,共享共同零件(例如,定义基本接口),但是应该始终清楚您要解决哪些问题而不混合职责。

The reason you can't find a solution is that you have 2 different interfaces, one for slow access and one for fast access. They could share the same base interface, that means that the could be empty themselves, but both should exists because they solve 2 different problems.

Moreover, having 2 of them allows you to extend each one with exactly the needs that are going to arise for that interface, without touching the other one. For example: your fast interface is required to return an extended object, that initially wasn't expected. You simply implement it, and you're finish. The slow interface remains instead unchanged because this particular function, or requirement, doesn't apply to it.

On the other side, if later your slow interface requires a new query to return some data, you could implement it without having to worry about how you would implement it in the fast interface, simply because you don't have it.

Remember: keep it simple and one responsibility for each class/interface. You could 'reduce' the code, sharing the common parts (defining a base interface, for example), but it should always remain clear which problem you're going to solve without mixing the responsibilities.

如何处理同一服务的两个实现

羁绊已千年 2025-02-14 20:30:15

这个很棘手!
我知道Plotly没有任何内置的事情可以简单地做到这一点。我试图使用形状绘制此框进行锻炼,但这是行不通的,因为它将传奇放在顶部(因此大多数盒子都被隐藏了)。我显然比情节更固执。

此答案需要软件包 htmlwidgets 。我没有更改您的情节将其分配给对象。我为此答案命名了您的情节对象 pl

onRender 函数的内容:

or = ("function(el){
      costLeg = document.querySelectorAll('g.traces')[2];      /* third legend entry */
      cChW = costLeg.firstChild.getBoundingClientRect().width; /* text only */
      cR = costLeg.lastChild.getBoundingClientRect();          /*g trace space*/ 
      cR2 = costLeg.lastChild.outerHTML.split('\" ');
      cy = cR2[3].split('\"')[1];                              /* the y without padding*/
      cDf = cR.width - cChW - 14;                 /*legend width - text width - padding*/
      costLC = costLeg.lastChild.cloneNode(true); /* copy the current rect element */
      costLC.removeAttribute('pointer-events');   /* remove the pointer events */
      costLeg.removeAttribute('class');           /*stop refresh from changing it*/
      costLC.setAttribute('x', 3);                /* calc values + or minus padding */
      costLC.setAttribute('y', (cR.height - 6)/2 * -1); /* measure from center */
      costLC.setAttribute('width', cDf);
      costLC.setAttribute('height', cR.height - 6);
      costLC.setAttribute('style',
          'fill: rgb(0, 0, 0); fill-opacity: 0; stroke-width: 2px; stroke: black;');
      costLeg.insertBefore(costLC, costLeg.lastChild);
      }")

调用图块,然后添加 onRender 函数绘制框。

pL %>% htmlwidgets::onRender(or)

顺便说一句,这也应该随您的情节扩展。

This one was tricky!
I know that Plotly doesn't have anything built-in to do this simply. I tried to work out using shapes to draw this box, but that doesn't work, because it puts the legend on top (so most of the box is hidden). I'm apparently more stubborn than Plotly though.

This answer requires the package htmlwidgets. I didn't change your plot other an assigning it to an object. I named your Plotly object pL for this answer.

The content for the onRender function:

or = ("function(el){
      costLeg = document.querySelectorAll('g.traces')[2];      /* third legend entry */
      cChW = costLeg.firstChild.getBoundingClientRect().width; /* text only */
      cR = costLeg.lastChild.getBoundingClientRect();          /*g trace space*/ 
      cR2 = costLeg.lastChild.outerHTML.split('\" ');
      cy = cR2[3].split('\"')[1];                              /* the y without padding*/
      cDf = cR.width - cChW - 14;                 /*legend width - text width - padding*/
      costLC = costLeg.lastChild.cloneNode(true); /* copy the current rect element */
      costLC.removeAttribute('pointer-events');   /* remove the pointer events */
      costLeg.removeAttribute('class');           /*stop refresh from changing it*/
      costLC.setAttribute('x', 3);                /* calc values + or minus padding */
      costLC.setAttribute('y', (cR.height - 6)/2 * -1); /* measure from center */
      costLC.setAttribute('width', cDf);
      costLC.setAttribute('height', cR.height - 6);
      costLC.setAttribute('style',
          'fill: rgb(0, 0, 0); fill-opacity: 0; stroke-width: 2px; stroke: black;');
      costLeg.insertBefore(costLC, costLeg.lastChild);
      }")

Call the plot and add the onRender function to draw the box.

pL %>% htmlwidgets::onRender(or)

enter image description here

By the way, this should scale with your plot, as well.

R:如何在情节中修改传奇?

羁绊已千年 2025-02-14 16:40:19

您只需要在操作中添加 [来自Body] 并使用第一个Ajax,这是一个演示:

Action

[HttpPost]
        public IActionResult CreateProduct([FromBody]ProductViewModel productViewModel) 
        {
            return RedirectToAction("Index");
        }

Ajax:

function post() {
       /* var url = $("#CreateProductForm").attr("action");*/
        var data = $("#CreateProductForm").serialize();                
        var FoodsIDVal = [];
        $("select[name='FoodsID']").each(function () {
            var values = $(this).val();
            FoodsIDVal.push(values);
        });
        var ViewModel = {
            "MST":data,
            "FoodsID":FoodsIDVal
        };        
        console.log(ViewModel);
        $.ajax({
            type: "POST",
            url: "CreateProduct",
            data: JSON.stringify(ViewModel),
            dataType: "json",   
            contentType: 'application/json; charset=utf-8',
            success: function (response) {

            },
            error: function () {

            }
        });
    }

如果您仍然无法获得FoodSid,请尝试检查 foodsidval foodsidval < /代码>在Ajax中。

You only need to add [FromBody] to the action and use the first ajax,here is a demo:

action

[HttpPost]
        public IActionResult CreateProduct([FromBody]ProductViewModel productViewModel) 
        {
            return RedirectToAction("Index");
        }

ajax:

function post() {
       /* var url = $("#CreateProductForm").attr("action");*/
        var data = $("#CreateProductForm").serialize();                
        var FoodsIDVal = [];
        $("select[name='FoodsID']").each(function () {
            var values = $(this).val();
            FoodsIDVal.push(values);
        });
        var ViewModel = {
            "MST":data,
            "FoodsID":FoodsIDVal
        };        
        console.log(ViewModel);
        $.ajax({
            type: "POST",
            url: "CreateProduct",
            data: JSON.stringify(ViewModel),
            dataType: "json",   
            contentType: 'application/json; charset=utf-8',
            success: function (response) {

            },
            error: function () {

            }
        });
    }

If you still cannot get FoodsID,try to check the data of FoodsIDVal in ajax.

ajax帖子到.NET CORE MVC控制器可以获取正确的参数

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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