XE7 Firemonkey application get "argument out of range" - delphi-xe7

I'm making a multi-device application whit Rad Studio XE7.
Sometimes when i want save my last modify on a Form, Rad Studio raises an exception "Argument out of range" but don't give me any information on where is the problem.
Detail of error report this:
[067B425F]{fmx210.bpl }
FMX.Types.{System.Generics.Collections}TList.SetCapacity
(Line 737, "System.Generics.Collections.pas" + 1) + $1
[067B1703]{fmx210.bpl } FMX.Types.RegisterShortCuts (Line 7266,
"FMX.Types.pas" + 23) + $7 [067448C7]{fmx210.bpl }
FMX.Styles..TStyleReader (Line 351, "FMX.Styles.pas" + 0) + $132E
[067448D6]{fmx210.bpl } FMX.Styles.TStyleReader.SetName (Line 368,
"FMX.Styles.pas" + 0) + $2 [067449CE]{fmx210.bpl }
FMX.Styles.TStyleStreaming.SameStyle (Line 404, "FMX.Styles.pas" + 1)
+ $17 [067177F4]{fmx210.bpl } FMX.Controls.DoWrite (Line 5896, "FMX.Controls.pas" + 2) + $C [06717847]{fmx210.bpl }
FMX.Controls.TStyleBook.DefineProperties (Line 5902,
"FMX.Controls.pas" + 0) + $B [50161682]{rtl210.bpl }
System.Classes.TWriter.WriteProperties (Line 11571,
"System.Classes.pas" + 19) + $8 [50160EE9]{rtl210.bpl }
System.Classes.TWriter.WriteData (Line 11381, "System.Classes.pas" +
30) + $6 [5016C1F3]{rtl210.bpl } System.Classes.TComponent.WriteState
(Line 15547, "System.Classes.pas" + 0) + $3 [50160CBF]{rtl210.bpl }
System.Classes.TWriter.WriteComponent (Line 11333,
"System.Classes.pas" + 18) + $8 [067A8F01]{fmx210.bpl }
FMX.Types.TFmxObject.GetChildren (Line 4750, "FMX.Types.pas" + 7) +
$17 [06760403]{fmx210.bpl } FMX.Forms.TCommonCustomForm.Notification
(Line 3567, "FMX.Forms.pas" + 1) + $1 [5005F532]{rtl210.bpl }
System.#CallDynaInst (Line 16299, "System.pas" + 4) + $0
[50160FFA]{rtl210.bpl } System.Classes.TWriter.WriteData (Line 11403,
"System.Classes.pas" + 52) + $16 [5016C1F3]{rtl210.bpl }
System.Classes.TComponent.WriteState (Line 15547, "System.Classes.pas"
+ 0) + $3 [50160CBF]{rtl210.bpl } System.Classes.TWriter.WriteComponent (Line 11333,
"System.Classes.pas" + 18) + $8 [5016114E]{rtl210.bpl }
System.Classes.TWriter.WriteDescendent (Line 11431,
"System.Classes.pas" + 8) + $4 [211357A3]{designide210.bpl}
ComponentDesigner.WriteStream (Line 4184, "ComponentDesigner.pas" +
11) + $7 [21135870]{designide210.bpl}
ComponentDesigner.TComponentRoot.WriteRootStream (Line 4207,
"ComponentDesigner.pas" + 5) + $B [21132540]{designide210.bpl}
ComponentDesigner.TComponentRoot.GetRootStream (Line 2936,
"ComponentDesigner.pas" + 14) + $5 [211388F6]{designide210.bpl}
ComponentDesigner.TComponentRoot.Save (Line 5194,
"ComponentDesigner.pas" + 1) + $2 [211389BE]{designide210.bpl}
ComponentDesigner.TComponentRoot.Save (Line 5208,
"ComponentDesigner.pas" + 15) + $12 [21D7CF56]{delphicoreide210.bpl}
DelphiModule.TPascalCodeMgrModHandler.SaveFile (Line 1589,
"DelphiModule.pas" + 2) + $8 [206A6F84]{coreide210.bpl}
SourceModule.TCodeISourceModule.SaveFile (Line 1514,
"SourceModule.pas" + 2) + $22 [206A4604]{coreide210.bpl}
SourceModule.TSourceModule.SaveFile (Line 656, "SourceModule.pas" + 3)
+ $1F [2087C1AC]{coreide210.bpl} DocModul.TDocModule.TheMalteseFalcon (Line 1438, "DocModul.pas" + 60) + $2 [500F11ED]{rtl210.bpl }
System.Rtti.RawInvoke (Line 7090, "System.Rtti.pas" + 46) + $0
[500F15DF]{rtl210.bpl } System.Rtti.Invoke (Line 7289,
"System.Rtti.pas" + 57) + $6 [500E7BBA]{rtl210.bpl }
System.Rtti.TRttiInstanceMethodEx.DispatchInvoke (Line 5409,
"System.Rtti.pas" + 101) + $20 [500F1A74]{rtl210.bpl }
System.Rtti.TRttiMethod.Invoke (Line 7980, "System.Rtti.pas" + 1) +
$11 [2087BE24]{coreide210.bpl} DocModul.TDocModule.Save (Line 1362,
"DocModul.pas" + 3) + $22 [206A5731]{coreide210.bpl}
SourceModule.TSourceModule.Save (Line 1005, "SourceModule.pas" + 13) +
$7 [20880E20]{coreide210.bpl} DocModul.SaveModifiedModules (Line 3584,
"DocModul.pas" + 57) + $3 [0041FEA5]{bds.exe }
AppMain.{System.Generics.Collections}TList.IndexOf
(Line 1151, "System.Generics.Collections.pas" + 0) + $1
[5016D523]{rtl210.bpl } System.Classes.TBasicAction.Execute (Line
16099, "System.Classes.pas" + 3) + $7 [505AC25A]{vcl210.bpl }
Vcl.ActnList.TCustomAction.Execute (Line 259, "Vcl.ActnList.pas" + 19)
+ $35 [5016D3A7]{rtl210.bpl } System.Classes.TBasicActionLink.Execute (Line 16010, "System.Classes.pas" + 2) + $7 [505C316C]{vcl210.bpl }
Vcl.Controls.TControl.Click (Line 7346, "Vcl.Controls.pas" + 7) + $7
[5063F950]{vcl210.bpl } Vcl.ComCtrls.TToolButton.Click (Line 21481,
"Vcl.ComCtrls.pas" + 0) + $0 [505C3631]{vcl210.bpl }
Vcl.Controls.TControl.WMLButtonUp (Line 7487, "Vcl.Controls.pas" + 7)
+ $6 [505C2C15]{vcl210.bpl } Vcl.Controls.TControl.WndProc (Line 7232, "Vcl.Controls.pas" + 91) + $6 [5016E218]{rtl210.bpl }
System.Classes.StdWndProc (Line 16600, "System.Classes.pas" + 8) + $0
[505C2850]{vcl210.bpl } Vcl.Controls.TControl.Perform (Line 7010,
"Vcl.Controls.pas" + 10) + $8 [505C6E12]{vcl210.bpl }
Vcl.Controls.GetControlAtPos (Line 9773, "Vcl.Controls.pas" + 4) + $75
[505C6EDA]{vcl210.bpl } Vcl.Controls.TWinControl.ControlAtPos (Line
9796, "Vcl.Controls.pas" + 13) + $E [505C2850]{vcl210.bpl }
Vcl.Controls.TControl.Perform (Line 7010, "Vcl.Controls.pas" + 10) +
$8 [505C6FA8]{vcl210.bpl } Vcl.Controls.TWinControl.IsControlMouseMsg
(Line 9820, "Vcl.Controls.pas" + 15) + $29 [505C755E]{vcl210.bpl }
Vcl.Controls.TWinControl.WndProc (Line 9989, "Vcl.Controls.pas" + 104)
+ $6 [50641A65]{vcl210.bpl } Vcl.ComCtrls.TToolBar.UpdateButtonState (Line 22759, "Vcl.ComCtrls.pas" + 11) + $27 [50641AA6]{vcl210.bpl }
Vcl.ComCtrls.TToolBar.UpdateButtonStates (Line 22770,
"Vcl.ComCtrls.pas" + 3) + $4 [50644444]{vcl210.bpl }
Vcl.ComCtrls.TToolBar.WndProc (Line 24345, "Vcl.ComCtrls.pas" + 104) +
$6 [505C6D1C]{vcl210.bpl } Vcl.Controls.TWinControl.MainWndProc (Line
9750, "Vcl.Controls.pas" + 3) + $6 [5016E218]{rtl210.bpl }
System.Classes.StdWndProc (Line 16600, "System.Classes.pas" + 8) + $0
[507176C9]{vcl210.bpl } Vcl.Forms.TApplication.CancelHint (Line
11181, "Vcl.Forms.pas" + 6) + $D [5071635B]{vcl210.bpl }
Vcl.Forms.TApplication.ProcessMessage (Line 10352, "Vcl.Forms.pas" +
23) + $1 [5071639E]{vcl210.bpl } Vcl.Forms.TApplication.HandleMessage
(Line 10382, "Vcl.Forms.pas" + 1) + $4 [507166D1]{vcl210.bpl }
Vcl.Forms.TApplication.Run (Line 10520, "Vcl.Forms.pas" + 26) + $3
I think that the problem lies in the StyleBook component where I have defined some designs so that some parameters can only be modified by them.
it's frustrating that a commercial software doesn't give the opportunity at least to bypass the problem.Enough for me to understand what not to do.

Seens to be the TListView problem. Try to clear listview fields and clear search box if exists.

Related

how to solve the NaNs produced when i use the log()

> LL_LN<-function(para){
+ ww=para[1] # w
+ alpha=para[2] # alpha
+ beta=para[3]# beta
+ sigma=para[4]
+ n=length(R)
+ psi <- rep(0, n)
+ # read data from file , named as RR
+ psi[1]=0.5 # replace with mean (R) or R(1)
+ sum1 = -n/2*log(2*pi*sigma^2)
+ sum4 = -log(R[1])
+ sum3 = -((log(R[1])-log(psi[1]))+0.5*(sigma^2))^2/(2*(sigma^2))
+ sum=0
+
+ for (i in 2:n) {
+ psi[i]=ww+alpha*psi[i-1]+beta*R[i-1]
+ sum4=sum4-log(R[i])
+ sum3=sum3-((log(R[i])-log(psi[i]))+0.5*(sigma^2))^2/(2*(sigma^2))
+ }
+ sum=sum1+sum3+sum4
+ return(-sum)
+
+ }
> n=10000
> k=5
> sigma=0.25
> mu=-(sigma^2)/2
> result=c(0,0,0,0)
> output<-matrix(0,k,4)
> output<-as.data.frame(output)
> for(j in 1:k){
+ #E<-rexp(n,1)
+ E=rlnorm(n,mu,sigma)
+ w=1
+ a=0.2
+ b=0.3
+ R <- rep(0, n) # To Store R1,R2....R1000
+ X <- rep(0, n) # To Store X1,X2....X1000
+ X[1] = 0.5
+ R[1]=X[1]*E[1]
+
+ for (i in 2:n) # To Find R1,R2....R1000
+ {
+ X[i]=w+a*X[i-1]+b*R[i-1]
+ R[i]=X[i]*E[i]
+ }
+ hist(R)
+ mean(E)
+
+ initial =c(1,0.2,0.3,2)
+ op<-optim(initial,LL_LN)
+ output$V1[j] <- op$par[1]
+ output$V2[j] <- op$par[2]
+ output$V3[j] <- op$par[3]
+ output$V4[j] <- op$par[4]
+
+ print(output)
+ }
V1 V2 V3 V4
1 1.0202418 0.1989128 0.2927711 0.2484346
2 0.9725745 0.2159796 0.2970536 0.2529665
3 1.0648460 0.1692719 0.2987034 0.2492417
4 1.0186746 0.1819587 0.3039954 0.2517418
5 1.0022230 0.2103271 0.2858050 0.2484962
There were 50 or more warnings (use warnings() to see the first 50)
> mean<-cbind(mean(output$V1),mean(output$V2),mean(output$V3),mean(output$V4))
> mean
[,1] [,2] [,3] [,4]
[1,] 1.015712 0.19529 0.2956657 0.2501762

Transform Solver Excel program in R

I want to maximize a one variable (sum(DeplaQ1$somme_vrai)) with unknow parameters (alpha,VDT,constVPC,constVPP,a,constTC,const2RM,constTaxi) and I want to determine this parametres with a one constraint x1 <= 10000
I do not find this solution. triplaQ1 is a database with time and number of trip per transport mod.I try to use Optimum or LpSolve but it does not work.**
** My program :
fr <- function(alpha,VDT,constVPC,constVPP,a,constTC,const2RM,constTaxi) {
triplaQ1$u_VPC <- - (alpha * alpha + 0.001)*(triplaQ1$time_VPC*VDT + 0.15*triplaQ1$dist_VPC + constVPC)
triplaQ1$u_VPP <- - (alpha * alpha +0.001) * (triplaQ1$time_VPP * VDT) + constVPP
triplaQ1$u_TC <- - (alpha * alpha +0.001) * ((triplaQ1$time_TC/a)*VDT+constTC)
triplaQ1$u_mp <- - (alpha * alpha +0.001) * (triplaQ1$time_MP * VDT)
triplaQ1$u_2RM <- - (alpha * alpha +0.001) * (triplaQ1$time_2RM * VDT + const2RM)
triplaQ1$u_Taxi <- - (alpha * alpha + 0.001) * (triplaQ1$time_Taxi * VDT + 0.3 * triplaQ1$dist_Taxi + constTaxi)
triplaQ1$simuleVPC <- triplaQ1$trip * ((exp(triplaQ1$u_VPC)) / (exp(triplaQ1$u_VPC) + exp(triplaQ1$u_VPP) + exp(triplaQ1$u_TC) + exp(triplaQ1$u_mp) + exp(triplaQ1$u_2RM) + exp(triplaQ1$u_Taxi)))
triplaQ1$simuleVPP <- triplaQ1$trip * ((exp(triplaQ1$u_VPP)) / (exp(triplaQ1$u_VPC) + exp(triplaQ1$u_VPP) + exp(triplaQ1$u_TC) + exp(triplaQ1$u_mp) + exp(triplaQ1$u_2RM) + exp(triplaQ1$u_Taxi)))
triplaQ1$simuleTC <- triplaQ1$trip * ((exp(triplaQ1$u_TC)) / (exp(triplaQ1$u_VPC) + exp(triplaQ1$u_VPP) + exp(triplaQ1$u_TC) + exp(triplaQ1$u_mp) + exp(triplaQ1$u_2RM) + exp(triplaQ1$u_Taxi)))
triplaQ1$simuleMAP <- triplaQ1$trip * ((exp(triplaQ1$u_mp)) / (exp(triplaQ1$u_VPC) + exp(triplaQ1$u_VPP) + exp(triplaQ1$u_TC) + exp(triplaQ1$u_mp) + exp(triplaQ1$u_2RM) + exp(triplaQ1$u_Taxi)))
triplaQ1$simule2RM <- triplaQ1$trip * ((exp(triplaQ1$u_2RM)) / (exp(triplaQ1$u_VPC) + exp(triplaQ1$u_VPP) + exp(triplaQ1$u_TC) + exp(triplaQ1$u_mp) + exp(triplaQ1$u_2RM) + exp(triplaQ1$u_Taxi)))
triplaQ1$simuleTaxi <- triplaQ1$trip * ((exp(triplaQ1$u_Taxi)) / (exp(triplaQ1$u_VPC) + exp(triplaQ1$u_VPP) + exp(triplaQ1$u_TC) + exp(triplaQ1$u_mp) + exp(triplaQ1$u_2RM) + exp(triplaQ1$u_Taxi)))
triplaQ1$somme_simule <- triplaQ1$simuleVPC + triplaQ1$simuleVPP + triplaQ1$simuleTC + triplaQ1$simuleMAP + triplaQ1$simule2RM + triplaQ1$simuleTaxi
triplaQ1$shsimuleVPC <- ifelse(triplaQ1$trip > 0.001, triplaQ1$simuleVPC/triplaQ1$trip, 0)
triplaQ1$shsimuleVPP <- ifelse(triplaQ1$trip > 0.001, triplaQ1$simuleVPP/triplaQ1$trip, 0)
triplaQ1$shsimuleTC <- ifelse(triplaQ1$trip > 0.001, triplaQ1$simuleTC/triplaQ1$trip, 0)
triplaQ1$shsimuleMAP <- ifelse(triplaQ1$trip > 0.001, triplaQ1$simuleMAP/triplaQ1$trip, 0)
triplaQ1$shsimule2RM <- ifelse(triplaQ1$trip > 0.001, triplaQ1$simule2RM/triplaQ1$trip, 0)
triplaQ1$shsimuleTaxi <- ifelse(triplaQ1$trip > 0.001, triplaQ1$simuleTaxi/triplaQ1$trip, 0)
triplaQ1$shsommesimule <- triplaQ1$shsimuleVPC + triplaQ1$shsimuleVPP + triplaQ1$shsimuleTC + triplaQ1$shsimuleMAP + triplaQ1$shsimule2RM + triplaQ1$shsimuleTaxi
triplaQ1$VraiVPC <- ifelse(triplaQ1$trip > 0,triplaQ1$Tij_vpc * log(triplaQ1$simuleVPC/triplaQ1$trip),0)
triplaQ1$VraiVPP <- ifelse(triplaQ1$trip > 0,triplaQ1$Tij._vpp * log(triplaQ1$simuleVPP/triplaQ1$trip),0)
triplaQ1$VraiTC <- ifelse(triplaQ1$trip > 0,triplaQ1$Tij._tc * log(triplaQ1$simuleTC/triplaQ1$trip),0)
triplaQ1$VraiMAP <- ifelse(triplaQ1$trip > 0,triplaQ1$Tij._mp * log(triplaQ1$simuleMAP/triplaQ1$trip),0)
triplaQ1$Vrai2RM <- ifelse(triplaQ1$trip > 0,triplaQ1$Tij._2RM * log(triplaQ1$simule2RM/triplaQ1$trip),0)
triplaQ1$VraiTaxi <- ifelse(triplaQ1$trip > 0,triplaQ1$Tij_Taxi * log(triplaQ1$simuleTaxi/triplaQ1$trip),0)
triplaQ1$somme_vrai <- triplaQ1$VraiVPC + triplaQ1$VraiVPP + triplaQ1$VraiTC + triplaQ1$VraiMAP + triplaQ1$Vrai2RM + triplaQ1$VraiTaxi
return(sum(triplaQ1$somme_vrai))
}
x1 <- sqrt((sum(DeplaQ1$dep_VPC) - sum(DeplaQ1$simuleVPC))^2 + (sum(DeplaQ1$dep_VPP) - sum(DeplaQ1$simuleVPP))^2 + (sum(DeplaQ1$dep_TC) - sum(DeplaQ1$simuleTC))^2 + (sum(DeplaQ1$dep_2RM) - sum(DeplaQ1$simule2RM))^2 + (sum(DeplaQ1$dep_MP) - sum(DeplaQ1$simuleMAP))^2 + (sum(DeplaQ1$dep_Taxi) - sum(DeplaQ1$simuleTaxi))^2)
thank you in advance
first translate the EXCEL formula you want to find a target value to to a r-function. I did this for a very simple formula x^2+y^2 here, this is my_fun in the example. Then define a function that gives the squared difference (or any other norm you want to use) between target value and function value for all inputs. Then just put everything into the optim function.
my_fun <- function(x){
x[1]^2 + x[2]^2
}
target <- 2
optim_fun <- function(x){
sum((my_fun(x)-target)^2)
}
res <- optim(c(0,0), optim_fun)
res
To deal with constraints you could introduce a penalty term. Some algorithms in optim also support constraints. There are a lot of more specialised optimisation libraries for R if the very basic optim function does not fit your need.

Can this query be shorter? Sqlite

Keep in mind that I use sqlite so I can't use stuff like:
(SELECT Z1, Z2, Z3, DECODE(Z1, 'x', 1, 0) + DECODE(Z2, 'x', 1, 0) + DECODE(Z3, 'x', 1, 0) test FROM InfoP1)
This is my query:
String sql = "SELECT ID, Nume, Prenume,"
+ "InfoP1.Z1, InfoP1.Z2, InfoP1.Z3, "
+ "SUM(InfoP1.Z1 + InfoP1.Z2 + InfoP1.Z3) AS Total, "
+ "(SELECT(((CASE WHEN Z1 = 'x' then 1 else 0 END)"
+ "+ (CASE WHEN Z2 = 'x' then 1 else 0 END)"
+ "+ (CASE WHEN Z3 = 'x' then 1 else 0 END))*8) AS Test),"
+ "FROM InfoAn "
+ "LEFT JOIN InfoP1 ON InfoAn.ID = InfoP1.rowid "
+ "GROUP BY ID";
In SQLite, boolean expressions return 0 or 1, so you can simply drop the decoding:
SELECT Z1, Z2, Z3, (Z1 = 'x') + (Z2 = 'x') + (Z3 = 'x') AS test FROM InfoP1

What value is returned by the call f(4,2)?

//pseudocode
//n and k are nonnegative integers`
int f(int n, int k)`
`if(k*n ==0)`
`return 1`
`else`
`return f(n-1,k-1)+f(n-1,k)`
`end if`
end f
What I have so far is this. But how do I find the value of this function call?
f(3,1) + f(3,2)
f(2,0) +f(2,1) f(2,1)+f(2,2)
1 f(1,0)+f(1,1) f(1,1)+f(1,2)
f(0,0)+f(0,1) f(0,1)+f(0,2)
Basically the answer is just continuing what you started:
f(4, 2) ; ==
f(3, 1) + f(3, 2) ; ==
f(2, 0) + f(2, 1) + f(2, 1) + f(2, 2) ; ==
1 + f(1, 0) + f(1, 1) + f(1, 0) + f(1, 1) + f(1, 1) + f(1, 2) ; ==
1 + 1 + f(0, 0) + f(0, 1) + 1 + f(0, 0) + f(0, 1)+ f(0, 0) +
f(0, 1) + f(0, 1) + f(0, 2) ; ==
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 ; ==
11
The answer is 11.
One simple way to understand recursion function call is to expand the recursion call stack tree, which can help you clearly see how the whole process goes(Hope the pic is clear enough):
In the comment I mentioned divede-and-conquer process in a recursion process, so I updated a new image to contain the whole process. Hope this could be helpful :-)

Thick Bezier curves in SVG without artifacts

I try to draw thick Bezier lines (for a custom Sankey diagram).
I use SVG Paths, with Bezier curves in the form of C x1 y1, x2 y2, x y. I use stroke rather than fill, so that they have constant width (and can represent flows).
It works very well if the lines are thin or if the vertical difference is relatively low. However, if they are very thick, I get some nasty artifacts (looking like horns) - see the bottom right curve from the picture below:
Source: http://jsfiddle.net/stared/83jr5fub/
Is there a way to avoid artifacts, i.e.:
ensure there is nothing on the left of x1 or right of x,
actual widths on the left and right match stroke-width?
I think that he best solution in your case (with the given path), is to make your path closed, and use its fill property.
To do this, you'll have to make a lineTo(0, strokeWidth) at the end of your BezierCurveTo, and then to redraw the bezierCurve in the other way :
var svg = d3.select("#chart");
var data = [
{t: 5, dy: 10},
{t: 5, dy: 20},
{t: 5, dy: 40},
{t: 20, dy: 10},
{t: 20, dy: 20},
{t: 20, dy: 40},
{t: 50, dy: 10},
{t: 50, dy: 20},
{t: 50, dy: 40},
];
var ctrl = 10;
var dx = 40;
var spacing = 100;
var colors = d3.scale.category10();
svg
.attr("width", 4 * spacing)
.attr("height", 4 * spacing);
svg.selectAll("path")
.data(data)
.enter()
.append("path")
.attr("d", function (d, i) {
var x1 = spacing + spacing * (i % 3);
var y1 = spacing + spacing * Math.floor(i / 3);
return "M" + x1 + "," + y1 +
"c" + ctrl + "," + 0 +
" " + (dx - ctrl) + "," + d.dy +
" " + dx + "," + d.dy +
// move down for the wanted width
"l" + (0) + "," + (d.t) +
// negate all values
"c" + (ctrl * -1) + "," + 0 +
" " + ((dx - ctrl) * -1) + "," + (d.dy * -1) +
" " + (dx * -1) + "," + (d.dy * -1);
})
.style("fill", colors(0))
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<svg id="chart"></svg>
And since an animation worth more than 10 thousand words here is one showing what was happening and why it can't be called a browser bug :
#keyframes dash {
from {
stroke-dashoffset: -10%;
}
to {
stroke-dashoffset: 90%;
}
}
#-webkit-keyframes dash {
from {
stroke-dashoffset: -10%;
}
to {
stroke-dashoffset: 90%;
}
}
#dashed{
animation : dash 12s linear infinite;
}
<svg height="200" width="200" id="chart" viewBox="290 260 100 100">
<path id="dashed" style="fill: none; stroke: rgb(31, 119, 180); stroke-width: 50; stroke-dasharray: 3, 3;" d="M300,300c10,0 30,40 40,40"></path>
<path style="fill: none; stroke: black;" d="M300,300c10,0 30,40 40,40">
</path></svg>
Kaiido gave an excellent and complete answer for why the SVG-path with thick stroke-width are displayed with artifacts and how to avoid this. I'll try to provide a bit more info that is specific to D3.js Sankey diagrams, as I was recently facing the same problem as Piotr Migdal.
Original Sankey diagram code
(from Sankey.js in this Sankey example, which is similar to the example Piotr Migdal mentioned)
// regular forward node
var x0 = d.source.x + d.source.dx,
x1 = d.target.x,
xi = d3.interpolateNumber(x0, x1),
x2 = xi(curvature),
x3 = xi(1 - curvature),
y0 = d.source.y + d.sy + d.dy / 2,
y1 = d.target.y + d.ty + d.dy / 2;
return "M" + x0 + "," + y0
+ "C" + x2 + "," + y0
+ " " + x3 + "," + y1
+ " " + x1 + "," + y1;
Modified code
// regular forward node
var x0 = d.source.x + d.source.dx,
x1 = d.target.x,
xi = d3.interpolateNumber(x0, x1),
x2 = xi(curvature),
x3 = xi(1 - curvature),
y0 = d.source.y + d.sy,
y1 = d.target.y + d.ty;
return "M" + x0 + "," + y0
+ "C" + x2 + "," + y0
+ " " + x3 + "," + y1
+ " " + x1 + "," + y1
// move down for the wanted width
+ "l" + 0 + "," + d.dy
// draw another path below mirroring the top
+ "C" + x3 + "," + (y1 + d.dy)
+ " " + x2 + "," + (y0 + d.dy)
+ " " + x0 + "," + (y0 + d.dy);
Then you'll also need to change your css:
stroke: none
set fill color
and remove any D3 code that sets stroke-width of HTML elements.

Resources