Skip to content

Instantly share code, notes, and snippets.

@Willy-Kimura
Last active November 20, 2017 11:08
Show Gist options
  • Save Willy-Kimura/c0d3d07fdf9a162b217132c4abd7ad96 to your computer and use it in GitHub Desktop.
Save Willy-Kimura/c0d3d07fdf9a162b217132c4abd7ad96 to your computer and use it in GitHub Desktop.
Method for Line charts generation.
public void GenerateLineCharts()
{
// Create a new canvas for rendering our chart.
Canvas line_chart_canvas = new Canvas();
// Create the first spline chart datapoints-set.
DataPoint line1_datapoints = new DataPoint(BunifuDataViz._type.Bunifu_line);
// Add all the datapoints for the first spline chart.
line1_datapoints.addLabely("1 Jul", "2800");
line1_datapoints.addLabely("3 Jul", "2600");
line1_datapoints.addLabely("5 Jul", "2900");
line1_datapoints.addLabely("7 Jul", "2400");
line1_datapoints.addLabely("9 Jul", "2500");
line1_datapoints.addLabely("11 Jul", "2450");
line1_datapoints.addLabely("14 Jul", "2900");
line1_datapoints.addLabely("16 Jul", "2700");
line1_datapoints.addLabely("19 Jul", "1800");
line1_datapoints.addLabely("22 Jul", "1600");
line1_datapoints.addLabely("24 Jul", "3100");
line1_datapoints.addLabely("26 Jul", "2500");
line1_datapoints.addLabely("29 Jul", "2800");
line1_datapoints.addLabely("31 Jul", "2600");
// Now add the datapoints-set to the canvas created.
line_chart_canvas.addData(line1_datapoints);
// Create the second spline chart datapoints-set.
DataPoint line2_datapoints = new DataPoint(BunifuDataViz._type.Bunifu_line);
// Add all the datapoints for the second spline chart.
line2_datapoints.addLabely("1 Jul", "2000");
line2_datapoints.addLabely("3 Jul", "2400");
line2_datapoints.addLabely("7 Jul", "2500");
line2_datapoints.addLabely("8 Jul", "1800");
line2_datapoints.addLabely("11 Jul", "700");
line2_datapoints.addLabely("15 Jul", "1900");
line2_datapoints.addLabely("18 Jul", "1950");
line2_datapoints.addLabely("19 Jul", "2100");
line2_datapoints.addLabely("22 Jul", "2350");
line2_datapoints.addLabely("24 Jul", "2200");
line2_datapoints.addLabely("27 Jul", "2150");
line2_datapoints.addLabely("29 Jul", "2200");
line2_datapoints.addLabely("32 Jul", "3600");
// Add the datapoints-set to our canvas.
line_chart_canvas.addData(line2_datapoints);
// Finally include the canvas created to a Dataviz component for rendering.
BunifuDataViz1.Render(line_chart_canvas);
}
private void Timer1_Tick(object sender, EventArgs e)
{
// Call the method "GenerateLineCharts()".
GenerateLineCharts();
// Then, once the chart has been rendered, stop the timer.
Timer1.Stop();
// This will ensure that the chart has been generated only after the form has been loaded at runtime.
// Also, it assists in isolating the chart-rendering event and the form-loading process, since it
// initializes chart-rendering after 100 Milliseconds... Also, ensure that your timer is enabled;
// likewise, you can also set a number of milliseconds more if required.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment