Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candle Stick Chart #54

Open
ghostjat opened this issue Nov 21, 2021 · 3 comments
Open

Candle Stick Chart #54

ghostjat opened this issue Nov 21, 2021 · 3 comments
Assignees

Comments

@ghostjat
Copy link

Hi,
is this library support Candle Stick Chart type?

@goat1000
Copy link
Owner

Not exactly, but there is a box and whisker graph which looks very similar. It is described on this page: https://www.goat1000.com/svggraph-misc.php

I could add a candle stick chart quite easily since it is so similar to the box and whisker type.

@goat1000 goat1000 self-assigned this Dec 3, 2021
@goat1000
Copy link
Owner

goat1000 commented Dec 8, 2021

I've added a CandlestickGraph graph type in commit b61f1af - here's an example graph using some random data:

<?php
require_once 'SVGGraph/autoloader.php';

$options = [
  'structure' => [
    'key' => 0,
    'value' => 1, // close
    'open' => 2,
    'low' => 3,
    'high' => 4,
  ],
  'axis_font' => 'Arial',
  'axis_text_angle_h' => 90,
  'bar_space' => 5,
  'axis_min_v' => 1700,
];

$close = 1820;
$seed = 1241231;
srand($seed);
$values = [];
for($i = 1; $i < 32; ++$i) {
  $date = sprintf('Oct %02d', $i);
  $open = $close;
  $close = $close + rand(-30, 40);
  $low = min($open, $close) - rand(0, 40);
  $high = max($open, $close) + rand(0, 80);
  $values[] = [$date, $close, $open, $low, $high];
}

$g = new \Goat1000\SVGGraph\SVGGraph(600, 400, $options);
$g->values($values);
$g->colourRangeHexHSL(0, '#0c4', '#0c9');
$g->colourRangeHexHSL(1, '#f00', '#f55');
$g->render('CandlestickGraph');

@goat1000
Copy link
Owner

goat1000 commented Dec 8, 2021

This is what it looks like:

candlestick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants