|
@@ -2,10 +2,10 @@ module renderable.chart;
|
|
|
|
|
|
import renderable.renderable;
|
|
import renderable.renderable;
|
|
import color;
|
|
import color;
|
|
-import coordinate;
|
|
|
|
|
|
+import coordinates;
|
|
import cell;
|
|
import cell;
|
|
import renderable.renderable;
|
|
import renderable.renderable;
|
|
-import dimension;
|
|
|
|
|
|
+import dimensions;
|
|
import horizontaltextalignment;
|
|
import horizontaltextalignment;
|
|
import verticaltextalignment;
|
|
import verticaltextalignment;
|
|
import renderable.rect;
|
|
import renderable.rect;
|
|
@@ -26,12 +26,12 @@ class Chart : Renderable {
|
|
private CellCacheContainer container;
|
|
private CellCacheContainer container;
|
|
|
|
|
|
this(ChartType chartType, int[] data, int columnWidth, int columnSpace, Color chartColor = Color.White, Color backgroundColor = Color.terminal()) {
|
|
this(ChartType chartType, int[] data, int columnWidth, int columnSpace, Color chartColor = Color.White, Color backgroundColor = Color.terminal()) {
|
|
- Dimension dimension = Dimension(data.maxElement, cast(int)((data.length * columnSpace) + (data.length * columnWidth) - columnSpace));
|
|
|
|
|
|
+ Dimensions dimensions = Dimensions(data.maxElement, cast(int)((data.length * columnSpace) + (data.length * columnWidth) - columnSpace));
|
|
|
|
|
|
if (chartType == ChartType.bar) {
|
|
if (chartType == ChartType.bar) {
|
|
- this.dimension = dimension;
|
|
|
|
|
|
+ this.dimensions = dimensions;
|
|
} else {
|
|
} else {
|
|
- this.dimension = Dimension(dimension.height, dimension.width);
|
|
|
|
|
|
+ this.dimensions = Dimensions(dimensions.height, dimensions.width);
|
|
}
|
|
}
|
|
|
|
|
|
this.chartType = chartType;
|
|
this.chartType = chartType;
|
|
@@ -46,23 +46,23 @@ class Chart : Renderable {
|
|
|
|
|
|
override Cell[] render() {
|
|
override Cell[] render() {
|
|
foreach (indx, num; data) {
|
|
foreach (indx, num; data) {
|
|
- Rect rect = Rect.withFill(Dimension(columnWidth, num), chartColor);
|
|
|
|
|
|
+ Rect rect = Rect.withFill(Dimensions(columnWidth, num), chartColor);
|
|
|
|
|
|
if (chartType == ChartType.bar) {
|
|
if (chartType == ChartType.bar) {
|
|
- rect.dimension = Dimension(rect.dimension.height, rect.dimension.width);
|
|
|
|
|
|
+ rect.dimensions = Dimensions(rect.dimensions.height, rect.dimensions.width);
|
|
}
|
|
}
|
|
|
|
|
|
- Coordinate coordinates = Coordinate(0, cast(int)((indx * columnSpace) + (indx * columnWidth)));
|
|
|
|
|
|
+ Coordinates coordinates = Coordinates(0, cast(int)((indx * columnSpace) + (indx * columnWidth)));
|
|
|
|
|
|
if (chartType == ChartType.bar) {
|
|
if (chartType == ChartType.bar) {
|
|
container.updateCache(rect, coordinates);
|
|
container.updateCache(rect, coordinates);
|
|
} else {
|
|
} else {
|
|
- container.updateCache(rect, Coordinate(coordinates.y, this.dimension.height - num));
|
|
|
|
|
|
+ container.updateCache(rect, Coordinates(coordinates.y, this.dimensions.height - num));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (backgroundColor != Color.terminal()) {
|
|
if (backgroundColor != Color.terminal()) {
|
|
- container.updateCache(Rect.withFill(Dimension(dimension.width, dimension.height), backgroundColor), Coordinate(0, 0));
|
|
|
|
|
|
+ container.updateCache(Rect.withFill(Dimensions(dimensions.width, dimensions.height), backgroundColor), Coordinates(0, 0));
|
|
}
|
|
}
|
|
|
|
|
|
return container.cache;
|
|
return container.cache;
|