Invient Charts: Possibility to change the x- and y-axis caption dynamically

At first: I’ve asked this question also in the general froum thread about the Invient Chart plugin, but I’m afraid it will get lost in this 1000 pages there, so I hope you will excuse me to open an own thread about this problem. I hope this will make it easier to find an appropriate answer.


Is it possible to dynamically change the x- and y-axis Caption of the scattertchart (so after the chart has been created)?

I’m currently having a scatterchart and a button. When the button is clicked, all existing points (Series) shall be removed, the axis caption shall change and the new points shall be added on the chart.

That’s the code snippet with which I’m trying it currently:

public void changePoints(String xAxisTitle, String yAxisTitle, List<List<double[]>> xAndYCoordinates) {
		// remove all points from the scatterchart - THIS IS WORKING
		Object[] allSeries = chart.getAllSeries().toArray();
		for(int j = 0; j < allSeries.length; j++){
			Series serie = (Series) allSeries[j]
; 
			chart.removeSeries(serie); 
		}
		
		// update the x- and y-axis - THIS IS NOT WORKING
		chartConfig.getXAxes().clear(); 
		chartConfig.getYAxes().clear(); 
		
		NumberXAxis xAxis = new NumberXAxis();
		xAxis.setTitle(new AxisTitle(xAxisTitle));
		xAxis.setStartOnTick(true);
		xAxis.setEndOnTick(true);
		xAxis.setShowLastLabel(true);
		LinkedHashSet<XAxis> xAxesSet = new LinkedHashSet<InvientChartsConfig.XAxis>();
		xAxesSet.add(xAxis);
		chartConfig.setXAxes(xAxesSet);

		NumberYAxis yAxis = new NumberYAxis();
		yAxis.setTitle(new AxisTitle(yAxisTitle));
		LinkedHashSet<YAxis> yAxesSet = new LinkedHashSet<InvientChartsConfig.YAxis>();
		yAxesSet.add(yAxis);
		chartConfig.setYAxes(yAxesSet);
		

		// add the new points - THIS IS WORKING AGAIN
		for (int i = 0; i < versionDates.size(); i++) {
			String versionDate = versionDates.get(i);
			List<double[]> versionValues = xAndYCoordinates.get(i);

			ScatterConfig versionScatterConfig = new ScatterConfig();
			XYSeries series = new XYSeries("Version " + (i + 1) + " - "
					+ versionDate, versionScatterConfig);
			series.setSeriesPoints(getPoints(series, versionValues));
			chart.addSeries(series);
		}
	}

As you can see, the removing and adding of points works perfectly fine, which I assume is because I’m working directly on the chart here, while I’m working on the chartConfig when I try to change the axes caption.

Could you please tell or show me how I can change the caption of the x- and y-Axis in an already existing chart (As described above)?

If you don’t understand something in my post/my question, please feel free to ask :slight_smile: Nothing is more frustrating than no answer.

Thanks a lot for every comment and thought you’re sharing with me

I’ve never tried to do this, so I don’t know (In our project, we build charts, then display them).

I suspect that changes to the config are not being updated to the browser - to find that out, I’d just be
reading the source code.

Basically, the Invient Charts plug in is great - but the authors (not me, nor anything to do with me!) appear to be very busy, and don’t have much time to support and maintain their plugin. It’s clear and well written, IMHO - you should be able to follow the logic through.

Sorry,

Charles.

Well, I am also building charts and then displaying them. But on some charts I would like to have a dropdown menu where the user can choose between different datatypes to compare with in that chart (since a normal scatterchart can only display two dimensions). And I thought, since removing and adding points works perfectly fine there must also be a possibility to change the names of the axis.

I figured out the axis
change
when you press f5 on your browser. So I implemented a Refresher (using the refresher addon), but this doesn’t work, perhaps it does different things than a f5 button press. I don’t know what to do from this point, it looks like a bugged behaviour for me, I guess I will just remove the whole chart and create a new one, although this isn’t a good solution in my eyes.

And, please believe me, some of us yet haven’t so much experience reading other ones sourcecodes, especially when some classes are a several thousand lines of code.That’s why I ask on a forum, because I tried a lot(!) to solve my problem, e.g. also trying to understand the sourcecode, but nothing seemed to work. That’s the job of a forum, right? Help others.

The invient charts plugin is really great, I said nothing against it. If it wasn’t I wouldn’t do so much with it since I found it two weeks ago.