How can I use canvasjs to create a base64Image payload?

#1

Hi All,

I require to export a sparkline (once, comfortable, a candlestick chart using OHLC) to base64Image and send as part of a payload.

My plan is to use canvasjs.com (unless there's a better option), what is the best way to achieve this?

I've found a simple sample here: https://jsfiddle.net/canvasjs/erg5b3yq

My sparkline data is pretty simple, example:

{  
   "price":[  
      0.3508196109422033,
      0.3515710710876198,
      0.3521089411384712,
      0.34981720445155073,
      0.3499824148582528,
      0.3509933680788411,
      0.35050518513537915,
      0.3509995668702518,
      0.350403502353985,
      0.35015092291947075,
      0.3499815117941795,
      0.3481385999084613,
      0.3481332054708226,
      0.3494975646926544,
      0.3515371546850414,
      0.35164867292253527,
      0.3501670630812144,
      0.35169551304155683,
      0.3558710053144821,
      0.3561166713853336,
      0.3547160543837295,
      0.35558602571207115,
      0.3561278846078967,
      0.3545391309335088,
      0.35397881837861545,
      0.35597342659256126,
      0.3542019672025256,
      0.35412696214243444,
      0.3555058708870054,
      0.3540913827984396,
      0.35695298246938534,
      0.3591312550380113,
      0.3575914779281727,
      0.3538895429530578,
      0.35242524654224083,
      0.3534047043480931,
      0.35450630176406683,
      0.3513533372609075,
      0.35204363897011137,
      0.35085920398227927,
      0.33444212674692864,
      0.3379513015029158,
      0.3387218346248521,
      0.3388446032451839,
      0.3372166011899307,
      0.3378169366694606,
      0.3306037381779782,
      0.33256371238212,
      0.3303773172856674,
      0.33103139651664326,
      0.32828385709691954,
      0.33051514976748453,
      0.32966569970751797,
      0.3302914643651597,
      0.3293497655350269,
      0.3308758377903528,
      0.33065704317007566,
      0.3286235739768421,
      0.3278948066307062,
      0.3283448562299775,
      0.3298599839107897,
      0.33014745985557875,
      0.32141919602516406,
      0.32186684439941005,
      0.32455032624692387,
      0.32459309667926983,
      0.32397753915481114,
      0.3232185638467451,
      0.3229107356056557,
      0.32271949588027443,
      0.3230623119972207,
      0.3293125119009447,
      0.32722570754602237,
      0.3292530590213439,
      0.3263617453620259,
      0.328162784680512,
      0.32727882805583325,
      0.32856880399894406,
      0.3277401812491617,
      0.326108696011957,
      0.32617292734811465,
      0.32526285858329873,
      0.3250815055021967,
      0.3255348945653619,
      0.32615151001254217,
      0.3250041831015707,
      0.32580787983932535,
      0.3271289116445636,
      0.3275277570644494,
      0.3341629312372577,
      0.3305756858021523,
      0.33106677096287124,
      0.32980577714202747,
      0.3294581340313675,
      0.32789566753427735,
      0.3241774523801826,
      0.3238370965051,
      0.32586739520800456,
      0.3263378793071781,
      0.3274504304360327,
      0.32587129800630105,
      0.3247408583583424,
      0.32487646917859636,
      0.3253128396989771,
      0.32552060011662626,
      0.3245805120546109,
      0.32538762483464684,
      0.32546154110842707,
      0.3256083507602347,
      0.326336038120213,
      0.32730620917125375,
      0.325033248086963,
      0.3245714758149595,
      0.3262723841497916,
      0.32493640759531767,
      0.3238465901174184,
      0.3255736802228477,
      0.32433461588405277,
      0.3255354959135598,
      0.3255880758272545,
      0.32532516674161555,
      0.3251910419331915,
      0.3256922340327339,
      0.32492751672350206,
      0.3248268154584994,
      0.32518351643534293,
      0.3254254481104067,
      0.32551297436079446,
      0.32485709192488965,
      0.3248799613114584,
      0.3258176491230744,
      0.32812910388778027,
      0.32872483137267455,
      0.32905919963918867,
      0.33002314014702555,
      0.32826740324329956,
      0.32894862997925933,
      0.33004716415685065,
      0.3289962766309784,
      0.3291876786097238,
      0.3276436069661981,
      0.3282162620951319,
      0.32831050363247505,
      0.32571781867836785,
      0.32586177177766135,
      0.3260857044786525,
      0.3261234265853354,
      0.3263822013459963,
      0.3266253603764631,
      0.32518529768622695,
      0.31971829840678895,
      0.3191820105471056,
      0.31789919539527645,
      0.3183508639083469,
      0.31865833318216746,
      0.3192860737562137,
      0.31963345273696764,
      0.3185846914199351,
      0.3202061846758916,
      0.3198688605316002,
      0.3207375731215191,
      0.3207989234336964,
      0.3207559948173363,
      0.32057533661997284,
      0.3207740144392337,
      0.3226073272484703,
      0.3229558776771319,
      0.3199492399532361
   ]
}
#2

Just checking in to see if anyone has any ideas how I could get started with this? Is there an alternative node that can produce candlestick charts?

#3

node-red does not produce any graphics, you will need to use dashboard, ui-builder, a python script or something else to produce the graphics.