Comments (9)
Hello, thank you for your work. I am the person who requested to add a candle chart a few days ago. Now I know how to draw the main body of the candle chart, but I want to add moving average data (MA5、MA10). I found your smoothed line chart chart. I think this method draws a smooth curve
` private void drawSmoothLine(XYSeries<T> SERIES, boolean SHOW_POINTS) {
if (SERIES.isVisible()) {
double LOWER_BOUND_X = this.getLowerBoundX();
double LOWER_BOUND_Y = this.getLowerBoundY();
this.ctx.setLineWidth(SERIES.getStrokeWidth() > -1.0 ? SERIES.getStrokeWidth() : this.size * 0.0025);
this.ctx.setStroke(SERIES.getStroke());
this.ctx.setFill(Color.TRANSPARENT);
List<Point> points = new ArrayList(SERIES.getItems().size());
SERIES.getItems().forEach((item) -> {
points.add(new Point(item.getX(), item.getY(), item.isEmptyItem()));
});
Point[] interpolatedPoints = Helper.subdividePoints((Point[])points.toArray(new Point[0]), 24);
this.ctx.beginPath();
Point[] var9 = interpolatedPoints;
int var10 = interpolatedPoints.length;
for(int var11 = 0; var11 < var10; ++var11) {
Point p = var9[var11];
if (p.isEmpty()) {
this.ctx.moveTo((p.getX() - LOWER_BOUND_X) * this.scaleX, this.height - (p.getY() - LOWER_BOUND_Y) * this.scaleY);
} else {
this.ctx.lineTo((p.getX() - LOWER_BOUND_X) * this.scaleX, this.height - (p.getY() - LOWER_BOUND_Y) * this.scaleY);
}
}
this.ctx.stroke();
if (SHOW_POINTS) {
this.drawSymbols(SERIES);
}
}
}`
but I don't understand how he draws the curve. I try to draw it with beginpath(), moveto (x, y), lineto (x, y) and stroke(), But I can only get the line chart with sharp corners, so can you explain it,Or there are better suggestions for adding moving averages in the candle chart. Thank you!
from charts.
Understand, let me add something to the demo. Btw, do you have an example dataset that I can use?
from charts.
Thank you for your timely reply, but I originally intended to figure out how to draw and then read the data from the database, so I'm sorry I don't know how to provide you with the dataset...
And also i think there is a small bug in the CandleChart,please observe the picture,the item data both high and low are around 35, but the scale on the left is about 43
from charts.
Understand, let me add something to the demo. Btw, do you have an example dataset that I can use?
from charts.
I don't know how to send you a data set, nor what form you need, so I uploaded a data set you can download in my GitHub repository Dataset, which contains some data. Each row is:${s.name} ${s.date} ${s.low} ${s.open} ${s.close} ${s.high} ${s.MA5} ${s.MA10} ${s.MA20} ${s.MA60} ,I think you can understand the data. i dont know that data is right?
from charts.
Ok thx. The problem with the axis is related to the fact that I construct the chart manually, will fix that too.
from charts.
If you check out the latest commit from JDK17 branch you should now see your data incl. ma5, ma10, ma20 and ma60. Please let me know if that looks good to you...
from charts.
ok,the new CandleChart is very nice,That's what I need ,thank you very much!!
from charts.
Glad it works for you. Will create a new release of charts that contains the code later today.
from charts.
Related Issues (20)
- Do you have JavaScript Version for this? HOT 1
- README: Image for "Area, line, dot and ring chart" is broken
- Allow to configure the Gradle project without knowledge about credentials
- AreaHeatMap draw method speed up HOT 1
- More features in Parallel Coordinates HOT 1
- Where can I find tutorials to learn how to work with this library HOT 2
- MatrixBuilder is very slow HOT 3
- JFXCentral Badge
- NPE - 17.1.51 - TimeAxis HOT 1
- IndexOutOfBoundsException when sorting by clusters in ArcChart HOT 3
- renderToImage(w,h) HOT 6
- document how to build HOT 2
- Candle Chart Axis.java has one line missing in a constructor
- Add a method to add the quantiles in a timseseries graph HOT 13
- Can't build: what should ossrhUsername be? HOT 3
- Updating Axis range in LineChart HOT 12
- Heatmap's ColorMapping is not available HOT 1
- Axis for heatMap HOT 2
- HeatMap with solid color HOT 5
- Domain and Range markers HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from charts.