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

need to call margins before compose for child charts to inherit #1003

Closed
rand0m86 opened this issue Sep 4, 2015 · 2 comments
Closed

need to call margins before compose for child charts to inherit #1003

rand0m86 opened this issue Sep 4, 2015 · 2 comments
Milestone

Comments

@rand0m86
Copy link

rand0m86 commented Sep 4, 2015

I have simple example of using composite chart with currently latest dc js version (18). Anyway if I try to add any margin to chart definition I get chart lines shifted.

myChart
    .width(500)
    .height(200)
    //.margins({top: 10, right: 50, bottom: 30, left: 40})
    .dimension(timeDimension)
    .compose([
        dc.lineChart(myChart)
            .group(group1, "G1"),
        dc.lineChart(myChart)
            .group(group2, "G2")
            .useRightYAxis(true)
            .ordinalColors(["#ff7f0e"])
    ])
    .x(d3.time.scale().domain([minDate, maxDate]))
    .xUnits(d3.time.weeks)
    .elasticX(true)
    .elasticY(true)
    //.margins({top: 10, right: 50, bottom: 30, left: 40})
    .legend(dc.legend().x(60).y(10).itemHeight(13).gap(5))
    .on("renderlet", rotateTimeAxisLabels);

UPDATE Depends on position of .margins(...) call. If it is at the beginning then everything is ok. If it is at the end of config - I get a bug with shifting.

You can play a little bit with method call position, it depends.

@gordonwoodhull
Copy link
Contributor

Thanks @rand0m86, indeed there is some trickiness about when attributes get copied down from the composite chart to its children. The margins only get copied down in compose itself. Why some attributes get copied later, during generateG, I don't think anyone fully understands.

I'm going to keep this open as a documentation issue - docs should list the current behavior, if not explain it.

@gordonwoodhull gordonwoodhull added this to the v2.0 milestone Oct 6, 2015
@gordonwoodhull gordonwoodhull changed the title Margins for composite chart cause child charts to be shifted Margins inheritance from composite chart to children is unclear Oct 6, 2015
@gordonwoodhull gordonwoodhull changed the title Margins inheritance from composite chart to children is unclear need to call margins before compose for child charts to inherit Oct 3, 2019
@gordonwoodhull
Copy link
Contributor

Fixed by #1365 in 3.1.5

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

Successfully merging a pull request may close this issue.

2 participants