ChartJS SCatter Type - How to add DataSet

0
0

Hi,

How to add Dataset to Scatter Chart ?

 

I saw in the Extension code that I have to add as object containing X and Y properties … but how ?

/// <summary>
/// Scatter charts are based on basic line charts with the x axis changed to a linear axis.
/// To use a scatter chart, data must be passed as objects containing X and Y properties.
/// </summary>
Scatter

Regards

 

  • MARCELO BLANK
    Done… First create a class Point public class Point { public int X { get; set; } public int Y { get; set; } } Then, in the code: private void ChartsValue() { chartJS1.ChartType = Wisej.Web.Ext.ChartJS.ChartType.Scatter; Wisej.Web.Ext.ChartJS.DataSet oDatasetValue = new Wisej.Web.Ext.ChartJS.DataSet(); oDatasetValue.Label = “Value”; oDatasetValue.Data= GetDataValueXY(); chartJS1.DataSets.Add(oDatasetValue); chartJS1.UpdateData(); } private object[] GetDataValueXY() { var data = new[] { new Point { X = 5, Y = 3 }, new Point { X = 6, Y = 4 }}; return data; }
  • You must to post comments
0
0

Hi Marcelo,

in that case you´re probably better off using ChartJs directly inside a Wisej.Web.Widget.
You´d need to handle it with Javascript callbacks.
See Chartjs documentation and configure it like you would do in a plain html page.

https://www.chartjs.org/docs/latest/configuration/legend.html#legend-label-configuration

Best regards
Frank

  • You must to post comments
0
0

Great Frank

Is there an way to put a legend to each point ?

Regards

  • You must to post comments
0
0

Hi Marcelo,

you can achieve it with code like this:

chartjs_scatter_code

Sample chart:

chartjs_scatter_chart

Hope that helps.

Best regards
Frank

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.