Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

c3

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

c3 - npm Package Compare versions

Comparing version 0.7.10 to 0.7.11

2

package.json
{
"name": "c3",
"version": "0.7.10",
"version": "0.7.11",
"description": "D3-based reusable chart library",

@@ -5,0 +5,0 @@ "main": "c3.js",

@@ -23,3 +23,3 @@ import {

var c3 = {
version: "0.7.10",
version: "0.7.11",
chart: {

@@ -26,0 +26,0 @@ fn: Chart.prototype,

@@ -518,2 +518,28 @@ import CLASS from './class';

/**
* Find the closest point from the x value or undefined if none satisfies conditions.
*
* @param {Array} targets
* @param {Array} x A value on X axis
* @return {Object|undefined}
*/
ChartInternal.prototype.findClosestFromTargetsByX = function (targets, x) {
let closest;
let diff;
targets
.forEach((t) => {
t.values.forEach((d) => {
let newDiff = Math.abs(x - d.x);
if (diff === undefined || newDiff < diff) {
closest = d;
diff = newDiff;
}
});
});
return closest;
};
/**
* Using given compute distance method, returns the closest data point from the

@@ -520,0 +546,0 @@ * given position.

@@ -38,11 +38,2 @@ import CLASS from './class';

// converts 'x' position (in pixel) to category index
const maxDataCount = $$.getMaxDataCount();
const xEventScale = d3.scaleQuantize()
// use X range (in pixel) as domain
.domain([0, config.axis_rotated ? $$.height : $$.width])
// 0 to N evenly distributed
.range(maxDataCount ? Array.apply(null, { length: maxDataCount }).map(Function.call, Number) : [0]);
const withName = (d) =>

@@ -105,13 +96,27 @@ d ? $$.addName(Object.assign({}, d)) : null;

if (showSingleDataPoint) {
if (!closest) {
return mouseout();
if (closest) {
selectedData = [ closest ];
}
selectedData = [closest];
} else {
const mouseX = config.axis_rotated ? mouse[1] : mouse[0];
let closestByX;
if (closest) {
// reuse closest value
closestByX = closest;
} else {
// try to find the closest value by X values from the mouse position
const mouseX = config.axis_rotated ? mouse[1] : mouse[0];
closestByX = $$.findClosestFromTargetsByX(targetsToShow, $$.x.invert(mouseX));
}
selectedData = $$.filterByIndex(targetsToShow, xEventScale(mouseX));
// highlight all data for this 'x' value
if (closestByX) {
selectedData = $$.filterByX(targetsToShow, closestByX.x);
}
}
// ensure we have data to show
if (!selectedData || selectedData.length === 0) {
return mouseout();
}
// inject names for each point

@@ -118,0 +123,0 @@ selectedData = selectedData.map(withName);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc