Home forums Using CanvasJS Stack with one List of DataPoints

This topic contains 1 reply, has 2 voices, and was last updated by  Shashi Ranjan 2 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26576

    Hi! I have a little problem i don’t know how to stack a list of DataPoints in the same column.

    Here is an example of what i want to do…

    List<DataPoints> Target = new List<DataPoints>(); 
    List<DataPoints> Real = new List<DataPoints>(); 
    List<DataPoints> Projects = new List<DataPoints>(); 
    
    Target.Add(new DataPoints("Target", 500));
    
    Real.Add(new DataPoints("Real", 300));
    
    Projects.Add(new DataPoints("Project1", 50));
    Projects.Add(new DataPoints("Project2", 50));
    Projects.Add(new DataPoints("Project3", 50));
    Projects.Add(new DataPoints("Project4", 50));
    Projects.Add(new DataPoints("Project5", 100));
    
    ViewBag.Target = JsonConvert.SerializeObject(Target);
    ViewBag.Real = JsonConvert.SerializeObject(Real);
    ViewBag.Projects = JsonConvert.SerializeObject(Projects);

    And i want to get something like this

    600|
       |
    500|      +-----+
       |      |     |
    400|      |     |
       |      |     |
    300|      |     |     +-----+     +-----+
       |      |     |     |     |     |     |
    200|      |     |     |     |     +-----+
       |      |     |     |     |     +-----+
    100|      |     |     |     |     +-----+
       |      |     |     |     |     +-----+
      0|______|_____|_____|_____|_____+-----+_
               Target      Real       Projects

    I hope you can understannd my problem

    • This topic was modified 2 months, 3 weeks ago by  9Dan7. Reason: Wrong title
    #26589

    @9dan7,

    Stacked Column Charts are plotted when multiple Column Charts with aligned x values are plotted on the same scale. Using Target, Real and Project as the dataPoints of one of the dataSeries(say dataSeries1) and then creating new dataSeries(dataSeries2) for each of the Project(Project1) as its dataPoint and so on should work fine in your case. Kindly refer this gallery page for an example on a stacked column chart.


    Shashi Ranjan
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.