Skip to content

Instantly share code, notes, and snippets.

@Willy-Kimura
Created November 21, 2017 10:17
Show Gist options
  • Save Willy-Kimura/e2e49ac68b3ee7d63c01a31856a83135 to your computer and use it in GitHub Desktop.
Save Willy-Kimura/e2e49ac68b3ee7d63c01a31856a83135 to your computer and use it in GitHub Desktop.
Method for generating Dataviz charts.
private void GenerateCharts()
{
// Let's begin by generating a chart that consists of an Area chart and a Line chart.
// We need to create one canvas that will host the first two charts inside it, that is,
// the Area chart and Line chart.
Canvas multi_chart_canvas = new Canvas();
// Create a new datapoints-set for the first chart - Area chart.
DataPoint area_chart_datapoints = new DataPoint(BunifuDataViz._type.Bunifu_area);
// Add the datapoints for the Area chart.
area_chart_datapoints.addLabely("l1", "45");
area_chart_datapoints.addLabely("l2", "60");
area_chart_datapoints.addLabely("l3", "50");
area_chart_datapoints.addLabely("l4", "80");
area_chart_datapoints.addLabely("l5", "70");
area_chart_datapoints.addLabely("l6", "90");
area_chart_datapoints.addLabely("l7", "100");
area_chart_datapoints.addLabely("l8", "95");
area_chart_datapoints.addLabely("l9", "60");
area_chart_datapoints.addLabely("l10", "45");
// Now add the Area chart to the canvas we created.
multi_chart_canvas.addData(area_chart_datapoints);
// Create a new datapoints-set for the second chart - Line chart.
DataPoint line_chart_datapoints = new DataPoint(BunifuDataViz._type.Bunifu_line);
// Add the datapoints for the Line chart.
line_chart_datapoints.addLabely("", "55");
line_chart_datapoints.addLabely("", "70");
line_chart_datapoints.addLabely("", "60");
line_chart_datapoints.addLabely("", "90");
line_chart_datapoints.addLabely("", "80");
line_chart_datapoints.addLabely("", "100");
line_chart_datapoints.addLabely("", "110");
line_chart_datapoints.addLabely("", "105");
line_chart_datapoints.addLabely("", "70");
line_chart_datapoints.addLabely("", "55");
// Then add the Line chart to the canvas we created.
multi_chart_canvas.addData(line_chart_datapoints);
// Finally render the multiple-chart canvas in our Dataviz component.
BunifuDataViz1.Render(multi_chart_canvas);
// Let's now create a new canvas for the Doughnut chart.
Canvas doughnut_chart_canvas = new Canvas();
DataPoint doughnut_chart_datapoints = new DataPoint(BunifuDataViz._type.Bunifu_doughnut);
// Add the datapoints for the Doughnut chart.
doughnut_chart_datapoints.addLabely("", "45");
doughnut_chart_datapoints.addLabely("", "60");
doughnut_chart_datapoints.addLabely("", "50");
doughnut_chart_datapoints.addLabely("", "80");
doughnut_chart_datapoints.addLabely("", "70");
doughnut_chart_datapoints.addLabely("", "90");
// Then add the Doughnut chart to the canvas we created.
doughnut_chart_canvas.addData(doughnut_chart_datapoints);
// Finally render the Doughnut chart canvas in our Dataviz component.
BunifuDataViz2.Render(doughnut_chart_canvas);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment