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

mapd3

Package Overview
Dependencies
Maintainers
6
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapd3 - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0

2

package.json
{
"name": "mapd3",
"version": "0.14.0",
"version": "0.15.0",
"description": "A fast chart library for the fastest DB",

@@ -5,0 +5,0 @@ "main": "dist/mapd3.js",

@@ -92,3 +92,5 @@ import * as d3 from "./helpers/d3-service"

function formatXAxis () {
if (config.keyType === "time") {
if (typeof config.xAxisFormat === "function") {
cache.xAxis.tickFormat(config.xAxisFormat)
} else if (config.keyType === "time") {
if (config.xAxisFormat && config.xAxisFormat !== "auto") {

@@ -121,3 +123,5 @@ const formatter = d3.utcFormat(config.xAxisFormat)

}
if (config.yAxisFormat === "auto") {
if (typeof config.yAxisFormat === "function") {
axis.tickFormat(config.yAxisFormat)
} else if (config.yAxisFormat === "auto") {
const yExtent = config.yDomain === "auto" ? scales.yScale.domain() : config.yDomain

@@ -137,3 +141,5 @@ const yFormat = autoFormat(yExtent, config.numberFormat)

}
if (config.y2AxisFormat === "auto") {
if (typeof config.y2AxisFormat === "function") {
axis.tickFormat(config.y2AxisFormat)
} else if (config.y2AxisFormat === "auto") {
const y2Extent = config.y2Domain === "auto" ? scales.y2Scale.domain() : config.y2Domain

@@ -140,0 +146,0 @@ const y2Format = autoFormat(y2Extent, config.numberFormat)

@@ -95,2 +95,3 @@ import * as d3 from "./helpers/d3-service"

numberFormat: ".2f",
tooltipTitleFormat: null,

@@ -97,0 +98,0 @@ // legend

@@ -92,2 +92,7 @@ import {keys} from "./constants"

export function isNumberString (val) {
// eslint-disable-next-line eqeqeq
return Number(parseFloat(val)) == val
}
export function isNumeric (val) {

@@ -94,0 +99,0 @@ return Number(parseFloat(val)) === val

import * as d3 from "./helpers/d3-service"
import {keys, dashStylesTranslation} from "./helpers/constants"
import {isNumeric, override} from "./helpers/common"
import {isNumeric, isNumberString, override} from "./helpers/common"
import {binTranslation, formatOddDateBin, formatTooltipNumber} from "./helpers/formatters"

@@ -28,2 +28,3 @@

tooltipFormat: null,
tooltipTitleFormat: null,

@@ -137,7 +138,7 @@ markPanelWidth: null,

function formatValue (_value, _format, _index) {
if (typeof _format === "string" && _format !== "auto") {
function applyFormat (_value, _format) {
if (typeof _format === "function") {
return _format(_value)
} else if (typeof _format === "string" && _format !== "auto") {
return d3.format(_format)(_value)
} else if (Array.isArray(_format)) {
return _format[_index] ? d3.format(_format[_index])(_value) : formatTooltipNumber(_value)
} else {

@@ -148,2 +149,10 @@ return formatTooltipNumber(_value)

function formatValue (_value, _format, _index) {
if (Array.isArray(_format) && _format[_index]) {
return applyFormat(_value, _format[_index])
} else {
return applyFormat(_value, _format)
}
}
function drawContent () {

@@ -235,8 +244,10 @@ const tooltipItems = cache.tooltipBody.selectAll(".tooltip-item")

// format date if we have a date
if (title instanceof Date) {
if (typeof config.tooltipTitleFormat === "function" && typeof title !== "string") {
title = config.tooltipTitleFormat(title)
} else if (title instanceof Date) {
const {binningResolution} = config
const specifier = binTranslation[binningResolution]
if (specifier) {
if (config.tooltipTitleFormat !== "auto") {
title = d3.utcFormat(config.tooltipTitleFormat)(title)
} else if (specifier) {
title = d3.utcFormat(specifier)(title)

@@ -250,3 +261,8 @@ } else if (["1w", "1q", "10y", "1c"].indexOf(binningResolution) > -1) {

} else if (isNumeric(title)) {
title = formatTooltipNumber(title)
title = Number(parseFloat(title))
if (config.tooltipTitleFormat) {
title = applyFormat(title, config.tooltipTitleFormat)
} else {
title = formatTooltipNumber(title)
}
}

@@ -284,3 +300,8 @@

setYPosition(tooltipY)
setTitle(_dataPoint[keys.KEY])
let title = _dataPoint[keys.KEY]
if (isNumberString(title)) {
title = Number(parseFloat(title))
}
setTitle(title)
setupContent(_dataPoint[keys.SERIES])

@@ -287,0 +308,0 @@

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