Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Chart with a width defined by an equation-value in the question text box

  • doe067
  • doe067's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago #207517 by doe067
Dear Community,

is it possible to add a chart with a width defined by an equation-value in the question text box?

Problem
The situation is the following: I have two questions. The first question is from the type equation and saves a numeric positive value var_x.NAOK. In the question text box of the second question, I want to dispaly a chart. The width of the chart shall be var_x.NAOK. My objective is two show a chart where I can set the width/ size of e.g. a bar with var_x.NAOK.

Current approach
My current solution is the following:
The simple HTML-Code draws three bars. However, the width is fixed (e.g. width: 400px). I can only display the equation-value as the descritpion (e.g. ..> bar 1 {var_x.NAOK}</div>)
Code:
<h2>Bar Chart</h2>
 
<div style="font: 10px sans-serif; text-align: right; color: white;">
<div style="background: steelblue; padding: 3px; margin: 1px; width: 400px;"> bar 1 {var_x.NAOK}</div>
 
<div style="background: steelblue; padding: 3px; margin: 1px; width: 100px;"> bar 2 </div>
 
<div style="background: steelblue; padding: 3px; margin: 1px; width: 50px;"> bar 3 </div>
</div>


Version
My current version is LimeSurvey 3.22.27+200720. I am flexible in version and add-ons.

I am happy about your expert insights!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207519 by tpartner
I would be using percentages for the bar widths so it is screen-size responsive.

What value do you see for {var_x.NAOK}?

Have you tried inserting that as the width value?

Code:
<div style="background: steelblue; padding: 3px; margin: 1px; width: {var_x.NAOK}px;"> bar 1 {var_x.NAOK}</div>

Or:

Code:
<div style="background: steelblue; padding: 3px; margin: 1px; width: {var_x.NAOK}%;"> bar 1 {var_x.NAOK}</div>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose