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

setting dimension titles manually #16

Closed
gile opened this Issue Jan 24, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@gile

gile commented Jan 24, 2013

I added a small feature to set the dimension titles manually (currently when using dimensions() with an array containing strings an error is received)

there are 4 new/modified lines (marked with '<== NEW' or '<== MOD')

d3.parcoords = function(config) {

  var __ = {
    data: [],
    dimensions: [],
    dimensionTitles: [],  //<== NEW
    types: {},
    brushed: false,
    mode: "default",
    rate: 10,
    width: 600,
    height: 300,
    margin: { top: 24, right: 0, bottom: 12, left: 0 },
    color: "#069",
    composite: "source-over",
    alpha: "0.7"
  };

.
.
.
pc.createAxes = function() {
    if (g) pc.removeAxes(); 

    // Add a group element for each dimension.
    g = pc.svg.selectAll(".dimension")
        .data(__.dimensions, function(d) { return d; })
      .enter().append("svg:g")
        .attr("class", "dimension")
        .attr("transform", function(d) { return "translate(" + xscale(d) + ")"; })

    // Add an axis and title.
    g.append("svg:g")
        .attr("class", "axis")
        .attr("transform", "translate(0,0)")
        .each(function(d) { d3.select(this).call(axis.scale(yscale[d])); })
      .append("svg:text")
        .attr({
          "text-anchor": "middle",
          "y": 0,
          "transform": "translate(0,-12)",
          "x": 0,
          "class": "label"
        })
        .text(function(d, i) {    // <== MOD
                 return __.dimensionTitles[i] || String(d);  // <== NEW
        })  //<== MOD

    flags.axes= true;
    return this;
  };
@syntagmatic

This comment has been minimized.

Show comment
Hide comment
@syntagmatic

syntagmatic Aug 21, 2013

Owner

Added this feature, although I used an object instead of array for dimensionTitles. This way you don't have to specify every one to override just a few.

http://syntagmatic.github.io/parallel-coordinates/examples/titles.html

Owner

syntagmatic commented Aug 21, 2013

Added this feature, although I used an object instead of array for dimensionTitles. This way you don't have to specify every one to override just a few.

http://syntagmatic.github.io/parallel-coordinates/examples/titles.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment