<commit_before><!DOCTYPE html>
<html lang="en">
<head>
    <title>dc.js - Row Chart with Target Lines</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../css/dc.css"/>
</head>
<body>

<div class="container">
<script type="text/javascript" src="header.js"></script>
<div id="test"></div>

    <script type="text/javascript" src="../js/promise-polyfill.js"></script>
    <script type="text/javascript" src="../js/fetch.umd.js"></script>
<script type="text/javascript" src="../js/d3.js"></script>
<script type="text/javascript" src="../js/crossfilter.js"></script>
<script type="text/javascript" src="../js/dc.js"></script>
<script type="text/javascript">

var chart = dc.rowChart("#test");
d3.csv("morley.csv").then(function(experiments) {

  experiments.forEach(function(x) {
    x.Speed = +x.Speed;
  });

  var ndx                 = crossfilter(experiments),
      runDimension        = ndx.dimension(function(d) {return +d.Run;}),
      speedSumGroup       = runDimension.group().reduceSum(function(d) {return d.Speed * d.Run / 1000;});

  // use your keys in this map. or your could reduce these in your data
  var _targets = {
      5: 20,
      7: 15,
      9: 22,
      11: 7,
      13: 40,
      20: 70
  };

  chart
    .width(768)
    .height(480)
    .x(d3.scaleLinear().domain([6,20]))
    .elasticX(true)
    .dimension(runDimension)
    .group(speedSumGroup)
    .on('pretransition', function(chart) {
        // read height from one of the row rects, because it's difficult to calculate
        var height = chart.select('g.row rect').attr('height');
        // add vertical target line for any row which does not have one
        var target = chart.selectAll('g.row')
            .selectAll('path.target').data(function(d) { return [d]; });
        target = target.enter().append('path')
            .attr('class', 'target')
            .attr('stroke', 'red')
            .attr('visibility', function(d) {
                return (d.value.target !== undefined || _targets[d.key] !== undefined) ? 'visible' : 'hidden';
            })
            .attr('d', function(d) {
                return 'M0,0 v' + height;
            }).merge(target);
        // move into position (also move any targets that changed)
        target.transition().duration(chart.transitionDuration())
            .attr('d', function(d) {
                return 'M' + (chart.x()(d.value.target || _targets[d.key] || 0)+0.5) + ',0 v' + height;
            });
    });
    chart.render();
});

</script>

</div>
</body>
</html><commit_msg>targets may also become (in)visible<commit_after><!DOCTYPE html>
<html lang="en">
<head>
    <title>dc.js - Row Chart with Target Lines</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../css/dc.css"/>
</head>
<body>

<div class="container">
<script type="text/javascript" src="header.js"></script>
<div id="test"></div>

    <script type="text/javascript" src="../js/promise-polyfill.js"></script>
    <script type="text/javascript" src="../js/fetch.umd.js"></script>
<script type="text/javascript" src="../js/d3.js"></script>
<script type="text/javascript" src="../js/crossfilter.js"></script>
<script type="text/javascript" src="../js/dc.js"></script>
<script type="text/javascript">

var chart = dc.rowChart("#test");
d3.csv("morley.csv").then(function(experiments) {

  experiments.forEach(function(x) {
    x.Speed = +x.Speed;
  });

  var ndx                 = crossfilter(experiments),
      runDimension        = ndx.dimension(function(d) {return +d.Run;}),
      speedSumGroup       = runDimension.group().reduceSum(function(d) {return d.Speed * d.Run / 1000;});

  // use your keys in this map. or your could reduce these in your data
  var _targets = {
      5: 20,
      7: 15,
      9: 22,
      11: 7,
      13: 40,
      20: 70
  };

  chart
    .width(768)
    .height(480)
    .x(d3.scaleLinear().domain([6,20]))
    .elasticX(true)
    .dimension(runDimension)
    .group(speedSumGroup)
    .on('pretransition', function(chart) {
        // read height from one of the row rects, because it's difficult to calculate
        var height = chart.select('g.row rect').attr('height');
        // add vertical target line for any row which does not have one
        var target = chart.selectAll('g.row')
            .selectAll('path.target').data(function(d) { return [d]; });
        target = target.enter().append('path')
            .attr('class', 'target')
            .attr('stroke', 'red')
            .attr('visibility', function(d) {
                return (d.value.target !== undefined || _targets[d.key] !== undefined) ? 'visible' : 'hidden';
            })
            .attr('d', function(d) {
                return 'M0,0 v' + height;
            }).merge(target);
        // move into position (also move any targets that changed)
        target.transition().duration(chart.transitionDuration())
            .attr('visibility', function(d) {
                return (d.value.target !== undefined || _targets[d.key] !== undefined) ? 'visible' : 'hidden';
            })
            .attr('d', function(d) {
                return 'M' + (chart.x()(d.value.target || _targets[d.key] || 0)+0.5) + ',0 v' + height;
            });
    });
    chart.render();
});

</script>

</div>
</body>
</html>
{'fraction_non_alphanumeric': 0.1878432808495057, 'fraction_numerical': 0.015745148297326986, 'mean_word_length': 2.591715976331361, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5424208', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1701, 'n_words': 384}