eclipse / swtchart

Eclipse Public License 2.0
43 stars 41 forks source link

Box plot support #303

Closed navykoo closed 1 year ago

navykoo commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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

eselmeister commented 1 year ago

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

jackybian commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

You don't need RCPTT. You can run it directly from within the Eclipse IDE, when you select "Run as Java application...".

On 07.11.22 15:26, jackybian wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/eclipse/swtchart/issues/303#issuecomment-1305694840, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFHUT7ZQQHL4XNHN5FUSRLWHEGP5ANCNFSM6AAAAAAQXOIEX4. You are receiving this because you were mentioned.Message ID: @.***>

--

OpenChrom - the open source alternative for chromatography / mass spectrometry
Dr. Philip Wenig » Founder ***@***.***  »http://www.openchrom.net
jackybian commented 1 year ago

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 commented 1 year ago

You don't need to set the build path. Open the following target platform in the editor and "Set as Active Target Platform": org.eclipse.swtchart.targetplatform/org.eclipse.swtchart.targetplatform.target

On 08.11.22 03:04, jackybian wrote:

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 https://user-images.githubusercontent.com/11855467/200456512-994500de-8b68-4158-8111-943f976ad9c8.jpg

— Reply to this email directly, view it on GitHub https://github.com/eclipse/swtchart/issues/303#issuecomment-1306510214, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFHUT6UYNVWSTVDHUWVY5LWHGYKFANCNFSM6AAAAAAQXOIEX4. You are receiving this because you were mentioned.Message ID: @.***>

--

OpenChrom - the open source alternative for chromatography / mass spectrometry
Dr. Philip Wenig » Founder ***@***.***  »http://www.openchrom.net
jackybian commented 1 year ago

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 commented 1 year ago

Are you able to run the demo chart from within your IDE?

On 08.11.22 07:10, jackybian wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/eclipse/swtchart/issues/303#issuecomment-1306684622, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFHUTZHRAHQKYSNX5LB6ODWHHVGJANCNFSM6AAAAAAQXOIEX4. You are receiving this because you were mentioned.Message ID: @.***>

--

OpenChrom - the open source alternative for chromatography / mass spectrometry
Dr. Philip Wenig » Founder ***@***.***  »http://www.openchrom.net
jackybian commented 1 year ago

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

eselmeister commented 1 year ago

@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 commented 1 year ago

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

jackybian commented 1 year ago

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

eselmeister commented 1 year ago

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

jackybian commented 1 year ago

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 commented 1 year ago

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

jackybian commented 1 year ago

Thank you and wait for your good news.

eselmeister commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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

eselmeister commented 1 year ago

Could you please have a look at your workspace and check that the file BoxPlotSeries1 is available. https://github.com/eclipse/swtchart/commit/209d9925089f440d3be965060cedfab431299f56#diff-9d1fad6b59d9ad8317eb3ac603d3d9a20465abf92550afec302714c3452b2281

jackybian commented 1 year ago

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

eselmeister commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago
    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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

eselmeister commented 1 year ago

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

jackybian commented 1 year ago

PR? PropertiesResources?

eselmeister commented 1 year ago

Pull Request :-)

jackybian commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

image

eselmeister commented 1 year ago

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

jackybian commented 1 year ago

2N(7M_B`6YJ W`9LC)@OM M Is that right?

eselmeister commented 1 year ago

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 commented 1 year ago

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

jackybian commented 1 year ago

I am waiting for good news:)

eselmeister commented 1 year ago

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

yoshitaka1008 commented 1 year ago
eselmeister commented 1 year ago

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

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