Jump to content
JChartFX Community
  • 0

Custom legend box for pie chart - javascript


cyberbobak
 Share

Question

2 answers to this question

Recommended Posts

  • 0

If you are passing data with json, the pie will show the first string field found in your json objects, e.g.

    var data = [{"Name":"Rolling Stones", "Sales":10},{"Name":"Pink Floyd", "Sales":8},{"Name":"Led Zeppelin", "Sales":7}];

    chart1.setDataSource(data);

    chart1.setGallery(cfx.Gallery.Pie);

The legend box (and tooltip for each pie) will show the band name.
 
If you are passing data manually you can use axisX.getLabels() as follows but I would recommend the json approach.
 
    var data = chart1.getData();
    
    data.setSeries(1);
    data.setPoints(3);
    data.setItem(0, 0, 20);
    data.setItem(0, 1, 14);
    data.setItem(0, 2, 17);
    
    chart1.setGallery(cfx.Gallery.Pie);
    
    var labels = chart1.getAxisX().getLabels();
    labels.clear();
    labels.setItem(0, "First Item");
    labels.setItem(1, "Second Item");
    labels.setItem(2, "Third Item");
 
Regards,
 
JuanC 
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...