Repository navigation
New features - #35
New features#35nanobowers wants to merge 8 commits into
Conversation
| @@ -0,0 +1,8 @@ | |||
| #!/bin/env ruby | |||
There was a problem hiding this comment.
New example for lineplot with different canvases including :block
| require 'stringio' | ||
|
|
||
| require 'unicode_plot/version' | ||
| require_relative './unicode_plot/version' |
There was a problem hiding this comment.
converted to relative requires because it makes development easier for me, but can revert if you prefer normal require.
| require_relative './unicode_plot/lookup_canvas' | ||
| require_relative './unicode_plot/ascii_canvas' | ||
| require_relative './unicode_plot/dot_canvas' | ||
| require_relative './unicode_plot/block_canvas' |
There was a problem hiding this comment.
new block canvas
| require_relative './unicode_plot/scatterplot' | ||
|
|
||
| # new! | ||
| require_relative './unicode_plot/stairs' |
|
|
||
| char_y = (pixel_y.fdiv(pixel_height) * height).floor + 1 | ||
| char_y_off = pixel_y % Y_PIXEL_PER_CHAR + 1 | ||
| char_x = tx.floor |
There was a problem hiding this comment.
This code is both a fix for interpolation issue #32 but also removes several of the +1 / -1 manipulations needed which were there because the original UnicodePlots.jl (Julia) uses 1-based array indexing.
| @grid[index] = (@grid[index].ord | BRAILLE_SIGNS[char_x_off - 1][char_y_off - 1]).chr(Encoding::UTF_8) | ||
| @colors[index] |= COLOR_ENCODE[color] | ||
| @grid[index] = (@grid[index].ord | BRAILLE_SIGNS[char_x_off][char_y_off]).chr(Encoding::UTF_8) | ||
| # If we can fetch color from color-encode then or with the existing color. |
There was a problem hiding this comment.
Color handling done using fetch where the numeric color is used if the symbol lookup is unsuccessful.
This allows support of the 256 color palette that is in the styled-print.
Please note that if 256 color is used, the mixing (OR'ing) functionality doesn't not work properly.
| @@ -0,0 +1,114 @@ | |||
| # coding: utf-8 | |||
There was a problem hiding this comment.
Oops, did not mean to check this file in yet, heatmap support is not finished.
| char_x = tx.floor + 1 | ||
| char_x_off = pixel_x % x_pixel_per_char + 1 | ||
| char_x += 1 if char_x < tx.round + 1 && char_x_off == 1 | ||
| char_x = tx.floor |
There was a problem hiding this comment.
simlar to canvas.rb, we have
- fixes for 1-index ==> 0-index
- fixes for rounding issue Line has spike while data are monotonous #32
- fixes for color fetching issue Lineplot has a limited number of colors to choose from. #34
| Usage | ||
| ====== | ||
|
|
||
| stairs(x, y; style = :post, name = "", title = "", xlabel = "", ylabel = "", labels = true, border = :solid, margin = 3, padding = 1, color = :auto, width = 40, height = 15, xlim = (0, 0), ylim = (0, 0), canvas = BrailleCanvas, grid = true) |
There was a problem hiding this comment.
comments taken from julia code, will need to clean this up or remove it.
|
|
||
| def print_color(out, color, *args) | ||
| color = COLOR_DECODE[color] | ||
| color = COLOR_DECODE.fetch(color, color) |
There was a problem hiding this comment.
This is also handling the other part of #34
|
@nanobowers Thanks for submitting this pull-request. |
@mrkn
This PR Adds support for
tests included for both stair plots and block canvas which were mostly borrowed from UnicodePlots.jl tests
Also contains issue fixes for
I have also included more examples in the examples directory. Some of them are for getting a quick start for users. Others are exposing issues #32/#34, which may want to eventually either be turned into unit test cases or removed.
If you would like separated PRs for each issue (#17, #19, #32, #34) then please let me know. Thanks!