Skip to content

Commit

Permalink
nameinjs
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed Oct 21, 2024
1 parent 2b87321 commit 53adcb0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
int height = 100+nameCount.Count() * 20;
var xaxis = "[" +
string.Join(',', nameCount
.Select(it => it.Name)
.Select(it => it.NameInJS())
.Select(it => it.Replace("<", "#60;"))
.Select(it => it.Replace(">", "#62;"))
.Select(it => "\"" + it + "\"")
.ToArray())
+ "]";
var maxCount = nameCount.Max(it => it.Count);
Expand All @@ -40,7 +39,7 @@
{
nameCountGraphic = nameCount.Take(10).ToArray();
}
string assNamesMaintIndex = string.Join(",", nameCountGraphic.Select(it => "'" + it.Name.Replace("\\", "\\\\") + "'"));
string assNamesMaintIndex = string.Join(",", nameCountGraphic.Select(it => "'" + it.NameInJS() + "'"));
string valuesMaintIndex = string.Join(",\r\n",
nameCountGraphic.Select(it => "{value:" + it.Count +"}")
);
Expand Down Expand Up @@ -125,7 +124,7 @@ bar @yAxis
@foreach (var item in nameCountOriginal)
{
<text>
{"Name": "@item.Name.Replace("\\", "\\\\")", "Nr": "@item.Count" },
{"Name": "@item.NameInJS()", "Nr": "@item.Count" },
</text>
}
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

//threshold1 = 40;
//threshold2 = 80;
string assNamesMaintIndex = string.Join(",", nameCountGraphic.Select(it => "'" + it.Name + "'"));
string assNamesMaintIndex = string.Join(",", nameCountGraphic.Select(it => "'" + it.NameInJS() + "'"));
string valuesMaintIndex = string.Join(",\r\n",
nameCountGraphic.Select(it => "{value:" + it.Count +
(CompareT(it.Count, threshold1, inverseData) ? ",itemStyle:{color:'red'}"
Expand Down Expand Up @@ -128,7 +128,7 @@
@foreach (var item in nameCount)
{
<text>
{"Name": "@item.Name", "Nr": "@item.Count" },
{"Name": "@item.NameInJS()", "Nr": "@item.Count" },
</text>
}
];
Expand All @@ -153,7 +153,7 @@
@{
if (display2.Length > 0)
{
assNamesMaintIndex = string.Join(",", display2.Select(it => "'" + it.Name + "'"));
assNamesMaintIndex = string.Join(",", display2.Select(it => "'" + it.NameInJS() + "'"));

var displayValues = nameCount
.Select(it => "{value:" + it.Count + ",itemStyle:{color:'red'}}"
Expand Down
7 changes: 7 additions & 0 deletions src/NetPackageAnalyzer/NetPackageAnalyzerObjects/many.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public class PublicClassRefData

public record NamePerCount(string Name, long Count)
{

public string NameInJS()
{
return Name
.Replace("\\", "\\\\")
.Replace("\"", "\\\"");
}
public string AdditionalData { get; set; } = Name;

}
Expand Down

0 comments on commit 53adcb0

Please sign in to comment.