Link to home
Start Free TrialLog in
Avatar of SiobhanElara
SiobhanElaraFlag for United States of America

asked on

Can I group FusionCharts monthly x-axis labels by year?

I have a chart created in FusionCharts that has data running back 10 years with a point for every month.  Is there a way to have the x-axis labeled only by year? For example,  instead of reading Jan 2010, Feb 2010, etc the area would just say 2010 once, spanning the width of the 12 months?

Thanks!
Avatar of Rob
Rob
Flag of Australia image

You can but it requires you to redo the data yourself. It will not do it internally.

What kind of chart are you creating?
Avatar of SiobhanElara

ASKER

It's just a line chart. I added vertical lines for the years but, other than that, nothing fancy (though a bit of the code is in ColdFusion for outputting data.)

  FusionCharts.ready(function(){
    var sentimentChart = new FusionCharts({
        "type": "line",
        "renderAt": "sentimentChartContainer",
        "width": "100%",
        "height": "300",
        "dataFormat": "json",
        "dataSource":  {
          "chart": {
				"caption": "Consumer Sentiment",
				//"subCaption": "Single Family",
				"xAxisName": "Date",
				"yAxisName": "Sentiment",
				"showVLineLabelBorder": "0",
				"theme": "chartTheme"
			}, //end chart
         "data": [
			<cfoutput query="qGetChartData">
				<cfif Month(dataDate) EQ 1>
					{
						//Setting data as vline data
						"vline": "true",
						//Adding label
						"label": "#year(dataDate)#",
						"labelPosition": "0.7",
						"labelHAlign": "left",
						"color": "##ccc"
					},
				</cfif>
				{	
					"label": "#DateFormat(dataDate, 'mmm-yy')#",
					"value": "#sentimentNumber#"
				}<cfif recordCount NEQ currentRow>,</cfif>
			</cfoutput>
          ] //end data
      }

  });
sentimentChart.render();
})

Open in new window

so it's just a matter of redoing your data.  Are you wanting the user to be able to switch between months and years or are you trying to change the chart permanently?
Good question. Let's go with switching between, since historically people change their minds once things are done a certain way. ;-)
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Fabulous, thank you so much for your help!