Error rendering macro with javascript

Deleted user September 15, 2015

I just created a user macro as listed below. It produces a rendering error but I cannot see what to do about it. Adding the code using the html-macro it works perfectly fine. Thanks for help, BKS

## Macro title: Google Graph
## Macro has a body: N
## Body processing: No macro body
## Output: Selected output option
##
## Developed by: Firstname Lastname
## Date created: 15/09/2015
## Installed by: Firstname Lastname
##
## @param SourceFile:title=Quelldatei|type=string|required=true|desc=Gib den Pfad zur Quelldatei an
## @param DataType:title=Datentyp|type=enum|enumValues=tav,role|default=tav|desc=Datentyp gibt an nach welcher Logik die Quelldatei geparst werden muss
## @param ChartID:title=Chart ID|type=string|required=true|desc=Vergebe jedem Chart eine eindeutige ID
## @param ChartTitle:title=Chart-Titel|type=string|required=true|desc=Der Titel des Charts
## @param ChartType:title=Chart-Typ|type=enum|enumValues=column,pie,line|default=column|desc=Waehle den Typen
## @param ChartWidth:title=Breite der Abbildung|type=string|required=true|desc=Angabe in Pixel - ohne px
## @param ChartHeight:title=Höhe der Abbildung|type=string|required=true|desc=Angabe in Pixel - ohne px
## @param AxisVertTitle:title=Titel der vertikalen Achse|type=string|required=true|desc=Setze die Beschriftung für die vertikale Achse
## @param AxisHorTitle:title=Titel der horizontalen Achse|type=string|required=true|desc=Setze die Beschriftung für die horizontale Achse
<div id="chart_$paramChartID">
</div>
<script type="text/javascript" src="https://www.google.com/jsapi">
</script>
<script type="text/javascript" src="http://192.168.56.202:8090/download/attachments/1081346/DrawChart.js">
</script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
</script>
<script type="text/javascript">
$.ajax({
    type: "GET",
    url: "$paramSourceFile",
    success: function(csvData)
    {
        switch ("$paramDataType")
        {
            case "tav":
                var data = ProcessTAVData(csvData);
                break;
            default:
                var data = ProcessTAVData(csvData);
        }
        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(DrawChart(
            data,
            "$paramChartID",
            "$paramChartTitle",
            "$paramChartType",
            "$paramChartWidth",
            "$paramChartHeight",
            "$paramAxisHorTitle",
            "$paramAxisVertTitle"
        ));
    }
});
</script>

2 answers

1 accepted

2 votes
Answer accepted
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2015

It's probably the $.ajax({. I've had issues with the velocity engine mistaking the $ as a velocity variable. Try this instead.

## @param AxisHorTitle:title=Titel der horizontalen Achse|type=string|required=true|desc=Setze die Beschriftung für die horizontale Achse


#set( $d = '$' )
 
<div id="chart_@paramChartID">
</div>
....
....
${d}.ajax({...
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2015

or you can just use jQuery instead of $

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2015

Yup. That'll work too.

Deleted user September 16, 2015

Thx, that was pretty obvious. ;) I just replaced the $ with 'jQuery' and now everything works fine! :)

0 votes
Alex Yasurek
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2015

Do you get any errors in the console when it tries to run on a page? 

Also, have you tried just removing pieces of the code until it works to try and pin point where it is failing?

Here are some things that you may want to check also:

https://answers.atlassian.com/questions/21353

https://answers.atlassian.com/questions/201855

 

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events