NAME
WebService::Pixela::Graph - It's Pixela Graph API client
SYNOPSIS
use strict;
use warnings;
use utf8;
use WebService::Pixela;
# All WebService::Pixela methods use this token and user name in URI, JSON, etc.
my $pixela = WebService::Pixela->new(username => $username, token => $token);
my $graph = $pixela->graph;
$graph->id('thisisgraphid')->create(name => 'graphname', unit => 'test',
type => 'int', color => 'sora', timezone => 'Asis/Tokyo');
my $graphs = $graph->get();
print $graphs->[0]->{id};
my $svg = $graphs->get_svg();
$graphs->update(name => 'update_graph_name',...);
# set html url
my $url = $graphs->html();
my $pixels = $graphs->pixels();
# delete graph
$graphs->delete();
DESCRIPTION
WebService::Pixela::Graph is user API client about Pixe.la webservice.
INTERFACE
instance methods
This instance method require WebService::Pixela instance. So, Usually use these methods from the WebService::Pixela
instance.
$pixela->graph->create(%opts) :$hash_ref
It is Pixe.la graph create.
%opts might be:
[required (autoset)] id : Str
-
It is an ID for identifying the pixelation graph.
If set in an instance of WebService::Pixela::Graph, use that value.
[required] name : Str
-
It is the name of the pixelation graph.
[required] unit : Str
-
It is a unit of the quantity recorded in the pixelation graph. Ex. commit, kilogram, calory.
[required] type : Str
-
It is the type of quantity to be handled in the graph. Only int or float are supported.
[required] color : Str
-
Defines the display color of the pixel in the pixelation graph. shibafu (green), momiji (red), sora (blue), ichou (yellow), ajisai (purple) and kuro (black) are supported as color kind.
timezone : Str
-
[optional] Specify the timezone for handling this graph as Asia/Tokyo. If not specified, it is treated as UTC.
self_sufficient : Str
-
[optional] If SVG graph with this field increment or decrement is referenced, Pixel of this graph itself will be incremented or decremented. It is suitable when you want to record the PVs on a web page or site simultaneously. The specification of increment or decrement is the same as Increment a Pixel and Decrement a Pixel with webhook. If not specified, it is treated as none .
See Also https://docs.pixe.la/#/post-graph
$pixela->graph->get()
Get all predefined pixelation graph definitions.
If you setting $pixela-decode(1) [default]> return array refs. Otherwise it returns json.
See Also https://docs.pixe.la/#/get-graph
$pixela->graph->get_svg(%args)
%opts might be:
data :Str
-
[optional] If you specify it in yyyyMMdd format, will create a pixelation graph dating back to the past with that day as the start date. If this parameter is not specified, the current date and time will be the start date. (it is used
<timezone
> setting if Graph’s<timezone
> is specified, if not specified, calculates it in<UTC
>) mode :Str
-
[optional] Specify the graph display mode. As of October 23, 2018, support only short mode for displaying only about 90 days.
See Also https://docs.pixe.la/#/get-svg
$pixela->graph->update(%args)
%options might be $pixela->graph->create()
options.
See Also https://docs.pixe.la/#/put-graph
$pixela->graph->delete()
Delete the predefined pixelation graph definition.
See Also https://docs.pixe.la/#/delete-graph
$pixela->graph->html(%args)
Displays the details of the graph in html format. (This method return html urls)
%args might be
[required (autoset)] id : Str
-
It is an ID for identifying the pixelation graph.
If set in an instance of WebService::Pixela::Graph, use that value.
( line => true )
-
[optional] URI tail add line mode parameter.
See Also https://docs.pixe.la/#/get-graph-html
$pixela->graph->pixels(%args)
Get a Date list of Pixel registered in the graph specified by graphID. You can specify a period with from and to parameters.
%args might be
from :Str
-
[optional] Specify the start position of the period.
to : Str
-
[optional] Specify the end position of the period.
See Also https://docs.pixe.la/#/get-graph-pixels
$pixela->graph->stats($id)
Based on the registered information, get various statistics.
$id might be
[required (autoset)] id : Str
-
It is an ID for identifying the pixelation graph.
If set in an instance of WebService::Pixela::Graph, use that value.
See Also https://docs.pixe.la/entry/get-graph-stats
LICENSE
Copyright (C) Takahiro SHIMIZU.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Takahiro SHIMIZU <anatofuz@gmail.com>