Heatmap Chart

@class
2125
function Heatmap() {
    var canvas = zrUtil.createCanvas();
    this.canvas = canvas;

    this.blurSize = 30;
    this.pointSize = 20;

    this.maxOpacity = 1;
    this.minOpacity = 0;

    this._gradientPixels = {};
}
702624
function (d, context) {
                    dimple._drawMarkers(d, chart, series, duration, className, graded, onEnter(d), onLeave(d), context);
                }
1018976
function () {
		var series = this,
			chart = series.chart,
			renderer = chart.renderer,
			groupTranslation,
			//center,
			graphic,
			group,
			shadow = series.options.shadow,
			shadowGroup,
			shapeArgs;


		// draw the slices
		each(series.data, function (point) {
			graphic = point.graphic;
			shapeArgs = point.shapeArgs;
			group = point.group;
			shadowGroup = point.shadowGroup;

			// put the shadow behind all points
			if (shadow && !shadowGroup) {
				shadowGroup = point.shadowGroup = renderer.g('shadow')
					.attr({ zIndex: 4 })
					.add();
			}

			// create the group the first time
			if (!group) {
				group = point.group = renderer.g('point')
					.attr({ zIndex: 5 })
					.add();
			}

			// if the point is sliced, use special translation, else use plot area traslation
			groupTranslation = point.sliced ? point.slicedTranslation : [chart.plotLeft, chart.plotTop];
			group.translate(groupTranslation[0], groupTranslation[1]);
			if (shadowGroup) {
				shadowGroup.translate(groupTranslation[0], groupTranslation[1]);
			}


			// draw the slice
			if (graphic) {
				graphic.animate(shapeArgs);
			} else {
				point.graphic =
					renderer.arc(shapeArgs)
					.attr(extend(
						point.pointAttr[NORMAL_STATE],
						{ 'stroke-linejoin': 'round' }
					))
					.add(point.group)
					.shadow(shadow, shadowGroup);
			}

			// detect point specific visibility
			if (point.visible === false) {
				point.setVisible(false);
			}

		});

	}
226791
function () {
		var chart = this,
			axes = chart.axes,
			renderer = chart.renderer,
			options = chart.options;

		var labels = options.labels,
			credits = options.credits,
			creditsHref;

		// Title
		chart.setTitle();


		// Legend
		chart.legend = new Legend(chart, options.legend);

		chart.getStacks(); // render stacks

		// Get margins by pre-rendering axes
		// set axes scales
		each(axes, function (axis) {
			axis.setScale();
		});

		chart.getMargins();

		chart.maxTicks = null; // reset for second pass
		each(axes, function (axis) {
			axis.setTickPositions(true); // update to reflect the new margins
			axis.setMaxTicks();
		});
		chart.adjustTickAmounts();
		chart.getMargins(); // second pass to check for new labels


		// Draw the borders and backgrounds
		chart.drawChartBox();		


		// Axes
		if (chart.hasCartesianSeries) {
			each(axes, function (axis) {
				axis.render();
			});
		}

		// The series
		if (!chart.seriesGroup) {
			chart.seriesGroup = renderer.g('series-group')
				.attr({ zIndex: 3 })
				.add();
		}
		each(chart.series, function (serie) {
			serie.translate();
			serie.setTooltipPoints();
			serie.render();
		});

		// Labels
		if (labels.items) {
			each(labels.items, function (label) {
				var style = extend(labels.style, label.style),
					x = pInt(style.left) + chart.plotLeft,
					y = pInt(style.top) + chart.plotTop + 12;

				// delete to prevent rewriting in IE
				delete style.left;
				delete style.top;

				renderer.text(
					label.html,
					x,
					y
				)
				.attr({ zIndex: 2 })
				.css(style)
				.add();

			});
		}

		// Credits
		if (credits.enabled && !chart.credits) {
			creditsHref = credits.href;
			chart.credits = renderer.text(
				credits.text,
				0,
				0
			)
			.on('click', function () {
				if (creditsHref) {
					location.href = creditsHref;
				}
			})
			.attr({
				align: credits.position.align,
				zIndex: 8
			})
			.css(credits.style)
			.add()
			.align(credits.position);
		}

		// Set flag
		chart.hasRendered = true;

	}
905186
function getHeatmap(tracks) {
    var heatmap = [];
    _.each(tracks, function(track) {
        var idxStart = Math.floor(track.startTime / HEATMAP_SEGMENT), idxEnd = Math.ceil(track.endTime / HEATMAP_SEGMENT);
        idxEnd = Math.min(MAX_HEATMAP_LEN, idxEnd); /* Protection - sometimes we have buggy tracks which end in Infinity */

        for (var i=idxStart; i<idxEnd; i++) {
          if (i<0) continue;
          if (! heatmap[i]) heatmap[i] = 0;
          USE_BOOLEAN ? heatmap[i] = 1 : heatmap[i]++;
        }
    });

    /* Heatmap: Fill in the blanks */
    for (var i = 0; i!=heatmap.length; i++) 
      if (! heatmap[i]) heatmap[i] = 0;   

    return heatmap;
}
1084384
protected Map<AbstractColumn, JRDesignVariable> registerChartVariable(ar.com.fdvs.dj.domain.chart.DJChart chart) {
        //FIXME aca hay que iterar por cada columna. Cambiar DJChart para que tome muchas
        JRDesignGroup group = getChartColumnsGroup(chart);
        Map<AbstractColumn, JRDesignVariable> vars = new HashMap<AbstractColumn, JRDesignVariable>();

        int serieNum = 0;
        for (Object o : chart.getDataset().getColumns()) {
            AbstractColumn col = (AbstractColumn) o;


            Class clazz;
//			try { clazz = Class.forName(col.getValueClassNameForExpression());
//			} catch (ClassNotFoundException e) {
//				throw new DJException("Exeption creating chart variable: " + e.getMessage(),e);
//			}

            JRDesignExpression expression = new JRDesignExpression();
            //FIXME Only PropertyColumn allowed?
            if (col instanceof ExpressionColumn) {
                try {
                    clazz = Class.forName(((ExpressionColumn) col).getExpression().getClassName());
                } catch (ClassNotFoundException e) {
                    throw new DJException("Exeption creating chart variable: " + e.getMessage(), e);
                }

                ExpressionColumn expCol = (ExpressionColumn) col;
                expression.setText(expCol.getTextForExpression());
                expression.setValueClassName(expCol.getExpression().getClassName());
            } else {
                try {
                    clazz = Class.forName(((PropertyColumn) col).getColumnProperty().getValueClassName());
                } catch (ClassNotFoundException e) {
                    throw new DJException("Exeption creating chart variable: " + e.getMessage(), e);
                }

                expression.setText("$F{" + ((PropertyColumn) col).getColumnProperty().getProperty() + "}");
                expression.setValueClass(clazz);
            }

            JRDesignVariable var = new JRDesignVariable();
            var.setValueClass(clazz);
            var.setExpression(expression);
            var.setCalculation(CalculationEnum.getByValue(chart.getOperation()));
            var.setResetGroup(group);
            var.setResetType(ResetTypeEnum.GROUP);

            //use the index as part of the name just because I may want 2
            //different types of chart from the very same column (with the same operation also) making the variables name to be duplicated
            int chartIndex = getReport().getNewCharts().indexOf(chart);
            var.setName("CHART_[" + chartIndex + "_s" + serieNum + "+]_" + group.getName() + "_" + col.getTitle() + "_" + chart.getOperation());

            try {
                getDesign().addVariable(var);
                vars.put(col, var);
            } catch (JRException e) {
                throw new LayoutException(e.getMessage(), e);
            }
            serieNum++;
        }
        return vars;
    }
965714
def draw(self):
        
        # Create display grid
        cr_display = np.zeros((len(self.classes_), len(self._displayed_scores)))


        # For each class row, append columns for precision, recall, f1, and support
        for idx, cls in enumerate(self.classes_):
            for jdx, metric in enumerate(self._displayed_scores):
                cr_display[idx, jdx] = self.scores_[metric][cls]

        # Set up the dimensions of the pcolormesh
        # NOTE: pcolormesh accepts grids that are (N+1,M+1)
        X, Y = np.arange(len(self.classes_)+1), np.arange(len(self._displayed_scores)+1)
        self.ax.set_ylim(bottom=0, top=cr_display.shape[0])
        self.ax.set_xlim(left=0, right=cr_display.shape[1])

        # Set data labels in the grid, enumerating over class, metric pairs
        # NOTE: X and Y are one element longer than the classification report
        # so skip the last element to label the grid correctly.
        for x in X[:-1]:
            for y in Y[:-1]:

                # Extract the value and the text label
                value = cr_display[x, y]
                svalue = "{:0.3f}".format(value)

                # change the svalue for support (when y == 3) because we want
                # to label it as the actual support value, not the percentage
                if y == 3:
                    if self.support != PERCENT:
                        svalue = self.support_score_[x]

                # Determine the grid and text colors
                base_color = self.cmap(value)
                text_color = find_text_color(base_color)

                # Add the label to the middle of the grid
                cx, cy = x+0.5, y+0.5
                self.ax.text(
                    cy, cx, svalue, va='center', ha='center', color=text_color
                )


        # Draw the heatmap with colors bounded by the min and max of the grid
        # NOTE: I do not understand why this is Y, X instead of X, Y it works
        # in this order but raises an exception with the other order.
        g = self.ax.pcolormesh(
            Y, X, cr_display, vmin=0, vmax=1, cmap=self.cmap, edgecolor='w',
        )

        # Add the color bar
        plt.colorbar(g, ax=self.ax)

        # Return the axes being drawn on
        return self.ax
909317
public static void plotCharts(List<Chart> charts){
		int numRows =1;
		int numCols =1;
		if(charts.size()>1){
			numRows = (int) Math.ceil(charts.size()/2.0);
			numCols = 2;
		}
		
	    final JFrame frame = new JFrame("");
	    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        frame.getContentPane().setLayout(new GridLayout(numRows, numCols));
	    for (Chart chart : charts) {
	          if (chart != null) {
	            JPanel chartPanel = new XChartPanel(chart);
	            frame.add(chartPanel);
	          }
	          else {
	            JPanel chartPanel = new JPanel();
	            frame.getContentPane().add(chartPanel);
	          }

	        }
	    // Display the window.
        frame.pack();
        frame.setVisible(true);
	}
526354
def heatmap(self, df, imagefile):
        
        import seaborn as sns
        import matplotlib.ticker as tkr
        import matplotlib.pyplot as plt
        from  matplotlib.colors import LinearSegmentedColormap

        sns.set()
        with sns.axes_style('whitegrid'):
            fig, ax = plt.subplots(figsize=(5, 11))  # inches

            cmax = max(df[self.args[2]].max(), self.CMAP_MIN_MAX)
            csteps = {
                0.0: 'darkred', 0.3/cmax: 'red', 0.6/cmax: 'orangered', 0.9/cmax: 'coral',
                1.0/cmax: 'skyblue', 1.5/cmax: 'blue', 1.9/cmax: 'darkblue',
                2.0/cmax: 'darkgreen', 3.0/cmax: 'green',
                (self.CMAP_MIN_MAX - .1)/cmax: 'palegreen', 1.0: 'yellow'}
            cmap = LinearSegmentedColormap.from_list('RdGrYl', sorted(csteps.items()), N=256)

            dataset = df.pivot(*self.args)

            sns.heatmap(dataset, mask=dataset.isnull(), annot=False, linewidths=.5, square=True, ax=ax, cmap=cmap,
                        annot_kws=dict(stretch='condensed'))
            ax.tick_params(axis='y', labelrotation=30, labelsize=8)
            # ax.get_yaxis().set_major_formatter(tkr.FuncFormatter(lambda x, p: x))
            plt.savefig(imagefile)
893949
function drawAllDataPoints(animationDecimal) {
			var totvalue = new Array();
			var maxvalue = new Array();
			var lmaxvalue = new Array();
			for (var i = 0; i < data.datasets.length; i++) {
				lmaxvalue[i] = -999999999;
				for (var j = 0; j < data.datasets[i].data.length; j++) {
					totvalue[j] = 0;
					maxvalue[j] = -999999999;
				}
			}
			for (var i = 0; i < data.datasets.length; i++) {
				for (var j = 0; j < data.datasets[i].data.length; j++) {
					if (!(typeof(data.datasets[i].data[j]) == 'undefined')) {
						totvalue[j] += 1 * data.datasets[i].data[j];
						maxvalue[j] = Max([maxvalue[j], 1 * data.datasets[i].data[j]]);
						lmaxvalue[i] = Max([lmaxvalue[i], 1 * data.datasets[i].data[j]]);
					}
				}
			}
			var rotationDegree = (2 * Math.PI) / data.datasets[0].data.length;
			ctx.save();
			//We accept multiple data sets for radar charts, so show loop through each set
			for (var i = 0; i < data.datasets.length; i++) {
				if (animationDecimal >= 1) {
					if (typeof(data.datasets[i].title) == "string") lgtxt = data.datasets[i].title.trim();
					else lgtxt = "";
				}
				var fPt = -1;
				for (var j = 0; j < data.datasets[i].data.length; j++) {
					var currentAnimPc = animationCorrection(animationDecimal, data, config, i, j, 1).animVal;
					if (currentAnimPc > 1) currentAnimPc = currentAnimPc - 1;
					if (!(typeof(data.datasets[i].data[j]) == 'undefined')) {
						if (fPt == -1) {
							ctx.beginPath();
							ctx.moveTo(midPosX + currentAnimPc * (Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop)), midPosY - currentAnimPc * (Math.sin(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop)));
							fPt = j;
						} else {
							ctx.lineTo(midPosX + currentAnimPc * (Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop)), midPosY - currentAnimPc * (Math.sin(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop)));
						}
						if (animationDecimal >= 1) {
							if (i == 0) divprev = 0;
							else divprev = data.datasets[i].data[j] - data.datasets[i - 1].data[j];
							if (i == data.datasets.length - 1) divnext = 0;
							else divnext = data.datasets[i + 1].data[j] - data.datasets[i].data[j];
							if (typeof(data.labels[j]) == "string") lgtxt2 = data.labels[j].trim();
							else lgtxt2 = "";
							jsGraphAnnotate[ctx.ChartNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["POINT", midPosX + Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop), midPosY - Math.sin(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop), lgtxt, lgtxt2, 1 * data.datasets[i].data[j], divprev, divnext, maxvalue[j], totvalue[j], i, j];
						}
					}
				}
				ctx.closePath();
				if (config.datasetFill) {
					if (typeof data.datasets[i].fillColor == "function") ctx.fillStyle = data.datasets[i].fillColor("FILLCOLOR", data, config, i, -1, currentAnimPc, -1, "Radar", ctx, midPosX, midPosY, 0, (config.animationLeftToRight ? 1 : currentAnimPc) * (calculateOffset(config.logarithmic, lmaxvalue[i], calculatedScale, scaleHop)));
					else if (typeof data.datasets[i].fillColor == "string") ctx.fillStyle = data.datasets[i].fillColor;
					else ctx.fillStyle = config.defaultFillColor;
				} else ctx.fillStyle = "rgba(0,0,0,0)";
				if (typeof data.datasets[i].strokeColor == "function") ctx.strokeStyle = data.datasets[i].strokeColor("STROKECOLOR", data, config, i, -1, currentAnimPc, -1, "Radar", ctx, midPosX, midPosY, 0, (config.animationLeftToRight ? 1 : currentAnimPc) * (calculateOffset(config.logarithmic, lmaxvalue[i], calculatedScale, scaleHop)));
				else if (typeof data.datasets[i].strokeColor == "string") ctx.strokeStyle = data.datasets[i].strokeColor;
				else ctx.strokeStyle = config.defaultStrokeColor;
				ctx.lineWidth = config.datasetStrokeWidth;
				ctx.fill();
				ctx.stroke();
				if (config.pointDot && (!config.animationLeftToRight || (config.animationLeftToRight && animationDecimal >= 1))) {
					ctx.beginPath();
					if (typeof data.datasets[i].pointColor == "function") ctx.fillStyle = data.datasets[i].pointColor("POINTCOLOR", data, config, i, -1, currentAnimPc, -1, "Radar", ctx, midPosX, midPosY, 0, (config.animationLeftToRight ? 1 : currentAnimPc) * (calculateOffset(config.logarithmic, lmaxvalue[i], calculatedScale, scaleHop)));
					else ctx.fillStyle = data.datasets[i].pointColor;
					if (typeof data.datasets[i].pointStrokeColor == "function") ctx.strokeStyle = data.datasets[i].pointStrokeColor("POINTSTROKECOLOR", data, config, i, -1, currentAnimPc, -1, "Radar", ctx, midPosX, midPosY, 0, (config.animationLeftToRight ? 1 : currentAnimPc) * (calculateOffset(config.logarithmic, lmaxvalue[i], calculatedScale, scaleHop)));
					else ctx.strokeStyle = data.datasets[i].pointStrokeColor;
					ctx.lineWidth = config.pointDotStrokeWidth;
					for (var k = 0; k < data.datasets[i].data.length; k++) {
						if (!(typeof(data.datasets[i].data[k]) == 'undefined')) {
							ctx.beginPath();
							ctx.arc(midPosX + currentAnimPc * (Math.cos(config.startAngle * Math.PI / 180 - k * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[k], calculatedScale, scaleHop)), midPosY - currentAnimPc * (Math.sin(config.startAngle * Math.PI / 180 - k * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[k], calculatedScale, scaleHop)), config.pointDotRadius, 2 * Math.PI, false);
							ctx.fill();
							ctx.stroke();
						}
					}
				}
			}
			ctx.restore();
			if (animationDecimal >= 1 && config.inGraphDataShow) {
				for (var i = 0; i < data.datasets.length; i++) {
					if (typeof(data.datasets[i].title) == "string") lgtxt = data.datasets[i].title.trim();
					else lgtxt = "";
					for (var j = 0; j < data.datasets[i].data.length; j++) {
						if (!(typeof(data.datasets[i].data[j]) == 'undefined')) {
							if (i == 0) divprev = 0;
							else divprev = data.datasets[i].data[j] - data.datasets[i - 1].data[j];
							if (i == data.datasets.length - 1) divnext = 0;
							else divnext = data.datasets[i + 1].data[j] - data.datasets[i].data[j];
							if (typeof(data.labels[j]) == "string") lgtxt2 = data.labels[j].trim();
							else lgtxt2 = "";
							ctx.save();
							ctx.textAlign = config.inGraphDataAlign;
							ctx.textBaseline = config.inGraphDataVAlign;
							if (config.inGraphDataAlign == "off-center") {
								if (config.inGraphDataRotate == "inRadiusAxis" || (config.startAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (config.startAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) <= Math.PI / 2) ctx.textAlign = "left";
								else ctx.textAlign = "right";
							} else if (config.inGraphDataAlign == "to-center") {
								if (config.inGraphDataRotate == "inRadiusAxis" || (config.startAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (config.startAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) < Math.PI / 2) ctx.textAlign = "right";
								else ctx.textAlign = "left";
							} else ctx.textAlign = config.inGraphDataAlign;
							if (config.inGraphDataVAlign == "off-center") {
								if ((config.startAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "bottom";
								else ctx.textBaseline = "top";
							} else if (config.inGraphDataVAlign == "to-center") {
								if ((config.startAngle * Math.PI / 180 - j * rotationDegree + 4 * Math.PI) % (2 * Math.PI) > Math.PI) ctx.textBaseline = "top";
								else ctx.textBaseline = "bottom";
							} else ctx.textBaseline = config.inGraphDataVAlign;
							ctx.font = config.inGraphDataFontStyle + ' ' + config.inGraphDataFontSize + 'px ' + config.inGraphDataFontFamily;
							ctx.fillStyle = config.inGraphDataFontColor;
							var radiusPrt;
							if (config.inGraphDataRadiusPosition == 1) radiusPrt = 0 + config.inGraphDataPaddingRadius;
							else if (config.inGraphDataRadiusPosition == 2) radiusPrt = (calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop)) / 2 + config.inGraphDataPaddingRadius;
							else if (config.inGraphDataRadiusPosition == 3) radiusPrt = (calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop)) + config.inGraphDataPaddingRadius;
							ctx.translate(midPosX + Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree) * radiusPrt, midPosY - Math.sin(config.startAngle * Math.PI / 180 - j * rotationDegree) * radiusPrt);
							if (config.inGraphDataRotate == "inRadiusAxis") ctx.rotate(j * rotationDegree);
							else if (config.inGraphDataRotate == "inRadiusAxisRotateLabels") {
								if ((j * rotationDegree + 2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (j * rotationDegree + 2 * Math.PI) % (2 * Math.PI) < 3 * Math.PI / 2) ctx.rotate(3 * Math.PI + j * rotationDegree);
								else ctx.rotate(2 * Math.PI + j * rotationDegree);
							} else ctx.rotate(config.inGraphDataRotate * (Math.PI / 180));
							var dispString = tmplbis(config.inGraphDataTmpl, {
								config: config,
								v1: fmtChartJS(config, lgtxt, config.fmtV1),
								v2: fmtChartJS(config, lgtxt2, config.fmtV2),
								v3: fmtChartJS(config, 1 * data.datasets[i].data[j], config.fmtV3),
								v4: fmtChartJS(config, divprev, config.fmtV4),
								v5: fmtChartJS(config, divnext, config.fmtV5),
								v6: fmtChartJS(config, maxvalue[j], config.fmtV6),
								v7: fmtChartJS(config, totvalue[j], config.fmtV7),
								v8: roundToWithThousands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[j], config.fmtV8), config.roundPct),
								v9: fmtChartJS(config, midPosX + Math.cos(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop), config.fmtV9),
								v10: fmtChartJS(config, midPosY - Math.sin(config.startAngle * Math.PI / 180 - j * rotationDegree) * calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop), config.fmtV10),
								v11: fmtChartJS(config, i, config.fmtV11),
								v12: fmtChartJS(config, j, config.fmtV12),
								data: data
							});
							ctx.fillTextMultiLine(dispString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize);
							ctx.restore();
						}
					}
				}
			}
			if(msr.legendMsr.dispLegend)drawLegend(msr.legendMsr,data,config,ctx,"Radar");
		}
1159658
function slide10() {
		var slide = pptx.addNewSlide();
		slide.addNotes('API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-charts.html');
		slide.addTable( [ [{ text:'Chart Examples: Line Chart: Lots of Lines', options:gOptsTextL },gOptsTextR] ], gOptsTabOpts );

		var MAXVAL = 20000;

		var arrDataTimeline = [];
		for (var idx=0; idx<15; idx++) {
			var tmpObj = {
				name  : 'Series'+idx,
				labels: MONS,
				values: []
			};

			for (var idy=0; idy<MONS.length; idy++) {
				tmpObj.values.push( Math.floor(Math.random() * MAXVAL) + 1 );
			}

			arrDataTimeline.push( tmpObj );
		}

		// FULL SLIDE:
		var optsChartLine1 = { x:0.5, y:0.6, w:'95%', h:'85%',
			fill: 'F2F9FC',

			valAxisMaxVal: MAXVAL,

			showLegend: true,
			legendPos : 'r'
		};
		slide.addChart( pptx.charts.LINE, arrDataTimeline, optsChartLine1 );
	}
1327995
function slide7() {
		var slide = pptx.addNewSlide();
		slide.addNotes('API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-charts.html');
		slide.addTable( [ [{ text:'Tornado Chart - Grid and Axis Formatting', options:gOptsTextL },gOptsTextR] ], gOptsTabOpts );

		slide.addChart(
			pptx.charts.BAR,
			[
				{
					name: 'High',
					labels: ['London', 'Munich', 'Tokyo'],
					values: [.20, .32, .41]
				},
				{
					name: 'Low',
					labels: ['London', 'Munich', 'Tokyo'],
					values: [-0.11, -0.22, -0.29]
				}
			],
			{
				x:0.5, y:0.5, w:'90%', h:'90%',
				valAxisMaxVal: 1,
				barDir: 'bar',
				axisLabelFormatCode: '#%',
				gridLineColor: 'D8D8D8',
				axisLineColor: 'D8D8D8',
				catAxisLineShow: false,
				valAxisLineShow: false,
				barGrouping: 'stacked',
				catAxisLabelPos: 'low',
				valueBarColors: true,
				shadow: 'none',
				chartColors: ['0077BF','4E9D2D','ECAA00','5FC4E3','DE4216','154384','7D666A','A3C961','EF907B','9BA0A3'],
				invertedColors: ['0065A2','428526','C99100','51A7C1','BD3813','123970','6A575A','8BAB52','CB7A69','84888B'],
				barGapWidthPct: 25,
				valAxisMajorUnit: 0.2
			}
		);
	}
556934
def plot_temp_diagrams(config, results, temp_dir):
    """"""
    display_name = {
        'time': 'Compilation time (s)',
        'memory': 'Compiler memory usage (MB)',
    }

    files = config['files']
    img_files = []

    if any('slt' in result for result in results) and 'bmp' in files.values()[0]:
        config['modes']['slt'] = 'Using BOOST_METAPARSE_STRING with string literal templates'
        for f in files.values():
            f['slt'] = f['bmp'].replace('bmp', 'slt')

    for measured in ['time', 'memory']:
        mpts = sorted(int(k) for k in files.keys())
        img_files.append(os.path.join(temp_dir, '_{0}.png'.format(measured)))
        plot(
            {
                m: [(x, results[files[str(x)][m]][measured]) for x in mpts]
                for m in config['modes'].keys()
            },
            config['modes'],
            display_name[measured],
            (config['x_axis_label'], display_name[measured]),
            img_files[-1]
        )
    return img_files
628903
def color_chart
      [0, 1, 4, 5, 7].each do |attr|
        puts '----------------------------------------------------------------'
        puts "ESC[#{attr};Foreground;Background"
        30.upto(37) do |fg|
          40.upto(47) do |bg|
            print "\033[#{attr};#{fg};#{bg}m #{fg};#{bg}  "
          end
          puts "\033[0m"
        end
      end
    end
1167952
def init_heatmap(x_vec, y_vec, hist_matrix, fig, colormap='Blues',
                 alpha=1, grid=False, colorbar=True,
                 vmax='auto', vmin='auto', crop=True):
    
    plt.figure(fig.number)
    ax = fig.gca()

    # set vmax and vmin
    vma = np.amax(hist_matrix) if vmax == 'auto' else vmax
    vmi = np.amin(hist_matrix) if vmin == 'auto' else vmin

    # an error check
    if vma <= vmi:
        vma = vmi + 1

    # grid the space for pcolormesh
    x_grid, y_grid = np.meshgrid(x_vec, y_vec)

    hmap = ax.pcolormesh(x_grid, y_grid, np.array(hist_matrix),
               cmap=colormap, alpha=alpha, shading='gouraud',
               vmax=vma, vmin=vmi)

    if colorbar:
        plt.colorbar(hmap)

    if not grid:
        ax.grid(False)

    if crop:
        ax.set_xlim([x_vec[0], x_vec[-1]])
        ax.set_ylim([y_vec[0], y_vec[-1]])
315882
def chart(colors, data, args, labels):
    """"""
    len_categories = len(data[0])
    if len_categories > 1:
        # Stacked graph
        if args['stacked']:
            normal_dat = normalize(data, args['width'])
            stacked_graph(labels, data, normal_dat, len_categories,
                          args, colors)
            return

        if not colors:
            colors = [None] * len_categories

        # Multiple series graph with different scales
        # Normalization per category
        if args['different_scale']:
            for i in range(len_categories):
                cat_data = []
                for dat in data:
                    cat_data.append([dat[i]])

                # Normalize data, handle negatives.
                normal_cat_data = normalize(cat_data, args['width'])

                # Generate data for a row.
                for row in horiz_rows(labels, cat_data, normal_cat_data,
                                      args, [colors[i]]):
                    # Print the row
                    if not args['vertical']:
                        print_row(*row)
                    else:
                        vertic = vertically(*row, args=args)

                # Vertical graph
                if args['vertical']:
                    print_vertical(vertic, labels, colors[i], args)

                print()
                value_list.clear(), zipped_list.clear(), vertical_list.clear()
                return

    # One category/Multiple series graph with same scale
    # All-together normalization
    if not args['stacked']:
        normal_dat = normalize(data, args['width'])
        for row in horiz_rows(labels, data, normal_dat, args, colors):
            if not args['vertical']:
                print_row(*row)
            else:
                vertic = vertically(*row, args=args)

        if args['vertical'] and len_categories == 1:
            if colors:
                color = colors[0]
            else:
                color = None

            print_vertical(vertic, labels, color, args)

        print()
712294
function () {
		if (this.options.dataLabels.enabled) {
			var series = this,
				x,
				y,
				data = series.data,
				seriesOptions = series.options,
				options = seriesOptions.dataLabels,
				str,
				dataLabelsGroup = series.dataLabelsGroup,
				chart = series.chart,
				renderer = chart.renderer,
				inverted = chart.inverted,
				seriesType = series.type,
				color,
				stacking = seriesOptions.stacking,
				isBarLike = seriesType === 'column' || seriesType === 'bar',
				vAlignIsNull = options.verticalAlign === null,
				yIsNull = options.y === null;

			if (isBarLike) {
				if (stacking) {
					// In stacked series the default label placement is inside the bars
					if (vAlignIsNull) {
						options = merge(options, {verticalAlign: 'middle'});
					}

					// If no y delta is specified, try to create a good default
					if (yIsNull) {
						options = merge(options, {y: {top: 14, middle: 4, bottom: -6}[options.verticalAlign]});
					}
				} else {
					// In non stacked series the default label placement is on top of the bars
					if (vAlignIsNull) {
						options = merge(options, {verticalAlign: 'top'});
					}
				}
			}

			// create a separate group for the data labels to avoid rotation
			if (!dataLabelsGroup) {
				dataLabelsGroup = series.dataLabelsGroup =
					renderer.g('data-labels')
						.attr({
							visibility: series.visible ? VISIBLE : HIDDEN,
							zIndex: 6
						})
						.translate(chart.plotLeft, chart.plotTop)
						.add();
			} else {
				dataLabelsGroup.translate(chart.plotLeft, chart.plotTop);
			}

			// determine the color
			color = options.color;
			if (color === 'auto') { // 1.0 backwards compatibility
				color = null;
			}
			options.style.color = pick(color, series.color, 'black');

			// make the labels for each point
			each(data, function (point) {
				var barX = point.barX,
					plotX = (barX && barX + point.barW / 2) || point.plotX || -999,
					plotY = pick(point.plotY, -999),
					dataLabel = point.dataLabel,
					align = options.align,
					individualYDelta = yIsNull ? (point.y >= 0 ? -6 : 12) : options.y;

				// get the string
				str = options.formatter.call(point.getLabelConfig());
				x = (inverted ? chart.plotWidth - plotY : plotX) + options.x;
				y = (inverted ? chart.plotHeight - plotX : plotY) + individualYDelta;

				// in columns, align the string to the column
				if (seriesType === 'column') {
					x += { left: -1, right: 1 }[align] * point.barW / 2 || 0;
				}

				if (inverted && point.y < 0) {
					align = 'right';
					x -= 10;
				}

				// update existing label
				if (dataLabel) {
					// vertically centered
					if (inverted && !options.y) {
						y = y + pInt(dataLabel.styles.lineHeight) * 0.9 - dataLabel.getBBox().height / 2;
					}
					dataLabel
						.attr({
							text: str
						}).animate({
							x: x,
							y: y
						});
				// create new label
				} else if (defined(str)) {
					dataLabel = point.dataLabel = renderer.text(
						str,
						x,
						y
					)
					.attr({
						align: align,
						rotation: options.rotation,
						zIndex: 1
					})
					.css(options.style)
					.add(dataLabelsGroup);
					// vertically centered
					if (inverted && !options.y) {
						dataLabel.attr({
							y: y + pInt(dataLabel.styles.lineHeight) * 0.9 - dataLabel.getBBox().height / 2
						});
					}
				}


				/*if (series.isCartesian) {
					dataLabel[chart.isInsidePlot(plotX, plotY) ? 'show' : 'hide']();
				}*/

				if (isBarLike && seriesOptions.stacking && dataLabel) {
					var barY = point.barY,
						barW = point.barW,
						barH = point.barH;

					dataLabel.align(options, null,
						{
							x: inverted ? chart.plotWidth - barY - barH : barX,
							y: inverted ? chart.plotHeight - barX - barW : barY,
							width: inverted ? barH : barW,
							height: inverted ? barW : barH
						});
				}
			});
		}
	}