ChartJS - how to send data to javascript function to create a chartjs via htmlpanel

0
0

Is there any examples on how to send (data and labels) from server side to a javascript function to create a chartJs dynamically?

I tried via htmlpanel to create a chart but could not be able to send coorectly the parameters.

Thanks.

  • You must to post comments
0
0

I would not recommend using htmlpanel. Instead, use the chartJS extension. It is a nuget package. In Solution Explorer, right-click, choose “Manage Nuget Packages”, and search for “Wisej ChartJS”.

The code to add data and labels to a chartJS chart looks like this:

object[] array1 = new object[] { 1, 3, 5, 7, 9 };
chartJS1.DataSets.Add("Data Set").Data = array1;
chartJS1.Labels = new string[] {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};

See attached sample project.

Hope this helps!
-Julie

Attachment
  • Jun
    • Jun
    • Mar 19, 2024 - 12:27 pm
    hi Julie, thanks for your reply! indeed im using the extension directly, binding data as you explained in your sample. But the reason to send the parameters to a javascript funcion is to customize the graph. It seems that the nuget extension lacks properties to customize it. Thanks.
  • Frank (ITG)
    Hi Jun, what properties are you looking for to customize? Can you please wrap up a test case so we can get a better understanding? TIA, Frank
  • Jun
    • Jun
    • Mar 20, 2024 - 6:42 pm
    for example number formatting and tooltips but in serverside.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.