This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global portviz:false, _:false */ | |
/* | |
* after rosettacode.org/mw/index.php?title=Knapsack_problem/0-1 | |
* | |
* details: https://github.com/truher/truher.github.com/wiki/Knapsack | |
*/ | |
var allwants = [ | |
{name:"map", weight:9, value: 150}, | |
{name:"compass", weight:13, value: 35}, | |
{name:"water", weight:153, value: 200}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* selection datum should contain a 'label' field, which can | |
* contain multiple lines. first line is emphasized. | |
* | |
* selection datum should accomodate the tips fifo called 'tips'. | |
* | |
* using a single tooltip element exposes the add/remove race, | |
* so it's easier to have lots of them; by id. that way we can | |
* nicely transition the fade of the old one, while creating | |
* new ones. so each mouseover target datum gets a fifo of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<script src="https://unpkg.com/d3/dist/d3.js"></script> | |
<script src="https://unpkg.com/d3fc/build/d3fc.js"></script> | |
<style> #small-multiples > div { height: 250px; } </style> | |
<d3fc-canvas id='small-multiples'></d3fc-canvas> | |
<script> | |
xScale = d3.scaleLinear().domain([-1, 10]); | |
yScale = d3.scaleLinear().domain([-1, 10]); | |
series = fc.seriesSvgPoint().crossValue(d => d.x).mainValue(d => d.y); | |
chart = fc.chartCartesian(xScale, yScale).svgPlotArea(series); |