timqian / chart.xkcd

xkcd styled chart lib
https://timqian.com/chart.xkcd/
MIT License
7.61k stars 200 forks source link

Control the SVG size and width/height ratio #41

Open chenjiandongx opened 4 years ago

chenjiandongx commented 4 years ago

Hi @timqian, Is there a easy way to control the SVG size?

I try to set width and height attr like this

<svg class="line-chart" width="800px" height="600px"></svg>

but it seem doesn't work. :)

timqian commented 4 years ago

The width of the svg depends on its parent. You can change the width of its parent to change its size.

timqian commented 4 years ago

The ratio of with and height is hard coded to 4/3. Adding a setting to config it might be good. I am considering adding this

chenjiandongx commented 4 years ago

Now div is the parent tag,

  <div width="800px" height="600px" width="800px">
      <svg class="line-chart"></svg>
  </div>

but.. SVG shows incomplete

image

chenjiandongx commented 4 years ago

It would be nice if added a new setting opts for it.

timqian commented 4 years ago

Try

  <div style="width:800px;">
      <svg class="line-chart"></svg>
  </div>
chenjiandongx commented 4 years ago

It works, :)

The ratio of with and height is hard coded to 4/3.

and is this will be changed in the future?

timqian commented 4 years ago

The default will always be 4/3, I think adding an option to change it might be good

timqian commented 4 years ago

I will keep this issue open for size & ratio related updates

chenjiandongx commented 4 years ago

@timqian I'm the author of pyecharts. Echarts is a great visualization library created by Baidu frontend team.

I got an idea that combines chart.xkcd with python. Because your charts lib is so adorable and I like such hand drawing style things.

But now it just an idea and not on the shedule temporarily :)

chenjiandongx commented 4 years ago

@timqian cutecharts opensouce today!

https://github.com/chenjiandongx/cutecharts

timqian commented 4 years ago

@chenjiandongx Nice job! I listed your tool in "who is using chart.xkcd" issue here https://github.com/timqian/chart.xkcd/issues/14

chenjiandongx commented 4 years ago

@timqian Yes, 👍 already.