Jump to content
JChartFX Community
  • 0

setWidth() on Legend


cmb99
 Share

Question

Hello, trying to set width on legend docked near bottom. setHeight working fine.

thx

function loadChart(titleStr) {

chart1 = new cfx.Chart();

chart1.setGallery(cfx.Gallery.Bar);

chart1.getView3D().setEnabled(true);

var title;

title = new cfx.TitleDockable();

title.setText(titleStr);

chart1.getTitles().add(title);

title.setPlotAreaOnly(true);

var data = chart1.getData();

data.setSeries(2);

data.setPoints(2);

var items = [{

"Candidate": 0.49,

"Competing Employees": 0.85

}];

chart1.getAxisY().getLabelsFormat().setFormat(cfx.AxisFormat.Percentage);

chart1.setDataSource(items);

chart1.getAxisY().setMax(1);

chart1.getAxisX().setVisible(false);

var allSeries = chart1.getAllSeries();

var pointLabels = allSeries.getPointLabels();

pointLabels.setVisible(true);

pointLabels.setOffset("16,16");

var legend = chart1.getLegendBox()

legend.setDock(cfx.DockArea.Bottom);

legend.setWidth(100);

}

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

When the legend is docked at the bottom you cannot control its width, there is a property called PlotAreaOnly that controls if the legend should be restricted to the plotarea or use all the available space. You can also control the horizontal alignment using ContentLayout.

To set the distance between different series in the same point, setIntraSeriesGap(0) should work, note that if you want to control the distance between different points you need to use getAllSeries().setVolume(100). If none of this seem to affect your output please try posting a link to an image and include the code used to generate such image.

JuanC 

Link to comment
Share on other sites

  • 0

ok. little-by-little, I seem to be marching forward. the command is chart1.getToolTips().setEnabled(false)

now I am trying to introduce a line break into the chart title.

this does not seem to work:

var title = new cfx.TitleDockable();

title.setText("First line \n Second line");

chart1.getTitles().add(title);

Link to comment
Share on other sites

  • 0

Ok. I see now you have to add multiple titles to get line breaks.

Next item. multiple series with setColor for each one.

I thought that this example would create two series, but apparently not ?

      var chart1;

chart1 = new cfx.Chart();

chart1.setGallery(cfx.Gallery.Bar);

chart1.getView3D().setEnabled(true);

var items = [

{"Group" : "Candidate Score", "Value": 0.49},

{"Group" : "Other Candidates Score", "Value" : 0.85}

];

chart1.getAxisY().getLabelsFormat().setFormat(cfx.AxisFormat.Percentage);

chart1.setDataSource(items);

chart1.getGalleryAttributes().setIntraSeriesGap(0);

chart1.getAxisY().setMax(1);

var allSeries = chart1.getAllSeries();

allSeries.setVolume(100);

var divHolder = document.getElementById(divId);

chart1.create(divHolder);

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...