Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box plot support #303

Closed
navykoo opened this issue Sep 28, 2022 · 52 comments
Closed

Box plot support #303

navykoo opened this issue Sep 28, 2022 · 52 comments

Comments

@navykoo
Copy link

navykoo commented Sep 28, 2022

Hey, I wanted to check if there is any plan of swtchart to support box plot (or called as box and wirsk plot)? If no, can I do some customization development on swtchart for achieve the goal? Any advice will be appreciated.

@eselmeister
Copy link
Contributor

@navykoo Thanks for your request. Could you support some sketches, screenshots of the plots you'd like to have? SWTChart is an open source project. I could also show you how to setup the IDE to make improvements on the library. Help is always appreciated.

@jackybian
Copy link
Contributor

@eselmeister Hi, I am navykoo's colleague. I'm looking for such feature support as well. Here are some websits about BoxPlot.
1,https://en.wikipedia.org/wiki/Box_plot
2,https://echarts.apache.org/examples/en/editor.html?c=boxplot-light-velocity
Any suggestion will be appreciated.

@eselmeister
Copy link
Contributor

@jackybian Great, I could guide you how to setup SWTChart and how to implement the Box plot support.

@eselmeister
Copy link
Contributor

Just let me know, if and when I shall give you assistance.

@jackybian
Copy link
Contributor

@jackybian Great, I could guide you how to setup SWTChart and how to implement the Box plot support.

Thank you very much. I'm a J2EE developer and I am not familiar with Swtchart and RCP.But i can try.
Can you tell me how to do.
My eclipse version is Eclipse IDE for RCP and RAP Developers - 2022-06.

@eselmeister
Copy link
Contributor

@jackybian Here's a short description how to setup the system:
https://github.com/eclipse/swtchart/blob/develop/org.eclipse.swtchart.cbi/Build.txt

The simplest way to have a look if everything runs fine is to start the following chart as Java application:
https://github.com/eclipse/swtchart/blob/develop/org.eclipse.swtchart.extensions.examples/src/org/eclipse/swtchart/extensions/examples/charts/DemoChart.java

@jackybian
Copy link
Contributor

Thank you.
Due to unfamiliarity with Eclipse and RCPTT, I can't run the demo.
Can you tell how to run it with RCPTT

@eselmeister
Copy link
Contributor

eselmeister commented Nov 7, 2022 via email

@jackybian
Copy link
Contributor

Thank you. I followed your steps and encountered a problem.
As shown in the screenshot, I can't set Build Path and don't know the reason.
pic

@eselmeister
Copy link
Contributor

eselmeister commented Nov 8, 2022 via email

@jackybian
Copy link
Contributor

Thank you.
I run the demo in another project which imports swtchar jars. But i did not know how to run the demo in Swtchar Project. I've already set target platform as Active Target Platform.
Can you tell me how to prepare to implement the Box plot. I need some preparation.

@eselmeister
Copy link
Contributor

eselmeister commented Nov 8, 2022 via email

@jackybian
Copy link
Contributor

%X0_85H9)}}Y)} G)0`9IVD
I build a new project and import 2 swtchart jars.

@eselmeister
Copy link
Contributor

@jackybian Please first setup the IDE as mentioned in the build instruction. You need "Eclipse IDE for RCP and RAP Developers" and then run the demo chart as a Java application.

Screenshot from 2022-11-08 08-24-40

@jackybian
Copy link
Contributor

pic
Thank you for your picture. I finished. I took Eclipse as an Idea IDE and selected wrong root directory.

@jackybian
Copy link
Contributor

@eselmeister Can you give me some suggestions about implementing Box Plot feature

@eselmeister
Copy link
Contributor

@jackybian Sure, do you have representative data (x,y) at hand, which we could use to implement the box plot support?

@jackybian
Copy link
Contributor

data X {trace0, trace1}
data Y {{741.5,752.1,741.4,729.1,767.1,766.1,756.3,745.4,735.6,741,754.2,758.6,753.9,742.6,729.6,723.3,724.6,748.5,754.2,749.2,734,727.6,718.1,729.2,766.5,772.5,765.5,766.5,772.5,765.5 },{743.6,753.9,745.1,731.6,768.2,767.3,758.7,746.6,737.9,743.6,756.6,760.3,755.2,743.6,731.9,725.5,727.4,751.8,756.2,752.8,737.8,731.2,724.9,732.4,770.7,775.7,767.3,745.4,
PIC
738.4,736}}
I hope the points can show in the box and they can hide.

@eselmeister
Copy link
Contributor

@jackybian Great, thanks. Give me 2 days to think about it. I'll then guide you how to best implement it.

@jackybian
Copy link
Contributor

Thank you and wait for your good news.

@eselmeister
Copy link
Contributor

@jackybian IMHO, we can implement it by extending the ScatterChart:
org.eclipse.swtchart.extensions.scattercharts.ScatterChart

The functionality of the scatter chart is used and additionally, a IBaseChartPaintListener is added to draw the boxes based on the live calculated statistics. Let me prepare it for your later today.

@jackybian
Copy link
Contributor

@eselmeister Thank you. I've had a lot of high-priority work to do in the last few days. After the work is done, I will try to implement it.

eselmeister added a commit that referenced this issue Nov 12, 2022
The BoxPlotChart is a subtype of ScatterChart. It contains a custom
paint listener to draw the whisker box.
@eselmeister
Copy link
Contributor

@jackybian Yep, no hurry. I have create a demo chart, which easily can be executed as a Java application:
org.eclipse.swtchart.extensions.examples.charts.DemoBoxPlotChart

Screenshot from 2022-11-12 20-56-54

The magic needs to implemented here:
org.eclipse.swtchart.extensions.marker.BoxPlotMarker

Additionally have a look at here:
https://github.com/eclipse/swtchart/wiki/Documentation#error-bar
https://en.wikipedia.org/wiki/Box_plot

@jackybian
Copy link
Contributor

1668436889280
I pull the source code and run the DemoBoxPlotChart. The console show the message as shown in the picture.

@eselmeister
Copy link
Contributor

Could you please have a look at your workspace and check that the file BoxPlotSeries1 is available.
209d992#diff-9d1fad6b59d9ad8317eb3ac603d3d9a20465abf92550afec302714c3452b2281

@jackybian
Copy link
Contributor

1668437853492
I can see the scatter, but the FileNotFoundException is still there

@eselmeister
Copy link
Contributor

You can ignore the FileNotFoundException. It's from the preference store, which is used by the legend.
Have a look at the BoxPlotMarker to implement drawing the statistical values:
https://github.com/eclipse/swtchart/blob/develop/org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/marker/BoxPlotMarker.java

@jackybian
Copy link
Contributor

image
@eselmeister I didn't use the error bar. The pic doesn't looks good.
Can I modify X axis from number to string.

@eselmeister
Copy link
Contributor

@jackybian Your custom paint listener boxes look good. I assume you'd like to have something similar like displayed in category, am I right?

https://github.com/eclipse/swtchart/wiki/Documentation#category

@jackybian
Copy link
Contributor

	IPrimaryAxisSettings primaryAxisSettingsX = chartSettings.getPrimaryAxisSettingsX();
	primaryAxisSettingsX.setVisible(true);
	primaryAxisSettingsX.setGridLineStyle(LineStyle.NONE);
	Axis xAxis = (Axis)baseChart.getAxisSet().getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
        xAxis.enableCategory(true);
	xAxis.setCategorySeries(new String[]{"Trace1", "Trace2"});

image
The boxes are not right. I don't know why.

@eselmeister
Copy link
Contributor

It's moving into the right direction. There seems to be something going wrong when plotting the blue and red data points. I would recommend to debug the plotting of the data series.

@jackybian
Copy link
Contributor

The data series didn't change when I debugged.
In addition to this , I hope I can zoom in one box(Trace2) and the X-Axis can only show Trace2

@eselmeister
Copy link
Contributor

If you're getting any further, please create a pull request, so that I can review your code. Have you signed the Eclipse Contributors Agreement already?

https://github.com/eclipse/swtchart/blob/develop/CONTRIBUTING.md

@jackybian
Copy link
Contributor

Ok, The quartile function is not accurate. If the category can show accurately, I will restructure the code and try to push the code to SWTChart Project.
BoxPlotMarker.zip

Axis xAxis = (Axis)baseChart.getAxisSet().getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
xAxis.enableCategory(true);
xAxis.setCategorySeries(new String[]{"Trace 1", "Trace 2"});
1669123498212
Also, I want to study your code. Is there any documentation about code?

@eselmeister
Copy link
Contributor

I would recommend to use the IPrimaryAxisSettings to modify the category etc.. When running applySettings(...), the settings are transferred to the SWTChart base chart.

We have a documentation here:
https://github.com/eclipse/swtchart/wiki/Documentation

Otherwise, I'll guide you.

@jackybian
Copy link
Contributor

1
2
I use the IPrimaryAxisSettings to modify the category when running applySettings.
But It does not work.

@eselmeister
Copy link
Contributor

OK, let me inspect it. Can you create a PR?

@jackybian
Copy link
Contributor

PR? PropertiesResources?

@eselmeister
Copy link
Contributor

Pull Request :-)

@jackybian
Copy link
Contributor

I've already signed ECA.
Now I can't create a PR and the GitHub UI shows that I don't have write access to Eclipse/Swtchart.

@eselmeister
Copy link
Contributor

Yep, it's only allowed for committers to write into the repository. Hence, we use PRs to merge/review request from externals. Have a look at the GitHub documentation on how to create a PR:

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

@jackybian
Copy link
Contributor

image

@eselmeister
Copy link
Contributor

It seems to be in your fork. I can't see any PRs here:
https://github.com/eclipse/swtchart/pulls

@jackybian
Copy link
Contributor

2N(7M_B6YJ W9LC)@OM M
Is that right?

@eselmeister
Copy link
Contributor

Thanks for the PR. I tracked down the problem. The category series are currently displayed well with bar charts:
https://github.com/eclipse/swtchart/wiki/Documentation#category

With scatter data, it doesn't plot the data correctly. Let me find a solution for that problem.

Screenshot from 2022-11-25 08-41-11

@jackybian
Copy link
Contributor

@eselmeister Hi, when can it plot the data correctly?

@jackybian
Copy link
Contributor

I am waiting for good news:)

@eselmeister
Copy link
Contributor

@jackybian Me too. I have a tight schedule, but let me inspect it as soon as possible.

@yoshitaka1008
Copy link

  • The desired box plot here has own X axis scale within each box, right?
  • The existing base chart doesn’t support drawing plot symbols in that way, so if we take the approach to implement it with BoxPlotMarker, the marker would have to draw not only boxes but also plot symbols with dedicated X scale.
  • The approach can be a bit tricky since we have to disable drawing plot symbols with base chart somehow.
  • A possible option would be for BoxPlotChart to internally set the point symbol type to NONE and keep original symbol types so that BoxPlotMarker can draw symbols with given types, which sounds not nice but it may work. (see attached experimental changes)
    experimental_changes.patch

@eselmeister
Copy link
Contributor

@yoshitaka1008 Excellent, thanks a lot. I have merged it.

Screenshot from 2022-12-23 12-09-21

@jackybian
Copy link
Contributor

@eselmeister Hi, which branch did you merge? And how to release the local jar which contains Boxchart

@eselmeister
Copy link
Contributor

It has been pushed on the branch "develop". You can either

A) download the integration build jars here:
https://download.eclipse.org/swtchart/integration/develop/repository/

B) or build the branch "develop" locally via:
mvn -f org.eclipse.swtchart.cbi/pom.xml clean install

Screenshot from 2023-01-06 07-59-23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants