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?

Web Development

Avatar of undefined
Last Comment

8/22/2022 - Mon

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

What kind of chart are you creating?

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.)

    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"
					"label": "#DateFormat(dataDate, 'mmm-yy')#",
					"value": "#sentimentNumber#"
				}<cfif recordCount NEQ currentRow>,</cfif>
          ] //end data


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?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

Good question. Let's go with switching between, since historically people change their minds once things are done a certain way. ;-)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Fabulous, thank you so much for your help!