It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Error rendering macro with javascript

Boris Karl Schlein Sep 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 Community Leader Sep 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 Sep 16, 2015

or you can just use jQuery instead of $

Davin Studer Community Leader Sep 16, 2015

Yup. That'll work too.

Boris Karl Schlein Sep 16, 2015

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

0 votes
Alex Yasurek Sep 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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

2,587 views 12 29
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you