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

.title not working on composite of line charts #554

Closed
xavier-d opened this issue Mar 31, 2014 · 18 comments
Closed

.title not working on composite of line charts #554

xavier-d opened this issue Mar 31, 2014 · 18 comments
Labels
Milestone

Comments

@xavier-d
Copy link

According to the example provided by the documentation https://github.com/dc-js/dc.js/blob/master/web/docs/api-latest.md#composesubchartarray title method should work on Composite Chart.

I've updated the example provided:
https://github.com/dc-js/dc.js/blob/master/web/examples/composite.html

.compose([
dc.lineChart(composite)
.dimension(dim)
.colors('red')
.group(grp1, "Top Line")
.dashStyle([2,2])
.title(function(d) { return 'Custom function prints this\n' + d.value; }),
dc.lineChart(composite)
.dimension(dim)
.colors('blue')
.group(grp2, "Bottom Line")
.dashStyle([5,5])
.title(function(d) { return 'Custom function prints this\n' + d.value; })
])

and it is not working

A bug ? A limitation of composite chart ? If yes the documentation should be updated

@jxstanford
Copy link

I ran into this as well. A default title is generated with the key and value whether you provide a title or not. I also tried to put the title directly in the composite chart with the same result.

@xavier-d
Copy link
Author

xavier-d commented Apr 7, 2014

There is also an issue with the Y axis where the domain is set to [0,10].

@buntyrathod
Copy link

I am also facing similar issue. Is there any workaround for this?

@gordonwoodhull gordonwoodhull added this to the v2.0 milestone Jun 5, 2014
@tttp
Copy link
Contributor

tttp commented Jun 6, 2014

I had a similar problem on a barchart, the workaround I found was to replace the title text in a postrender function. You get a bit of flickering unfortunately.

@gordonwoodhull
Copy link
Contributor

There is also an issue with the Y axis where the domain is set to [0,10].

@xavier-d, could you elaborate on this and file another bug?

@buntyrathod
Copy link

@tttp : Thanks a lot.. ! It worked perfectly..

@jeenu6
Copy link

jeenu6 commented Jun 19, 2014

I have a better solution.
Just set parentChart.shareTitle(false) in main composite chart, and put individual childChart.title( function(d){ return "My custom title";}) in each chart that is added. Working perfectly in LineChart groups

-> By default .shareTitle is true which is causing all the troubles.

@xavier-d
Copy link
Author

xavier-d commented Oct 1, 2014

[digging up an old issue]
By adding .shareTitle to false the .title function is called for the children but it seems to that the result of the method is evaluated at the chart creation and not at run time. And so the display is good if you don't do any filter, but if you activate a filter the output is not updated.
By adding a breakpoint on the function, you will reproduce the problem. The script is stopping before the display and never goes back on it
Am I the only one having this problem ?

@gordonwoodhull
Copy link
Contributor

Thanks @xavier-d, these issues are old but not forgotten.

If you can create a fiddle (or jasmine spec) which reproduces the problem, that will get this much closer to fixed. I may be naive but I still hope to close all bugs marked milestone 2.0 in the next month, and release 2.0.

@gordonwoodhull
Copy link
Contributor

Ooops, I see you have specified enough to repro this. I will give it a try soon.

I am very surprised if the title function is only evaluated once - the whole idea of specifying a function should be that it's evaluated whenever the data changes, but it is a common d3 error to attach attributes to create/enter when they should be on update.

@xavier-d
Copy link
Author

xavier-d commented Oct 1, 2014

after a (really) quick look at the code

_chart.compose = function (charts) {
_children = charts;
_children.forEach(function (child) {
child.height(_chart.height());
child.width(_chart.width());
child.margins(_chart.margins());

       if (_shareTitle) {
           child.title(_chart.title());
       }

       child.options(_childOptions);
   });
   return _chart;

};

I'm wondering if the _chart.title should not be set to all the child.title (as they have been defined) if the shareTitle is set to false

My 2cts comment

@RickWalker
Copy link

I get this problem too, on series charts - titles are fine when I create the chart, but don't update when I filter.

@RickWalker
Copy link

Actually, turns out I was on 2.0.0-alpha1 and it's fine on 2.1.0-dev. I'll make more effort to stay up to date!

@Kylir
Copy link

Kylir commented May 12, 2015

Thanks @jeenu6 ! I had the same issue and set chart.shareTitle(false). I'm using the master branch.

@DougMair
Copy link

I had the same problem and found a solution.

Make sure to call .shareTitle(false) BEFORE calling the .compose( ...) method.

@grugknuckle
Copy link

grugknuckle commented May 10, 2018

So this bug has been open for 3 years now. Maybe we should upgrade it to a feature by codifying this behavior into the documentation of composite charts. That way, developers will know right away that they should call the .compose(...) method of the composite chart last, instead of seeing this bug in their code and have to google their way to this thread.

just my 2 cents.

EDIT:
bug

@gordonwoodhull
Copy link
Contributor

I agree, we should document it. I wouldn't upgrade a bug to a feature, though. Looks like we'd need to document this for width, height, margins, and childOptions as well, unfortunately.

Action items for this issue:

  • Fix compose not to immediately replicate settings from parent to children (this should happen in render/redraw instead)
  • Figure out whether .shareTitle(true) ever works, and how, or fix it so that it has a better chance of working

@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants