How to use the d3-axis.axisLeft function in d3-axis

To help you get started, we’ve selected a few d3-axis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pbeshai / d3-scale-interactive / src / ui / StatsHistogram.js View on Github external
const yScale = scaleLinear().range([innerHeight, 0]);

    // filter out infinite values
    const filteredData = data.filter(d => d < Infinity && d > -Infinity);

    const xExtent = extent(filteredData);
    xScale.domain(xExtent);
    this.xAxis.call(axisBottom(xScale).ticks(7));

    const bins = histogram()
      .domain(xScale.domain())
      .thresholds(xScale.ticks(20))(filteredData);

    yScale.domain([0, max(bins, d => d.length)]);
    this.yAxis.call(axisLeft(yScale).ticks(4));

    let bars = this.countRects.selectAll('.bar').data(bins);
    bars.exit().remove();
    const barsEnter = bars.enter().append('g').attr('class', 'bar');

    const sampleBin = bins[1] || bins[0]; // first one can be smaller so use second if available
    const barWidth = Math.max(1, xScale(sampleBin.x1) - xScale(sampleBin.x0) - 1);
    barsEnter
      .append('rect')
      .attr('x', 1)
      .attr('width', barWidth)
      .style('fill', '#0bb');

    bars = bars.merge(barsEnter)
      .attr('transform', d => `translate(${xScale(d.x0)}, ${yScale(d.length)})`)
      .each(function eachBar(d) {
github BigFatDog / parcoords-es / dist / parcoords.esm.js View on Github external
});
  }

  var eventTypes = ['render', 'resize', 'highlight', 'mark', 'brush', 'brushend', 'brushstart', 'axesreorder'].concat(keys(config));

  var events = dispatch.apply(_this$4, eventTypes),
      flags = {
    brushable: false,
    reorderable: false,
    axes: false,
    interactive: false,
    debug: false
  },
      xscale = scalePoint(),
      dragging = {},
      axis = axisLeft().ticks(5),
      ctx = {},
      canvas = {};

  var brush = {
    modes: {
      None: {
        install: function install(pc) {}, // Nothing to be done.
        uninstall: function uninstall(pc) {}, // Nothing to be done.
        selected: function selected() {
          return [];
        }, // Nothing to return
        brushState: function brushState() {
          return {};
        }
      }
    },
github edgarordonez / d3-stencil / src / components / line-chart / line-chart.tsx View on Github external
this.root
        .append('g')
        .attr('class', 'grid')
        .call(
          axisBottom(this.x)
            .tickSize(this.height)
            .tickFormat(() => ''),
        );
    }

    if (this.graphDataMerged.lineChart.axis.y.gridVisible) {
      this.root
        .append('g')
        .attr('class', 'grid')
        .call(
          axisLeft(this.y)
            .tickSize(-this.width)
            .tickFormat(() => ''),
        );
    }
  }
github khartec / waltz / waltz-ng / client / playpen / 3 / asset-cost-graph.js View on Github external
function mkAxis(scale, scaleType = 'log') {
    const axis = axisLeft()
        .scale(scale);

    if (scaleType === 'log') {
        axis.ticks(5)
            .tickFormat(currencyLogFormat);
    }

    if (scaleType === 'linear') {
        axis.ticks(5)
            .tickFormat(currencyFormat);
    }
    return axis;
}
github Vizzuality / TRASE-frontend / scripts / components / profiles / scatterplot.component.js View on Github external
.attr('class', 'axis axis--x')
      .attr('transform', 'translate(0,' + this.height + ')')
      .call(this.xAxis);

    this.svg.append('g')
      .attr('class', 'axis axis-line')
      .attr('transform', 'translate(0,' + this.height + ')')
      .call(d3_axis_bottom(this.x).ticks(0).tickSizeOuter(0));

    this.svg.append('g')
      .attr('class', 'axis axis--y')
      .call(this.yAxis);

    this.svg.append('g')
      .attr('class', 'axis axis-line')
      .call(d3_axis_left(this.y).ticks(0).tickSizeOuter(0));

    this.circles = this.svg.selectAll('circle')
      .data(this._getFormatedData(0))
      .enter()
      .append('circle')
      .attr('class', d => this._getCircleClass(d))
      .attr('r', 5)
      .attr('cx', d => this.x(d.x))
      .attr('cy', d => this.y(d.y));

    if (this.showTooltipCallback !== undefined) {
      this.circles.on('mousemove', function(d) {
        const selectedSwitcher = document.querySelector('.js-scatterplot-switcher-item.selected span');

        this.showTooltipCallback(
          d,
github paulhoughton / mortgage / src / components / Chart.js View on Github external
drawAxis() {
    this.xAxis.call(axisBottom().scale(x).ticks(Math.min(this.props.data.length, 30)));
    this.yAxis.call(axisLeft().scale(y));
  }
};
github khartec / waltz / waltz-ng / client / entity-statistics / components / history-chart / entity-statistic-history-chart.js View on Github external
function drawYAxis(section, scale) {
    const yAxis = axisLeft()
        .ticks(5)
        .scale(scale);

    section
        .call(yAxis);
}
github datencia / d3js-angular-examples / src / app / 04_stacked_bar_chart / stacked-bar-chart.component.ts View on Github external
.selectAll('rect')
            .data(d => d)
            .enter().append('rect')
            .attr('x', d => this.x(d.data.State))
            .attr('y', d => this.y(d[1]))
            .attr('height', d => this.y(d[0]) - this.y(d[1]))
            .attr('width', this.x.bandwidth());

        this.g.append('g')
            .attr('class', 'axis')
            .attr('transform', 'translate(0,' + this.height + ')')
            .call(d3Axis.axisBottom(this.x));

        this.g.append('g')
            .attr('class', 'axis')
            .call(d3Axis.axisLeft(this.y).ticks(null, 's'))
            .append('text')
            .attr('x', 2)
            .attr('y', this.y(this.y.ticks().pop()) + 0.5)
            .attr('dy', '0.32em')
            .attr('fill', '#000')
            .attr('font-weight', 'bold')
            .attr('text-anchor', 'start')
            .text('Population');

        let legend = this.g.append('g')
            .attr('font-family', 'sans-serif')
            .attr('font-size', 10)
            .attr('text-anchor', 'end')
            .selectAll('g')
            .data(keys.slice().reverse())
            .enter().append('g')
github khartec / waltz / waltz-ng / client / complexity / components / chart / complexity-bar-chart.js View on Github external
function drawYAxis(yScale, container) {
    const yAxis = axisLeft(yScale);

    container.append('g')
        .attr('transform', `translate(${dimensions.margin.left}, ${dimensions.margin.top})`)
        .call(yAxis);
}

d3-axis

Displays automatic reference lines for scales.

ISC
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis