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

hexo-tag-googlecharts

v1.0.2

Published

A hexo tag for inserting google charts in your blog.

Downloads

8

Readme

#hexo-tag-googlecharts

Version: 1.0.0

Compatible with Hexo Version 3

About

First, you should go check GoogleCharts docs, so you could understand this plugin's potential.

The google charts tag plugin for hexo helps you add dynamic charts by google into your hexo blog.

Install

This is important. In order for this plugin to work, you'll have to include above the post content, the script for the Google JS API. It should look like this

<script type="text/javascript" src="//www.google.com/jsapi"></script>

Then you should run the following command

npm install hexo-tag-googlecharts --save

How to use it

The tag called googlecharts requires an endtag called endgooglecharts. The main tag can have up to 3 arguments, which none are required, but they have default values that may not be what you wanted. If a chart is created without a type, it'll default to Table. Then the default width is 400, and default height is 400 too.

{% googlecharts ChartType [width [height]] %}

Check google's API to see every type of chart, and now we'll show you how to use it here.

In the content, fist you should have the title of the chart, plain text

{% googlecharts ... %}
  This is the title for the chart
  ....
{% endgooglecharts ... %}

In the next line, you could (optional) have custom options. To tell the plugin you are going to use custom options, you should start the second line with a {. And in that line you should add a JSON object that will be merged with your options. Remember that it has to be a valid JSON, so use jsonlint.com if you need to, and it has to be in one line, so no break lines!

{% googlecharts ... %}
  ....
  {"is3D": true}
  ....
{% endgooglecharts ... %}

Finally, we enter the chart's data. The next row will be the column titles, and then, each row will have it's values. You must list each value separated by a colon, and if the value is a string, don't forget to include simple quotes.

{% googlecharts ... %}
  ....
  'Column1', 'Column2', 'Column3'
  'foo', 28, 5
  'bar', 71, 19
  ....
{% endgooglecharts ... %}

Example

A simple example makes it easy to see how this plugin works.

{% googlecharts ChartType [width [height]] %}
  Title for the Graph
  { "customOptions": true }
  'Column1', 'Column2', 'Column3'
  1000, 28, 5
  5000, 71, 19
  10000, 143, 37
  20000, 282, 68
{% endgooglecharts %}

How the plugin works

If you would like to use a different ChartType, and don't know how, maybe this guide will help.

Supose you go into the Chart Gallery, and you see a chart you like, and the example code is a bit like this:

function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['Year', 'Sales', 'Expenses'],
    ['2013',  1000,      400],
    ['2014',  1170,      460],
    ['2015',  660,       1120],
    ['2016',  1030,      540]
  ]);

  var options = {
    title: 'Company Performance',
    hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},
    vAxis: {minValue: 0}
  };

  var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
  chart.draw(data, options);
}

You now know all you need to know for making this chart.

new google.visualization.AreaChart(

Tells you that it's an AreaChart type.

options = {
  title: 'Company Performance',
  hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},
  vAxis: {minValue: 0}
};

The options, remove the title, height or width, and you have your custom options

{"hAxis": {"title": "Year", "titleTextStyle": {"color": "#333" }}, "vAxis": { "minValue": 0}}

```

And finally, inside `arrayToDataTable` you have the data.
Remove the first `[` and the last `],` of each line, and you have your data.

**Note:** if in the chart example code they use things like `data.addColumn('string', 'Something')`, ignore them, and add the columns the way it's explained in this document. If it doesn't work, you can always inspect the generated Javascript, and see if that's the data you wanted.