Skip to content

Instantly share code, notes, and snippets.

@feminie
Last active June 15, 2016 15:45
Show Gist options
  • Save feminie/f67a323119656b8ef80d to your computer and use it in GitHub Desktop.
Save feminie/f67a323119656b8ef80d to your computer and use it in GitHub Desktop.
JIRA Google Image Chart Custom Field
<!-- @@Formula:
String GenerateChartUrl(String prmRawData, String prmLabelData)
{
String log = "";
int recentCount = 20;
int scaleScope = 4;
String urlHeader = "https://chart.googleapis.com/chart?";
String urlCht = "cht=lc";
String urlChs = "chs=800x320";
String urlChxt = "chxt=x,y,x";
String urlChxl = "chxl=2:|";
String urlChco = "chco=6699FF";
String urlChm = "chm=s,3399CC,0,0::1,8.0|h,FF0000,0,0.8,1"; //min line : h 0.8
String urlChl = "chl="; // x axis value
String urlChd = "chd=t:"; // y axis value
String urlChem = "chem="; // for label
String[] splitRawData = prmRawData.split(";");
String xValuesConcat = "";
String yValuesConcat = "";
String xScaleConcat = "";
int generationStartIndex = splitRawData.length-recentCount;
if (generationStartIndex < 0)
{
generationStartIndex = 0;
}
String[] dateLookup = new String[splitRawData.length];
int lookupCounter = 0;
int seq = 0;
for (int i = generationStartIndex; i < splitRawData.length; i++)
{
String[] splitXY = splitRawData[i].split(",");
dateLookup[lookupCounter++] = splitXY[0];
xValuesConcat += splitXY[0].substring(4);
yValuesConcat += splitXY[1];
if (i < splitRawData.length-1)
{
xValuesConcat += "|";
yValuesConcat += ",";
}
if (seq % scaleScope == 0)
{
xScaleConcat += splitXY[0];
}
if (seq < splitRawData.length-generationStartIndex-1)
{
xScaleConcat += "|";
}
else
{
if ((seq+1) % scaleScope == 0)
{
xScaleConcat += splitXY[0];
}
}
seq++;
}
// label generation
String[] splitLabelData = prmLabelData.split(";");
String dateLabel = "";
int dsValue = -1;
String txtLabel = "";
String eachGeneratedLabel = "";
String totalGeneratedLabel = "";
String labelTemplate = "y;s=bubble_text_small;d=bbbr,#CONTENTS#,FF8,000;ds=0;dp=";
seq = 0;
for (int i = 0; i < splitLabelData.length; i++)
{
String[] splitDateLabel = splitLabelData[i].split(",");
try {
dateLabel = splitDateLabel[0];
txtLabel = splitDateLabel[1];
}
catch (ArrayIndexOutOfBoundsException ex)
{
break;
}
// find label index
dsValue = -1;
for (int j = 0; j < dateLookup.length; j++)
{
if (dateLookup[j].equals(dateLabel))
{
dsValue = j;
}
log += "j="+j+">>>dateLookup[j]="+dateLookup[j]+">>>dateLabel="+dateLabel+">>>dsValue="+String.valueOf(dsValue);
if (dsValue > -1)
{
break;
}
}
seq++;
// contents escaping
txtLabel = txtLabel.replaceAll(" ", "+");
eachGeneratedLabel = labelTemplate;
eachGeneratedLabel = eachGeneratedLabel.replaceAll("#CONTENTS#", txtLabel);
totalGeneratedLabel += eachGeneratedLabel + String.valueOf(dsValue);
if (seq < splitLabelData.length)
{
totalGeneratedLabel += "|";
}
}
String result = "";
result += urlHeader;
result += urlCht + "&";
result += urlChs + "&";
result += urlChxt + "&";
result += urlChxl + xScaleConcat + "&";
result += urlChco + "&";
result += urlChm + "&";
result += urlChl + xValuesConcat + "&";
result += urlChd + yValuesConcat;
if (totalGeneratedLabel != "")
{
result += "&";
result += urlChem + totalGeneratedLabel;
}
return result;
}
if (issue.get("customfield_12320")==null)
return null;
String issueMessage = "";
if (issue.get("customfield_12602")!=null)
{
issueMessage = String.valueOf(issue.get("customfield_12602"));
}
return String.valueOf(
"<img style='-webkit-user-select: none' src='"+
GenerateChartUrl(String.valueOf(issue.get("customfield_12320")), issueMessage) +"'>"
);
-->
@quest4i
Copy link

quest4i commented Jun 15, 2016

안녕하세요. 혹시 플러그인 전체 소스를 구할 수 있을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment