Skip to content
CityAM
Main navigation
  • News
    • News
      • Latest Business News
      • Economics
      • Politics
      • Tech
      • Banking
      • FTSE 100 Live
      • Retail
      • Insurance
      • Legal
      • Property
      • Transport
      • Markets
    • From our partners
      • AON
      • Bayes Business School
      • Canada BIDs
      • Central London Alliance CIC
      • Destination City
      • Halkin
      • Olympia
      • Inside Saudi
      • Tottenham Hotspur Stadium
      • Santander X
      • YEAR SIX Dividend
    • Featured

      Regulator wins decade-long pricing tussle with Pfizer

      Hikma reported a jump in profit for 2024

      Submit a story

      Tell us your story.

      Submit
  • Opinion
  • Sport
    • Latest Sports News
      • Sport
      • Sport Business
    • From our partners
      • The Morning Briefing: SBS x CityAM
      • Aramco Team Series
      • LIV Golf
    • Featured

      Arsenal launch £7k-a-head VIP package with seats behind dugout and player meeting

      High-resolution image of a business meeting with diverse professionals discussing a project in a modern office setting

      Submit a story

      Tell us your story.

      Submit
  • Life&Style
    • Life&Style
      • Life&Style
      • Toast the City Awards
      • The Magazine
      • Travel
      • Culture
      • Motoring
      • Wellness
      • The RED BULLETiN
      • Do it with Shared Ownership
      • Media Speak Hub
    • Featured

      SET Ceramics nominated for Best Newcomer Toast award

      Elegant ceramic set featuring assorted bowls and plates with intricate designs, showcasing artisanal craftsmanship

      Submit a story

      Tell us your story.

      Submit
  • Investec
  • Events
  • Latest Paper
Thursday 21 May 2015 1:04 pm

Steam test

By: Billy Ehrenberg

Add as a preferred source on Google

 

chart("https://cityam.go-vip.net/wp-content/uploads/2015/05/steamin-555e1069cd273.csv", "blue");

var datearray = []; var colorrange = [];

function chart(csvpath, color) {

if (color == "blue") { colorrange = ["#045A8D", "#2B8CBE", "#74A9CF", "#A6BDDB", "#D0D1E6", "#F1EEF6"]; } else if (color == "pink") { colorrange = ["#980043", "#DD1C77", "#DF65B0", "#C994C7", "#D4B9DA", "#F1EEF6"]; } else if (color == "orange") { colorrange = ["#B30000", "#E34A33", "#FC8D59", "#FDBB84", "#FDD49E", "#FEF0D9"]; } strokecolor = colorrange[0];

var format = d3.time.format("%m/%d/%Y"); //%m/%d/%y

var margin = {top: 20, right: 40, bottom: 20, left: 40}; var width = 840; var height = 400;

var tooltip = d3.select("#chartHouseBuilding") .append("div") .attr("class", "toolTip");

var x = d3.time.scale() .range([margin.left, width-margin.right]);

var y = d3.scale.linear() .range([height - margin.top - margin.bottom, 0]);

var z = d3.scale.ordinal() .range(colorrange);

var xAxis = d3.svg.axis() .scale(x) .orient("bottom") .ticks(5);

var yAxis = d3.svg.axis() .scale(y) .tickFormat(d3.format("s"));

var yAxisr = d3.svg.axis() .scale(y) .tickFormat(d3.format("s"));

var stack = d3.layout.stack() .offset("silhouette") .values(function(d) { return d.values; }) .x(function(d) { return d.date; }) .y(function(d) { return d.value; });

var nest = d3.nest() .key(function(d) { return d.key; });

var area = d3.svg.area() .interpolate("cardinal") .x(function(d) { return x(d.date); }) .y0(function(d) { return y(d.y0); }) .y1(function(d) { return y(d.y0 + d.y); });

var svg = d3.select('#' + chart_id) .append('svg:svg') .attr('width', width) .attr('height', height) .attr('viewBox', '0 0 ' + width + ' ' + height ) .attr('perserveAspectRatio', 'xMinYMid') .attr('id', chart_id + '-chart') .attr('class', chart_id + '-chart');

var graph = d3.csv(csvpath, function(data) { data.forEach(function(d) { d.date = format.parse(d.date); d.value = +d.value; });

var layers = stack(nest.entries(data));

x.domain(d3.extent(data, function(d) { return d.date; })); y.domain([0, d3.max(data, function(d) { return d.y0 + d.y; })]);

svg.selectAll(".layer") .data(layers) .enter().append("path") .attr("class", "layer") .attr("d", function(d) { return area(d.values); }) .style("fill", function(d, i) { return z(i); });

svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + (height-margin.bottom-margin.top) + ")") .call(xAxis);

svg.append("g") .attr("class", "y axis axisRight") .attr("transform", "translate(" + (width-margin.right) + ", 0)") .call(yAxis.orient("right"));

svg.append("g") .attr("class", "y axis") .attr("transform", "translate(" + margin.left + ", 0)") .call(yAxis.orient("left"));

svg.selectAll(".layer") .attr("opacity", 1) .on("mouseover", function(d, i) { svg.selectAll(".layer").transition() .duration(250) .attr("opacity", function(d, ni) { return ni === i ? 1 : 0.6; })})

.on("mousemove", function(d, i) { mousex = d3.mouse(this); mousex = mousex[0]; var invertedx = x.invert(mousex); invertedx = invertedx.getYear();

var selected = (d.values);

for (var k = 0; k " + theYear + "
" + key1 + ": " + proFormat(pro1) + "
" + key2 + ": " + proFormat(pro2) + "
" + key3 + ": " + proFormat(pro3) + "

"; //var pro = d.values[mousedate].value;

//var proOutput = proFormat(pro);

d3.select(this) .classed("hover", true) .attr("stroke", strokecolor) .attr("stroke-width", "0.5px"), tooltip.html( webString ).style("display", "block");

}) .on("mouseout", function(d, i) { svg.selectAll(".layer") .transition() .duration(250) .attr("opacity", "1"); d3.select(this) .classed("hover", false) .attr("stroke-width", "0px"), tooltip.html( "

" + d.key + "

" ).style("display", "none"); })

var vertical = d3.select("#chartHouseBuilding") .append("div") .attr("class", "remove") .style("position", "absolute") .style("z-index", "19") .style("width", "1px") .style("height", height) .style("top", "10px") .style("bottom", "30px") .style("left", "0px") .style("background", "#fff");

d3.select("#chartHouseBuilding") .on("mousemove", function(){ mousex = d3.mouse(this); mousex = mousex[0] + 5; vertical.style("left", mousex + "px" )}) .on("mouseover", function(){ mousex = d3.mouse(this); mousex = mousex[0] + 5; vertical.style("left", mousex + "px")}); }); }

/* JS code for auto resizing of chart for responsive devices */ var the_chart = jQuery("#" + chart_id + '-chart'), aspect = the_chart.width() / the_chart.height(), container = the_chart.parent();

jQuery(window).on("resize", function() { var targetWidth = container.width(); the_chart.attr("width", targetWidth); the_chart.attr("height", Math.round(targetWidth / aspect)); }).trigger("resize");

Share this article

  • Facebook
  • X
  • LinkedIn
  • WhatsApp
  • Email

Similarly tagged content:

Sections

  • News

Categories

  • Business

Trending Articles

  • As it happened: Stocks sink after Fed and Bank of England opt for hawkish hold; Oil price tumbles

  • More Big Four blues as Deloitte plans to slash UK audit roles

  • Baillie Gifford in line for Anthropic windfall just months after £3.6bn SpaceX bonanza

  • City investors raise alarm on Burnham’s Chancellor pick

  • Revolut pays compensation for waking customer up with push notifications

More from CityAM

  • New London rooftop bar will be biggest ever with 1,000 capacity

    Life&Style
    Freight Brixton rooftop bar in New London with city skyline views, modern decor, and patrons enjoying cocktails at sunset
  • West Ham sponsor Boyle Sports ‘extremely concerned’ by David Sullivan allegations

    Sport Business
    Getty Images logo on a smartphone screen with a blurred background, representing media and photography business industry.
  • Volvo ES90 review: Forward-looking tech in a trad saloon package

    Life&Style
    Volvo ES90 electric sedan showcasing sleek design and advanced features in a cityscape setting
  • Cabinet ministers urge Starmer to set path for succession

    Politics
    Prime Minister Keir Starmer speaks at a press conference addressing future leadership rumours, wearing a navy suit and tie.
  • Greencore shares slide as M&S sandwich supplier counts cost of Bakkavor takeover

    Food
    Golden-brown homemade quiche with flaky crust and vibrant vegetable filling, freshly baked and ready to serve.
  • Electric Rolls-Royce Spectre Series II: More power, longer range

    Life&Style
    Rolls-Royce Spectre luxury electric vehicle showcased in a sleek design, highlighting its innovative features and elegance
  • Sexy EV coupe joins Porsche Cayenne SUV range – and it looks like a 911

    Life&Style
    Porsche Cayenne showcasing sleek design and advanced features in a dynamic city setting
  • Sweet on Sugar to cause huge 50/1 upset in the Oaks

    Sport
    Getty Images logo on display with blurred background, representing stock photography business in a news context

CityAM Canada — business, markets and opinion for Canadian readers.

Sections

  • Business
  • Markets
  • Tech
  • AI
  • Economics
  • Opinion
  • Cities

Company

  • About
  • Contact

Legal

  • Terms of Use
  • Privacy Policy
  • Cookie Policy
© 2026 CityAM Canada. All rights reserved.
Terms · Privacy · Cookies