dc.js icon indicating copy to clipboard operation
dc.js copied to clipboard

Round and xUnit are completely ignored in CompositeChart

Open dakujem opened this issue 3 years ago • 4 comments

I'm trying to do similar thing as in the "switching times" example, that is, to have a variable X-axis, but the two functions (most importantly the xUnits) are never even triggered

      const deb = () => {
        debugger
      }
      const chart = new dc.CompositeChart(this.$refs.chart);
      chart
        .height(500)

        .x(timeScale)

        .round(deb)
        .xUnits(deb)

Also, this is my time scale:

      // make a datetime value
      const dt = v => v instanceof DateTime ? v : DateTime.fromJSDate(v)
      const timeScale = d3scale.scaleTime().domain([
        dt(this.start).minus({days: 1}),
        dt(this.end)//.plus({days:1}),
      ])

I want to switch between day/week/month/year view, but this seems like a wrong way to go.

dakujem avatar Jan 15 '21 13:01 dakujem

Try setting them on the child chart.

It’s true, there is a lot of weirdness with the overlap in functionality between parent and child charts, but I’m my experience there is always a way to make it work. It sometimes takes an incomprehensible combination of setting on parent / child.

I’m not clear what problem you are having with the time scale, but it sounds like a separate issue or SO question.

gordonwoodhull avatar Jan 15 '21 14:01 gordonwoodhull

I assumed that the xUnit function would be called. I was setting d3.timeDays, d3.timeMonths, or d3.timeYears, but seeing the ticks on the x-axis did not change, I dropped the debugger in and it never even fired, the option is ignored. With the formatter on x-axis, I wanted to print names of months, the year or the week number or date depending on which particular grouping was set. Not sure if I am able to do this without xUnits working properly.

dakujem avatar Jan 15 '21 14:01 dakujem

Sorry I don't have time to work up an example atm, but I am confident that there is a way to get this working. There always is, but with composite charts it is often surprising what needs to be set on the composite vs the child charts.

I will try to respond later in the week if you're still having trouble.

gordonwoodhull avatar Jan 17 '21 14:01 gordonwoodhull

I think I'll work this out eventually :-)

Thank you Gordon. This can be closed, if its not a bug. I found out the xUnits is not called for line charts either. Considering the inheritance map, I may have been confused by the documentation itself.

dakujem avatar Jan 18 '21 10:01 dakujem