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

catchart

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

catchart - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

46

client.js

@@ -8,4 +8,9 @@ const Chart = require('chart.js')

function main() {
const context = global.$$context
if (context.showValueLabels) {
labelPlugin()
}
const chartData = {

@@ -129,2 +134,43 @@ datasets: [],

return patternNames[patternIndex++]
}
function labelPlugin() {
Chart.plugins.register({
afterDatasetsDraw
})
function afterDatasetsDraw(chart, easing) {
// To only draw at the end of animation, check for easing === 1
var ctx = chart.ctx
for (let i = 0; i < chart.data.datasets.length; i++) {
let dataset = chart.data.datasets[i]
var meta = chart.getDatasetMeta(i)
if (!meta.hidden) {
for (let j = 0; j < meta.data.length; j++) {
let element = meta.data[j]
// Draw the text in black, with the specified font
ctx.fillStyle = 'rgb(0, 0, 0)'
var fontSize = 16
var fontStyle = 'normal'
var fontFamily = 'Helvetica Neue'
ctx.font = Chart.helpers.fontString(fontSize, fontStyle, fontFamily)
// Just naively convert to string for now
var dataString = dataset.data[j].toString()
// Make sure alignment settings are correct
ctx.textAlign = 'center'
ctx.textBaseline = 'middle'
var padding = 5
var position = element.tooltipPosition()
ctx.fillText(dataString, position.x, position.y - (fontSize / 2) - padding)
}
}
}
}
}

4

config.js
const rc = require('rc')
// TODO unify these comments with program.js
module.exports = rc('catchart', {

@@ -28,2 +29,5 @@ rowSeparator: '\n',

// show labels on values in the chart
showValueLabels: false,
// do not fill the area under chart lines with color

@@ -30,0 +34,0 @@ noFill: false,

3

index.js

@@ -154,3 +154,4 @@ const hcat = require('hcat')

title: config.title,
fieldCount: config.fieldCount
fieldCount: config.fieldCount,
showValueLabels: config.showValueLabels
}

@@ -157,0 +158,0 @@

{
"name": "catchart",
"version": "1.0.4",
"version": "1.1.0",
"description": "Pipe something from command line to a browser chart",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -21,2 +21,3 @@ const program = require('commander')

value in each row will be considered the label`, 'auto')
.option('--showValueLabels', 'show labels on values in the chart', config.showValueLabels)
.option('--noFill', 'Do not fill the area under the chart line with color', config.noFill)

@@ -23,0 +24,0 @@ .option('--usePatterns', 'Fill the area under the chart line with a pattern, this is meant for individuals who suffer from color blindness', config.usePatterns)

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