// even if the point is outside the visible range and only one series has a valid value for this point.
CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);
};
+
+ConnectSeparatedPointsTestCase.prototype.testConnectSeparatedPointsPerSeries = function() {
+ var assertExpectedLinesDrawnPerSeries = function(htx, expectedSeries1, expectedSeries2, expectedSeries3) {
+ var expected = [expectedSeries1, expectedSeries2, expectedSeries3];
+ var actual = [
+ CanvasAssertions.numLinesDrawn(htx, "#ff0000"),
+ CanvasAssertions.numLinesDrawn(htx, "#00ff00"),
+ CanvasAssertions.numLinesDrawn(htx, "#0000ff")];
+ assertEquals(expected, actual);
+ }
+
+ var g = new Dygraph(document.getElementById("graph"),
+ [
+ [1, 10, 10, 10],
+ [2, 15, 11, 12],
+ [3, null, null, 12],
+ [4, 20, 14, null],
+ [5, 15, null, 17],
+ [6, 18, null, null],
+ [7, 12, 14, null]
+ ],
+ {
+ labels: ["Date","Series1","Series2","Series3"],
+ connectSeparatedPoints: false,
+ colors: ["#ff0000", "#00ff00", "#0000ff"]
+ });
+
+ htx = g.hidden_ctx_;
+ assertExpectedLinesDrawnPerSeries(htx, 4, 1, 2);
+
+ Proxy.reset(htx);
+ g.updateOptions({
+ connectSeparatedPoints : true,
+ });
+ assertExpectedLinesDrawnPerSeries(htx, 5, 3, 3);
+
+ Proxy.reset(htx);
+ g.updateOptions({
+ connectSeparatedPoints : false,
+ series : {
+ Series1 : { connectSeparatedPoints : true }
+ }
+ });
+ assertExpectedLinesDrawnPerSeries(htx, 5, 1, 2);
+
+
+ Proxy.reset(htx);
+ g.updateOptions({
+ connectSeparatedPoints : true,
+ series : {
+ Series1 : { connectSeparatedPoints : false }
+ }
+ });
+ assertExpectedLinesDrawnPerSeries(htx, 4, 3, 3);
+}
var drawGapPoints = g.getOption('drawGapEdgePoints', e.setName);
var points = e.points;
+ var setName = e.setName;
var iter = Dygraph.createIterator(points, 0, points.length,
DygraphCanvasRenderer._getIteratorPredicate(
- g.getOption("connectSeparatedPoints"))); // TODO(danvk): per-series?
+ g.getOption("connectSeparatedPoints", setName)));
var stroking = strokePattern && (strokePattern.length >= 2);
var iter = Dygraph.createIterator(points, 0, points.length,
DygraphCanvasRenderer._getIteratorPredicate(
- g.getOption("connectSeparatedPoints")));
+ g.getOption("connectSeparatedPoints", setName)));
var newYs;
var points = sets[setIdx];
var iter = Dygraph.createIterator(points, 0, points.length,
DygraphCanvasRenderer._getIteratorPredicate(
- g.getOption("connectSeparatedPoints")));
+ g.getOption("connectSeparatedPoints", setName)));
// setup graphics context
var prevX = NaN;
this.yTicks_ = null;
};
-DygraphLayout.prototype.attr_ = function(name) {
- return this.dygraph_.attr_(name);
-};
-
/**
* Add points for a single series.
*
y: 0
};
- area.w = this.dygraph_.width_ - area.x - this.attr_('rightGap');
+ area.w = this.dygraph_.width_ - area.x - this.dygraph_.attr_('rightGap');
area.h = this.dygraph_.height_;
// Let plugins reserve space.
// The Dygraph object's annotations aren't parsed. We parse them here and
// save a copy. If there is no parser, then the user must be using raw format.
this.annotations = [];
- var parse = this.attr_('xValueParser') || function(x) { return x; };
+ var parse = this.dygraph_.attr_('xValueParser') || function(x) { return x; };
for (var i = 0; i < ann.length; i++) {
var a = {};
if (!ann[i].xval && ann[i].x === undefined) {
};
DygraphLayout.prototype._evaluateLineCharts = function() {
- var connectSeparated = this.attr_('connectSeparatedPoints');
- var isStacked = this.attr_("stackedGraph");
+ var isStacked = this.dygraph_.attr_("stackedGraph");
for (var setIdx = 0; setIdx < this.points.length; setIdx++) {
var points = this.points[setIdx];
var setName = this.setNames[setIdx];
+ var connectSeparated = this.dygraph_.attr_('connectSeparatedPoints', setName);
var axis = this.dygraph_.axisPropertiesForSeries(setName);
// TODO (konigsberg): use optionsForAxis instead.
var logscale = this.dygraph_.attributes_.getForSeries("logscale", setName);
overlays in the proper color.</p>
<div id="graphdiv" style="width:600px; height:300px;"></div>
+<p><b>Toggle ConnectSeparated:<b></p>
+<p>
+ All: <button id="All" onclick="change(this)">true</button>
+ Series 1 <button id="Series1" onclick="change(this)">disabled</button>
+ Series 2 <button id="Series2" onclick="change(this)">disabled</button>
+ Series 3 <button id="Series3" onclick="change(this)">disabled</button>
+</p>
<script type="text/javascript">
var g = new Dygraph(document.getElementById("graphdiv"),
[
connectSeparatedPoints: true,
labels: ["Date","Series1","Series2","Series3"]
});
+
+ function change(el) {
+ var textSequences = [ "disabled", "true", "false" ];
+ var values = [ null, true, false ];
+ for (var idx = 0; idx < textSequences.length; idx++) {
+ if (textSequences[idx] == el.textContent) {
+ var nextIdx = (idx + 1) % 3;
+ var nextVal = values[nextIdx];
+ el.textContent = textSequences[nextIdx];
+
+ if (el.id == "All") {
+ g.updateOptions({ connectSeparatedPoints : nextVal });
+ } else {
+ var seriesOpt = {};
+ seriesOpt[el.id] = { connectSeparatedPoints : nextVal };
+ g.updateOptions({ series : seriesOpt });
+ }
+ break;
+ }
+ }
+ }
</script>
</body>
</html>