1 module libxlsxd.chart;
2 
3 import libxlsxd.xlsxwrap;
4 
5 struct Chart {
6 	import libxlsxd.types;
7 	import std.exception : enforce;
8 	import std.string : toStringz;
9 	import libxlsxd.chartseries;
10 	import libxlsxd.chartaxis;
11 
12 	lxw_chart* handle;
13 
14 	this(lxw_chart* handle) @nogc nothrow pure @safe {
15 		this.handle = handle;
16 	}
17 
18 	void free() @trusted {
19 		lxw_chart_free(this.handle);
20 	}
21 
22 	void assembleXmlFile() @trusted {
23 		lxw_chart_assemble_xml_file(this.handle);
24 	}
25 
26 	Chartseries addChartseries(string categories, string values) @trusted {
27 		return Chartseries(chart_add_series(this.handle, toStringz(categories),
28 					toStringz(values)
29 				));
30 	}
31 
32 	Chartaxis axisGet(lxw_chart_axis_type axisType) @trusted {
33 		return Chartaxis(chart_axis_get(this.handle, axisType));
34 	}
35 
36 	void titleSetName(string title) nothrow @trusted {
37 		chart_title_set_name(this.handle, toStringz(title));
38 	}
39 
40 	void titleSetNameRange(string sheetname, RowType row, ColType col) nothrow
41 			@trusted
42 	{
43 		chart_title_set_name_range(this.handle, toStringz(sheetname), row, col);
44 	}
45 
46 	void titleSetNameFont(lxw_chart_font* font) nothrow @nogc @trusted {
47 		chart_title_set_name_font(this.handle, font);
48 	}
49 
50 	void titleOff() nothrow @nogc @trusted {
51 		chart_title_off(this.handle);
52 	}
53 
54 	void legendSetPosition(ubyte pos) nothrow @nogc @trusted {
55 		chart_legend_set_position(this.handle, pos);
56 	}
57 
58 	void legendSetFont(lxw_chart_font* font) nothrow @nogc @trusted {
59 		chart_legend_set_font(this.handle, font);
60 	}
61 
62 	lxw_error legendDeleteSeries(short[] series) nothrow @nogc @trusted {
63 		return chart_legend_delete_series(this.handle, series.ptr);
64 	}
65 
66 	void chartareaSetLine(lxw_chart_line* line) nothrow @nogc @trusted {
67 		chart_chartarea_set_line(this.handle, line);
68 	}
69 
70 	void chartareaSetFill(lxw_chart_fill* fill) nothrow @nogc @trusted {
71 		chart_chartarea_set_fill(this.handle, fill);
72 	}
73 
74 	void chartareaSetPattern(lxw_chart_pattern* pattern) nothrow @nogc @trusted {
75 		chart_chartarea_set_pattern(this.handle, pattern);
76 	}
77 
78 	void plotareaSetLine(lxw_chart_line* line) nothrow @nogc @trusted {
79 		chart_plotarea_set_line(this.handle, line);
80 	}
81 
82 	void plotareaSetFill(lxw_chart_fill* fill) nothrow @nogc @trusted {
83 		chart_plotarea_set_fill(this.handle, fill);
84 	}
85 
86 	void plotareaSetPattern(lxw_chart_pattern* pattern) nothrow @nogc @trusted {
87 		chart_plotarea_set_pattern(this.handle, pattern);
88 	}
89 
90 	void setStyle(ubyte style) nothrow @nogc @trusted {
91 		chart_set_style(this.handle, style);
92 	}
93 
94 	void setTable() nothrow @nogc @trusted {
95 		chart_set_table(this.handle);
96 	}
97 
98 	void setTableGrid(ubyte hori, ubyte vert, ubyte outline, ubyte keys)
99 			nothrow @nogc @trusted
100 	{
101 		chart_set_table_grid(this.handle, hori, vert, outline, keys);
102 	}
103 
104 	void setTableFont(lxw_chart_font* font) nothrow @nogc @trusted {
105 		chart_set_table_font(this.handle, font);
106 	}
107 
108 	void setUpDownBars() nothrow @nogc @trusted {
109 		chart_set_up_down_bars(this.handle);
110 	}
111 
112 	void setUpDownBarsFormat(lxw_chart_line* upBarLine,
113 			lxw_chart_fill* upBarFill, lxw_chart_line* downBarLine,
114 			lxw_chart_fill* downBarFill) nothrow @nogc @trusted
115 	{
116 		chart_set_up_down_bars_format(this.handle, upBarLine, upBarFill,
117 				downBarLine, downBarFill);
118 	}
119 
120 	void setDropLines(lxw_chart_line* line) nothrow @nogc @trusted {
121 		chart_set_drop_lines(this.handle, line);
122 	}
123 
124 	void setHighLowLines(lxw_chart_line* line) nothrow @nogc @trusted {
125 		chart_set_high_low_lines(this.handle, line);
126 	}
127 
128 	void setSeriesOverlap(byte overlap) nothrow @nogc @trusted {
129 		chart_set_series_overlap(this.handle, overlap);
130 	}
131 
132 	void setSeriesGap(ushort gap) nothrow @nogc @trusted {
133 		chart_set_series_gap(this.handle, gap);
134 	}
135 
136 	void showBlanksAs(ubyte blanks) nothrow @nogc @trusted {
137 		chart_show_blanks_as(this.handle, blanks);
138 	}
139 
140 	void showHiddenData() nothrow @nogc @trusted {
141 		chart_show_hidden_data(this.handle);
142 	}
143 
144 	void setRotation(ushort rotation) nothrow @nogc @trusted {
145 		chart_set_rotation(this.handle, rotation);
146 	}
147 
148 	void setHoleSize(ubyte size) nothrow @nogc @trusted {
149 		chart_set_hole_size(this.handle, size);
150 	}
151 }