npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ywlee/k-means-js

v1.0.0

Published

k-means algorithm in javascript

Downloads

2

Readme

kmeans-js

  • Clickable/Interactive kmeans algorithm in javascript
  • It can be integrated into a web application
  • It is based on d3

Setup

Include the libraries

<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="../dist/kmeansjs.min.js"></script>
<link rel="stylesheet" href="../dist/kmeansjs.min.css"></link>

CDN - UNPKG

  • TODO

Usage

Hello World example

Create an element to hold the table

<div id="mykmeans"></div>

Turn the div element into a d3 scatter chart with some simple javascript

var mykmeans = kmeansjs.kmeans();
mykmeans.init(document.getElementById("mykmeans"), {
    selectedDataSet: [
    {age: 37, year_of_operation: 63, positive_axillary_nodes: 0, survival_status: 1},
    {age: 43, year_of_operation: 58, positive_axillary_nodes: 52, survival_status: 2},
    {age: 43, year_of_operation: 59, positive_axillary_nodes: 2, survival_status: 2},
    {age: 43, year_of_operation: 63, positive_axillary_nodes: 14, survival_status: 1},
    {age: 43, year_of_operation: 64, positive_axillary_nodes: 2, survival_status: 1},
    {age: 46, year_of_operation: 65, positive_axillary_nodes: 20, survival_status: 2},
    {age: 48, year_of_operation: 66, positive_axillary_nodes: 0, survival_status: 1},
    {age: 50, year_of_operation: 61, positive_axillary_nodes: 0, survival_status: 1},
    {age: 54, year_of_operation: 62, positive_axillary_nodes: 0, survival_status: 1},
    {age: 58, year_of_operation: 61, positive_axillary_nodes: 2, survival_status: 1}
    ], 
    selectedColumns: ["age", "year_of_operation"]
});

hello

Take a look at examples/hello.html for more information

Work with the chart table

Include the libraries

<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="../dist/kmeansjs.min.js"></script>
<script src="../dist/charttable.min.js"></script>
<link rel="stylesheet" href="../dist/kmeansjs.min.css"></link>
<link rel="stylesheet" href="../dist/charttable.min.css"></link>

Create div elements to hold the table

<div id="mytable"></div>
<div id="mykmeans"></div>

Work with chart table

const mytable = charttable.table();
const mykmeans = kmeansjs.kmeans();
const tol_vibrant = ["#EE7733", "#0077BB", "#33BBEE", "#EE3377", "#CC3311", "#009988"];
mytable.initTbl(document.getElementById("mytable"), {
    colors: tol_vibrant,
    minSelectedRow2Show: 4,
    minSelectedCol2Show: 2,
    height: 540,
    onSelect: function(data) {
    mykmeans.init(document.getElementById("mykmeans"), {
        selectedDataSet: data.selectedRows, 
        selectedColumns: data.selectedColumns
    });
    }
});

mytable.showDataset([
    {age: 30, year_of_operation: 65, positive_axillary_nodes: 0, survival_status: 1},
    {age: 38, year_of_operation: 66, positive_axillary_nodes: 0, survival_status: 1},
    {age: 42, year_of_operation: 59, positive_axillary_nodes: 0, survival_status: 2},
    {age: 49, year_of_operation: 63, positive_axillary_nodes: 0, survival_status: 2},
    {age: 49, year_of_operation: 61, positive_axillary_nodes: 0, survival_status: 1},
    {age: 55, year_of_operation: 66, positive_axillary_nodes: 18, survival_status: 1},
    {age: 56, year_of_operation: 60, positive_axillary_nodes: 0, survival_status: 1},
    {age: 61, year_of_operation: 65, positive_axillary_nodes: 0, survival_status: 2},
    {age: 61, year_of_operation: 59, positive_axillary_nodes: 0, survival_status: 1},
    {age: 64, year_of_operation: 66, positive_axillary_nodes: 0, survival_status: 1}
]);

charttable

TODO

  • use webpack to build
  • publish to npm and CDN - UNPKG
  • remove charttable.min.js once we can publish to npm