Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.
This repository was archived by the owner on Sep 17, 2021. It is now read-only.

gridColor applied to wrong axis #179

Closed
@ixje

Description

@ixje
  • I have searched for existing issues
  • I have provided detailed instructions that can reproduce the issue (including code and data necessary)

The newly added gridColor option (see #121) has the axis swapped. Specifying a gridColor on the x-axis options will cause it to draw vertical lines in that color, and for the y-axis options it draws horizontal lines.

Example:

            axisX: {
                gridColor: 'red',
                tickColor: 'red',
                ...
            }
            axisY: {
                gridColor: 'green',
                tickColor: 'green',
                ...
            }

produces the following:
screen shot 2017-08-10 at 10 57 10

I'm new to the whole library, but as far I think it works is that the lines are drawn from the tick positions and then up (for x-axis) or right (for y-axis) to create the gridlines. With that assumption I found the quickest solution to be just swapping the values around to the correct axis. Each chart seems to start with
let options = new Options(this.props)

So I have a quick fix in the constructor of the Options class that I can PR for, if

  • we agree this is actually an issue and not intended behaviour
  • the below suggestion is the right place to solve the problem (that depends if my above understanding about how the grid lines are drawn was correct)

In the Options class:

       this.options = props.options || {}
        if (this.options.axisX && this.options.axisY) {
            // get axis color if any
            let yGridColor = this.options.axisX.gridColor || null
            let xGridColor = this.options.axisY.gridColor || null
            // swap to correct axis
            this.options.axisX.gridColor = xGridColor
            this.options.axisY.gridColor = yGridColor
        }

This simply swaps the gridColor for the axises before the charts start using them. If the gridColor key is not specified it will use the default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions