Akshay S

Using FusionCharts x-axis labels as links in FusionCharts XT method

Recommended Posts

Hi,

 

I'm new to FusionCharts. I can call a Javascript function and pass parameters onClick of each column(say i'm using Column2D shockwave File+XML input+Jquery render method) using following XML

 

<graph yAxisNamePadding='20' labelPadding='10' yAxisName='AMOUNT' decimalSeparator=',' showhovercap='1' canvasborderalpha='0' canvasborder='3D86C6' showalternatehgridcolor='0' numdivlines='0' animation='1' showValues='0' showLimits='0'  showYAxisValues='0'  showDivLineSecondaryValue='0' numDivLines='0' outCnvBaseFontColor='3D86C6'   outCnvBaseFontSize='12'  bgColor='ffffff' showLegend='0' showBorder='1' borderAlpha='0' plotGradientColor='' plotBorderColor='ffffff'>
<vLine color='3D86C6' thickness='2'/>
<set name='MAY' value='28090.02' color='3D86C6' link='JavaScript: myJS(4,1); ' />
<set name='JUN' value='0' color='3D86C6' link='JavaScript: myJS(5,2); ' />
<set name='JUL' value='186236.7' color='3D86C6' link='JavaScript: myJS(6,3); ' />
<set name='AUG' value='0' color='3D86C6' link='JavaScript: myJS(7,4); ' />
<set name='SEP' value='0' color='3D86C6' link='JavaScript: myJS(8,5); ' />
<set name='OCT' value='65102.434' color='3D86C6' link='JavaScript: myJS(9,6); ' />
<set name='NOV' value='0' color='3D86C6' link='JavaScript: myJS(10,7); ' />
<set name='DEC' value='492987.38' color='3D86C6' link='JavaScript: myJS(11,8); ' />
<set name='JAN' value='0' color='3D86C6' link='JavaScript: myJS(0,9); ' />
<set name='FEB' value='0' color='3D86C6' link='JavaScript: myJS(1,10); ' />
<set name='MAR' value='0' color='3D86C6' link='JavaScript: myJS(2,11); ' />
<set name='APR' value='59831.70' color='B0BC25' link='JavaScript : myJS(3,12); ' />
<trendLines>  <line startValue='166449.66' color='#FBA91E'  thickness='5'  displayValue=' ' />
</trendLines>  <trendlines>   <line color='3D86C6' showOnTop='1' isTrendZone='0' thickness='2' endValue='1' startValue='1' displayValue=' ' />
</trendlines>  <styles><definition><style name='MyFirstFontStyle' type='font' font='GothamMedium' size='14' color='3D86C6' bold='0'/>
</definition><application><apply toObject='YAXISNAME' styles='MyFirstFontStyle'/><apply toObject='DATALABELS' styles='MyFirstFontStyle'/>
<apply toObject='DATAVALUES' styles='MyFirstFontStyle'/></application></styles>
</graph>
 
 
As per my another requirement i need to call javascript function onClick of x-axis labels not onClick of Columns. Here i'm using MSCombiDY2D shockWave File to get Multiseries column 2D+Single line chart with input fed as Json like
 
{
  "chart": {
    "palette": "5",
    "caption": "Sales",
    "showlabels": "1",
    "connectnulldata": "0",
    "pyaxisname": "TICKET VOLUME",
    "plotGradientColor": " ",
    "showPlotBorder": "0",
    "canvasborder": "3D86C6",
    "canvasborderalpha": "0",
    "showalternatehgridcolor": "0",
    "numdivlines": "0",
    "showLimits": "0",
    "plotBorderColor": "ffffff",
    "showBorder": "0",
    "chartRightMargin": "0",
    "chartTopMargin": "0",
    "lineColor": "00611C",
    "borderAlpha": "0",
    "bgColor": "ffffff",
    "showYAxisValues": "0",
    "legendPosition": "TOP",
    "formatnumberscale": "0"
  },
  "categories": [
    {
      "category": [
        {
          "vline": "true",
          "color": "3D86C6",
          "thickness": "2"
        },
        {
          "label": "<a href='http://www.fusioncharts.com'> Jan </a>"
        },
        {
          "label": "Feb"
        },
        {
          "label": "Mar"
        },
        {
          "label": "Apr"
        }
      ]
    }
  ],
  "dataset": [
    {
      "seriesname": "First",
      "color": "33CCFF",
      "showvalues": "1",
      "data": [
        {
          "value": "25601.34"
        },
        {
          "value": "20148.82"
        },
        {
          "value": "35407.15"
        },
        {
          "value": "38105.68"
        }
      ]
    },
    {
      "seriesname": "Second",
      "color": "6666FF",
      "showvalues": "1",
      "data": [
        {
          "value": "57401.85"
        },
        {
          "value": "41941.19"
        },
        {
          "value": "45263.37"
        },
        {
          "value": "117320.16"
        }
      ]
    },
    {
      "seriesname": "Third",
      "color": "D14719",
      "anchorBorderColor": "D14719",
      "anchorBgColor": "D14719",
      "anchorRadius": "5",
      "showvalues": "0",
      "parentyaxis": "S",
      "renderas": "Line",
      "data": [
        {
          "value": "45000"
        },
        {
          "value": "44835"
        },
        {
          "value": "42835"
        },
        {
          "value": "77557"
        }
      ]
    }
  ],
  "trendlines": [
    {
      "line": [
        {
          "color": "3D86C6",
          "showOnTop": "1",
          "isTrendZone": "0",
          "thickness": "2",
          "endValue": "1",
          "startValue": "1",
          "displayValue": " "
        }
      ]
    }
  ],
  "styles": {
    "definition": [
      {
        "name": "CategoryLink",
        "type": "font",
        "ishtml": "1"
      }
    ],
    "application": [
      {
        "toobject": "DATALABELS",
        "styles": "CategoryLink"
      }
    ]
  }
}
 
but i'm not able to make atleast x-axis label Clickable.  

Share this post


Link to post
Share on other sites
Hi,

 

Due to security and performance reasons, support for HTML tags like anchor tags defined within X-axis labels has been dropped. So, this feature will not be available for the current version v3.3.1 SR3 as well.

 

The using of anchor (<a> tag) inside label for having links was a workaround provided to address the requirement to have links on x-axis labels in older versions of FusionCharts. This workaround does not work anymore, since we have made the charts more restrictive to external tags due to security constraints. 

 

Hope this helps.

Share this post


Link to post
Share on other sites

Okay. Thanks haritha.

 

Can we make x-axis labels clickable, say i want to call a javascript function onClick of x-axis labels. 

Share this post


Link to post
Share on other sites

Hi,

 

As said above, it is not possible to add a link on x-axis label to make it call a JavaScript function when a user clicks on it.

 

However, you may add links to data plots (columns) such that a JavaScript function gets called when a user clicks on the particular data plot. 

 

For more information on adding JavaScript function as link on data plot, refer: http://docs.fusioncharts.com/charts/contents/index.html?DrillDown/JavaScript.html

 

Also, for a demo of the same, refer: http://docs.fusioncharts.com/charts/Code/DrillDown/JSExample.html

 

Hope this helps.

Share this post


Link to post
Share on other sites

Okay. Thanks for response.

We already achieved making links on Data plot but making labels clickable i needed. Anyway thanks for response.

Share this post


Link to post
Share on other sites

Hi, 

 

I'm re-opening this thread because I find the answer quite unsatisfying and we need this feature as well.  Why would it be a security hole to call a javascript function when clicking on the axis members, but it's NOT a security hole to call a javascript function when clicking on a data plot?  That doesn't make any sense.

 

Thanks,

Steve

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now