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

Trial weighted alpha values when layering data #6

Open
js1300 opened this issue Sep 23, 2020 · 2 comments
Open

Trial weighted alpha values when layering data #6

js1300 opened this issue Sep 23, 2020 · 2 comments

Comments

@js1300
Copy link
Contributor

js1300 commented Sep 23, 2020

For example, on a graph with 20 datasets and an alpha of 0.5:

1st drawn layer alpha = 0.5 * 1/20 =
Last drawn layer alpha = 0.5 * 20/20 = 0.5

The goal is to avoid a "brown, mushy" colour under the graph.

@js1300
Copy link
Contributor Author

js1300 commented Jan 19, 2021

As an alternative to this, I would like to trial filling the area under the graph with background colour immediately before filling it with the data colour. There are caveats, though:

  • the drawing loop will need to be split in to two loops (one for drawing the area under the lines, one for drawing the lines)
  • in addition to the point above, this splitting will need to happen for both the Y and U datasets
  • in addition to the two points above, all areas under the lines (Y and U) need to drawn before all lines (Y and U)
  • this needs to tested with backgrounds with an alpha value below one

@js1300
Copy link
Contributor Author

js1300 commented Jan 19, 2021

When a solution is in place, experiment with area under graph gradient drawing once more. Currently, the entire extent of the graph is used for creating the gradient stops. It would be better (and, in turn, may look better) if the individual dataset limits (scaled in the case of the U axis) were used.

    createGraphFill(colour, colourStop, alpha, extentY) {
        var graphFill = null;
        if (this.graphGradientHorizontal) {
            graphFill = this.backgroundContext.createLinearGradient(this.graphStartX, 0, this.graphEndX, 0);
        } else {
            graphFill = this.backgroundContext.createLinearGradient(0, extentY, 0, this.graphEndY);
        }
        graphFill.addColorStop(0, this.grapheneHelper.hex2rgba(colour, alpha));
        if (this.graphGradientColour) {
            graphFill.addColorStop(1, this.grapheneHelper.hex2rgba(colourStop, alpha));
        } else {
            graphFill.addColorStop(1, this.grapheneHelper.hex2rgba(colour, 0));
        }
        return graphFill;
    }

    drawAreaUnderGraph(dataset, colour, colourStop, scale) {
        var extentY = Math.max(...dataset) * scale;
        this.backgroundContext.fillStyle = this.createGraphFill(colour, colourStop, this.alphasUnderGraph, extentY);

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

1 participant