<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>aruy.net &#187; redmine</title>
	<atom:link href="http://aruy.net/archives/tag/redmine/feed" rel="self" type="application/rss+xml" />
	<link>http://aruy.net</link>
	<description>ちゃんとプログラムが書けるようになりたい。</description>
	<lastBuildDate>Tue, 27 Jul 2010 05:44:54 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Redmineのガントチャートに日付を出したい。</title>
		<link>http://aruy.net/archives/414</link>
		<comments>http://aruy.net/archives/414#comments</comments>
		<pubDate>Thu, 06 Aug 2009 04:29:44 +0000</pubDate>
		<dc:creator>aruy</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[redmine]]></category>

		<guid isPermaLink="false">http://aruy.net/?p=414</guid>
		<description><![CDATA[プロジェクト管理にRedmineを導入してみました。状況を報告する為にガントチャートをPDF出力してみたのですが、時間の単位が日付ではなく週で表示されるのでちょっと不評でした。。。
自分としてはそんなもんかなぁと気になら [...]]]></description>
			<content:encoded><![CDATA[<p>プロジェクト管理にRedmineを導入してみました。状況を報告する為にガントチャートをPDF出力してみたのですが、時間の単位が日付ではなく週で表示されるのでちょっと不評でした。。。</p>
<p>自分としてはそんなもんかなぁと気にならなかったのですが、同僚が<a href="http://labo-ss.net/blog/?itemid=46&#038;catid=2">Redmineのガントチャートに日付の表示を追加</a>を見つけてきてくれたので、ブラウザでの閲覧時には日付を表示出来るように対応してみました。</p>
<p>やったことは参照先のまんまなんではしょりますが、ブラウザで日付で見れるとなると今度はPDFには反映されないの？ってことになります。 </p>
<p>PDFの生成をどこでやっているのかわからないので、ムリです。って答えていたのですが色々調べているウチに/lib/redmine/export/pdf.rbでPDFを生成していそうって事がわかったので実験してみたところ日付が出るようになりました。</p>
<p>rubyがちゃんとわかっているわけではないので、ブラウザに対応した時の対応の真似事をしただけなのですが備忘録として書いておきます。(#addが追加した部分です。)</p>
<p>300行あたり</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">if</span> gantt.<span style="color:#9900CC;">months</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006666;">7</span>
  show_weeks = <span style="color:#0000FF; font-weight:bold;">true</span>
  headers_heigth = <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">*</span>header_heigth
  <span style="color:#9966CC; font-weight:bold;">if</span> gantt.<span style="color:#9900CC;">months</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#006666;">3</span>
    show_days = <span style="color:#0000FF; font-weight:bold;">true</span>
<span style="color:#008000; font-style:italic;">#   headers_heigth = 3*header_heigth</span>
    headers_heigth = <span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">*</span>header_heigth <span style="color:#008000; font-style:italic;">#add</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
g_width = <span style="color:#006666;">210</span>
zoom = <span style="color:#006600; font-weight:bold;">&#40;</span>g_width<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006600; font-weight:bold;">&#40;</span>gantt.<span style="color:#9900CC;">date_to</span> <span style="color:#006600; font-weight:bold;">-</span> gantt.<span style="color:#9900CC;">date_from</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>
g_height = <span style="color:#006666;">120</span>
t_height = g_height <span style="color:#006600; font-weight:bold;">+</span> headers_heigth
&nbsp;
y_start = pdf.<span style="color:#9900CC;">GetY</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Months headers</span>
month_f = gantt.<span style="color:#9900CC;">date_from</span>
left = subject_width
height = header_heigth
gantt.<span style="color:#9900CC;">months</span>.<span style="color:#9900CC;">times</span> <span style="color:#9966CC; font-weight:bold;">do</span> 
  width = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>month_f <span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">-</span> month_f<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">*</span> zoom 
  pdf.<span style="color:#9900CC;">SetY</span><span style="color:#006600; font-weight:bold;">&#40;</span>y_start<span style="color:#006600; font-weight:bold;">&#41;</span>
  pdf.<span style="color:#9900CC;">SetX</span><span style="color:#006600; font-weight:bold;">&#40;</span>left<span style="color:#006600; font-weight:bold;">&#41;</span>
  pdf.<span style="color:#9900CC;">Cell</span><span style="color:#006600; font-weight:bold;">&#40;</span>width, height, <span style="color:#996600;">&quot;#{month_f.year}-#{month_f.month}&quot;</span>, <span style="color:#996600;">&quot;LTR&quot;</span>, <span style="color:#006666;">0</span>, <span style="color:#996600;">&quot;C&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  left = left <span style="color:#006600; font-weight:bold;">+</span> width
  month_f = month_f <span style="color:#006600; font-weight:bold;">&gt;&gt;</span> <span style="color:#006666;">1</span>
<span style="color:#9966CC; font-weight:bold;">end</span>  
&nbsp;
<span style="color:#008000; font-style:italic;"># Weeks headers</span>
<span style="color:#9966CC; font-weight:bold;">if</span> show_weeks
  left = subject_width
  height = header_heigth
  <span style="color:#9966CC; font-weight:bold;">if</span> gantt.<span style="color:#9900CC;">date_from</span>.<span style="color:#9900CC;">cwday</span> == <span style="color:#006666;">1</span>
    <span style="color:#008000; font-style:italic;"># gantt.date_from is monday</span>
    week_f = gantt.<span style="color:#9900CC;">date_from</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    <span style="color:#008000; font-style:italic;"># find next monday after gantt.date_from</span>
    week_f = gantt.<span style="color:#9900CC;">date_from</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">7</span> <span style="color:#006600; font-weight:bold;">-</span> gantt.<span style="color:#9900CC;">date_from</span>.<span style="color:#9900CC;">cwday</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    width = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">7</span> <span style="color:#006600; font-weight:bold;">-</span> gantt.<span style="color:#9900CC;">date_from</span>.<span style="color:#9900CC;">cwday</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">*</span> zoom<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span>
    pdf.<span style="color:#9900CC;">SetY</span><span style="color:#006600; font-weight:bold;">&#40;</span>y_start <span style="color:#006600; font-weight:bold;">+</span> header_heigth<span style="color:#006600; font-weight:bold;">&#41;</span>
    pdf.<span style="color:#9900CC;">SetX</span><span style="color:#006600; font-weight:bold;">&#40;</span>left<span style="color:#006600; font-weight:bold;">&#41;</span>
    pdf.<span style="color:#9900CC;">Cell</span><span style="color:#006600; font-weight:bold;">&#40;</span>width <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span>, height, <span style="color:#996600;">&quot;&quot;</span>, <span style="color:#996600;">&quot;LTR&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    left = left <span style="color:#006600; font-weight:bold;">+</span> width<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006666;">1</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">while</span> week_f <span style="color:#006600; font-weight:bold;">&lt;</span>= gantt.<span style="color:#9900CC;">date_to</span>
    width = <span style="color:#006600; font-weight:bold;">&#40;</span>week_f <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">6</span> <span style="color:#006600; font-weight:bold;">&lt;</span>= gantt.<span style="color:#9900CC;">date_to</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#006666;">7</span> <span style="color:#006600; font-weight:bold;">*</span> zoom : <span style="color:#006600; font-weight:bold;">&#40;</span>gantt.<span style="color:#9900CC;">date_to</span> <span style="color:#006600; font-weight:bold;">-</span> week_f <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">*</span> zoom
    pdf.<span style="color:#9900CC;">SetY</span><span style="color:#006600; font-weight:bold;">&#40;</span>y_start <span style="color:#006600; font-weight:bold;">+</span> header_heigth<span style="color:#006600; font-weight:bold;">&#41;</span>
    pdf.<span style="color:#9900CC;">SetX</span><span style="color:#006600; font-weight:bold;">&#40;</span>left<span style="color:#006600; font-weight:bold;">&#41;</span>
    pdf.<span style="color:#9900CC;">Cell</span><span style="color:#006600; font-weight:bold;">&#40;</span>width, height, <span style="color:#006600; font-weight:bold;">&#40;</span>width <span style="color:#006600; font-weight:bold;">&gt;</span>= <span style="color:#006666;">5</span> ? week_f.<span style="color:#9900CC;">cweek</span>.<span style="color:#9900CC;">to_s</span> : <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">&quot;LTR&quot;</span>, <span style="color:#006666;">0</span>, <span style="color:#996600;">&quot;C&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    left = left <span style="color:#006600; font-weight:bold;">+</span> width
    week_f = week_f<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006666;">7</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Days headers</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">if</span> show_days
  left = subject_width
  height = header_heigth
  wday = gantt.<span style="color:#9900CC;">date_from</span>.<span style="color:#9900CC;">cwday</span> 
  day_num = gantt.<span style="color:#9900CC;">date_from</span> <span style="color:#008000; font-style:italic;">#add</span>
  pdf.<span style="color:#9900CC;">SetFontStyle</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'B'</span>,<span style="color:#006666;">7</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#006600; font-weight:bold;">&#40;</span>gantt.<span style="color:#9900CC;">date_to</span> <span style="color:#006600; font-weight:bold;">-</span> gantt.<span style="color:#9900CC;">date_from</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_i</span>.<span style="color:#9900CC;">times</span> <span style="color:#9966CC; font-weight:bold;">do</span> 
    width = zoom
    pdf.<span style="color:#9900CC;">SetY</span><span style="color:#006600; font-weight:bold;">&#40;</span>y_start <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">*</span> header_heigth<span style="color:#006600; font-weight:bold;">&#41;</span>
    pdf.<span style="color:#9900CC;">SetX</span><span style="color:#006600; font-weight:bold;">&#40;</span>left<span style="color:#006600; font-weight:bold;">&#41;</span>
    pdf.<span style="color:#9900CC;">Cell</span><span style="color:#006600; font-weight:bold;">&#40;</span>width, height, day_name<span style="color:#006600; font-weight:bold;">&#40;</span>wday<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">first</span>, <span style="color:#996600;">&quot;LTR&quot;</span>, <span style="color:#006666;">0</span>, <span style="color:#996600;">&quot;C&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;"># add ここから</span>
    pdf.<span style="color:#9900CC;">SetY</span><span style="color:#006600; font-weight:bold;">&#40;</span>y_start <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">3</span> <span style="color:#006600; font-weight:bold;">*</span> header_heigth<span style="color:#006600; font-weight:bold;">&#41;</span>
    pdf.<span style="color:#9900CC;">SetX</span><span style="color:#006600; font-weight:bold;">&#40;</span>left<span style="color:#006600; font-weight:bold;">&#41;</span>
    pdf.<span style="color:#9900CC;">Cell</span><span style="color:#006600; font-weight:bold;">&#40;</span>width, height, day_num.<span style="color:#9900CC;">day</span>.<span style="color:#9900CC;">to_s</span>, <span style="color:#996600;">&quot;LTR&quot;</span>, <span style="color:#006666;">0</span>, <span style="color:#996600;">&quot;C&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    day_num = day_num <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span>
　  <span style="color:#008000; font-style:italic;"># ここまで   </span>
    left = left <span style="color:#006600; font-weight:bold;">+</span> width
    wday = wday <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span>
    wday = <span style="color:#006666;">1</span> <span style="color:#9966CC; font-weight:bold;">if</span> wday <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">7</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://aruy.net/archives/414/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
