Giter Site home page Giter Site logo

How about charts HOT 9 CLOSED

hansolo avatar hansolo commented on August 17, 2024
How

from charts.

Comments (9)

Xiaobaishushu25 avatar Xiaobaishushu25 commented on August 17, 2024

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.

HanSolo avatar HanSolo commented on August 17, 2024

Understand, let me add something to the demo. Btw, do you have an example dataset that I can use?

from charts.

Xiaobaishushu25 avatar Xiaobaishushu25 commented on August 17, 2024

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

image

from charts.

HanSolo avatar HanSolo commented on August 17, 2024

Understand, let me add something to the demo. Btw, do you have an example dataset that I can use?

from charts.

Xiaobaishushu25 avatar Xiaobaishushu25 commented on August 17, 2024

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.

HanSolo avatar HanSolo commented on August 17, 2024

Ok thx. The problem with the axis is related to the fact that I construct the chart manually, will fix that too.

from charts.

HanSolo avatar HanSolo commented on August 17, 2024

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.

Xiaobaishushu25 avatar Xiaobaishushu25 commented on August 17, 2024

ok,the new CandleChart is very nice,That's what I need ,thank you very much!!

from charts.

HanSolo avatar HanSolo commented on August 17, 2024

Glad it works for you. Will create a new release of charts that contains the code later today.

from charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.