Skip to content

Commit

Permalink
Merge pull request #23 from KarthikRIyer/bar_chart
Browse files Browse the repository at this point in the history
Implement horizontal and stacked bar chart
  • Loading branch information
KarthikRIyer authored Jun 10, 2019
2 parents 6e80865 + 4408282 commit e2bc669
Show file tree
Hide file tree
Showing 31 changed files with 585 additions and 112 deletions.
12 changes: 12 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ let package = Package(
name: "BarChartFilledCircleHatchedExample",
dependencies: ["AGGRenderer", "SVGRenderer", "SwiftPlot"],
path: "examples/BarChartFilledCircleHatched"),
.target(
name: "BarChartOrientationHorizontalExample",
dependencies: ["AGGRenderer", "SVGRenderer", "SwiftPlot"],
path: "examples/BarChartOrientationHorizontal"),
.target(
name: "BarChartVerticalStackedExample",
dependencies: ["AGGRenderer", "SVGRenderer", "SwiftPlot"],
path: "examples/BarChartVerticalStacked"),
.target(
name: "BarChartHorizontalStackedExample",
dependencies: ["AGGRenderer", "SVGRenderer", "SwiftPlot"],
path: "examples/BarChartHorizontalStacked"),
//.testTarget(
// name: "swiftplotTests",
// dependencies: ["swiftplot"]),
Expand Down
24 changes: 24 additions & 0 deletions examples/BarChartHorizontalStacked/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import SwiftPlot
import AGGRenderer
import SVGRenderer

var filePath = "examples/Reference/"
let fileName = "_18_bar_chart_horizontal_stacked"

let x:[String] = ["2008","2009","2010","2011"]
let y:[Float] = [320,-100,420,500]
let y1:[Float] = [100,100,220,245]

var agg_renderer: AGGRenderer = AGGRenderer()
var svg_renderer: SVGRenderer = SVGRenderer()

var plotTitle: PlotTitle = PlotTitle()

var barGraph: BarGraph = BarGraph()
barGraph.addSeries(x, y, label: "Plot 1", color: .orange, graphOrientation: .horizontal)
barGraph.addStackSeries(y1, label: "Plot 2", color: .blue)
plotTitle.title = "BAR CHART"
barGraph.plotTitle = plotTitle

barGraph.drawGraphAndOutput(fileName: filePath+"agg/"+fileName, renderer: agg_renderer)
barGraph.drawGraphAndOutput(fileName: filePath+"svg/"+fileName, renderer: svg_renderer)
22 changes: 22 additions & 0 deletions examples/BarChartOrientationHorizontal/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import SwiftPlot
import AGGRenderer
import SVGRenderer

var filePath = "examples/Reference/"
let fileName = "_08_bar_chart"

let x:[String] = ["2008","2009","2010","2011"]
let y:[Float] = [320,-100,420,500]

var agg_renderer: AGGRenderer = AGGRenderer()
var svg_renderer: SVGRenderer = SVGRenderer()

var plotTitle: PlotTitle = PlotTitle()

var barGraph: BarGraph = BarGraph()
barGraph.addSeries(x, y, label: "Plot 1", color: .orange, graphOrientation: .horizontal)
plotTitle.title = "BAR CHART"
barGraph.plotTitle = plotTitle

barGraph.drawGraphAndOutput(fileName: filePath+"agg/"+fileName, renderer: agg_renderer)
barGraph.drawGraphAndOutput(fileName: filePath+"svg/"+fileName, renderer: svg_renderer)
24 changes: 24 additions & 0 deletions examples/BarChartVerticalStacked/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import SwiftPlot
import AGGRenderer
import SVGRenderer

var filePath = "examples/Reference/"
let fileName = "_17_bar_chart_vertical_stacked"

let x:[String] = ["2008","2009","2010","2011"]
let y:[Float] = [320,-100,420,500]
let y1:[Float] = [100,100,220,245]

var agg_renderer: AGGRenderer = AGGRenderer()
var svg_renderer: SVGRenderer = SVGRenderer()

var plotTitle: PlotTitle = PlotTitle()

var barGraph: BarGraph = BarGraph()
barGraph.addSeries(x, y, label: "Plot 1", color: .orange)
barGraph.addStackSeries(y1, label: "Plot 2", color: .blue)
plotTitle.title = "BAR CHART"
barGraph.plotTitle = plotTitle

barGraph.drawGraphAndOutput(fileName: filePath+"agg/"+fileName, renderer: agg_renderer)
barGraph.drawGraphAndOutput(fileName: filePath+"svg/"+fileName, renderer: svg_renderer)
Binary file modified examples/Reference/agg/_08_bar_chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Reference/agg/_09_bar_chart_forward_slash_hatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Reference/agg/_10_bar_chart_backward_slash_hatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Reference/agg/_11_bar_chart_vertical_hatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Reference/agg/_12_bar_chart_horizontal_hatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Reference/agg/_13_bar_chart_grid_hatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Reference/agg/_14_bar_chart_cross_hatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Reference/agg/_15_bar_chart_hollow_circle_hatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Reference/agg/_16_bar_chart_filled_circle_hatched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/Reference/svg/_08_bar_chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/Reference/svg/_11_bar_chart_vertical_hatched.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/Reference/svg/_12_bar_chart_horizontal_hatched.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/Reference/svg/_13_bar_chart_grid_hatched.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/Reference/svg/_14_bar_chart_cross_hatched.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions examples/Reference/svg/_17_bar_chart_vertical_stacked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e2bc669

Please sign in to comment.