@hettiger/d3js-wordcloud
Advanced tools
Comparing version 0.0.0 to 0.0.1
10
index.ts
@@ -8,7 +8,7 @@ import * as d3 from 'd3'; | ||
export class D3JsWordcloud { | ||
static init(targetElement: HTMLDivElement, tags: {"key": string, "value": number}[]) { | ||
static init(targetElement: HTMLDivElement, ratio: number, tags: {"key": string, "value": number}[]) { | ||
var fill = d3.scale.category20b(); | ||
var w = window.innerWidth, | ||
h = window.innerHeight; | ||
var w = targetElement.parentElement.offsetWidth, | ||
h = targetElement.parentElement.offsetWidth * ratio; | ||
@@ -45,4 +45,4 @@ var max, | ||
function draw(data, bounds) { | ||
var w = window.innerWidth, | ||
h = window.innerHeight; | ||
var w = targetElement.parentElement.offsetWidth, | ||
h = targetElement.parentElement.offsetWidth * ratio; | ||
@@ -49,0 +49,0 @@ svg.attr("width", w).attr("height", h); |
{ | ||
"name": "@hettiger/d3js-wordcloud", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Responsive wordclouds utilizing d3js.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,3 +22,8 @@ @hettiger/d3js-wordcloud | ||
document.body.appendChild(targetElement); | ||
D3JsWordcloud.init(targetElement, tags); | ||
D3JsWordcloud.init(targetElement, 0.5625, tags); | ||
``` | ||
### Size | ||
The cloud inherits it's width from the parent element. | ||
The height is calculated from the ratio provided. (width * ratio) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
29
429527