Jump to content
JChartFX Community
  • 0

Display total value on stacked bar chart?


OnurY
 Share

Question

Hello,

 I'm trying to display total values of bars on a stacked chart. What I mean is, there are 3 kinds of series in one bar, and I want to display the total amount of those 3. I have the total value, but I have no idea how to display it on anywhere in the chart. For normal bars, I'm using the PointLabel. But if I try to display it on a stacked bar, it will display for every single piece in the bar. 

Thanks for the help. 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Assuming you have the total value you could setup your chart with 3 stacked bars and use markers for the fourth (total) series and only show the labels for this last series, e.g

    var data = [{"Jan":10, "Feb":12, "Mar":8, "Total":30}, {"Jan":7, "Feb":15, "Mar":3, "Total":24}];

    

    chart1.setDataSource(data);

    

    // Global Attributes that will apply to all but last series

    chart1.setGallery(cfx.Gallery.Bar);

    chart1.getAllSeries().setStackedStyle(cfx.Stacked.Normal);

    

    // Attributes for last series

    var series3 = chart1.getSeries().getItem(3);

    series3.setGallery(cfx.Gallery.Scatter);

    series3.getPointLabels().setVisible(true);

    

    // Remove scatters

    series3.setMarkerShape(cfx.MarkerShape.None);

 

JuanC 

Link to comment
Share on other sites

  • 0

In the latest release notes I see..

 

- Auto-Computed Total value as a Point Label in stacked series. 

 

 

Does this mean we can place the total of all series in a stacked bar at the top of the stacked bar?

 

If so, what is the code that would toggle that on?

 

Thanks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...