A Line chart with a highlighted section
A Line chart with a highlighted section. The highlight is achieved by covering two sides of the chart with a semi-transparent gray rectangle.
Here we have an example of a dark themed SVG Line chart that has a section of
it highlighted. The standard Line is a filled Line object that does NOT
- it uses transparency in the colors instead so that you can see datasets at
the back of other datasets.
The thing that differentiates this demo is the fact that once rendered there are two rectangles placed over the chart - one on the left-hand-side and one on the right-hand-side. This leaves a section in the middle of those two rectangles that has a highlighted appearance.
As it is on this chart, the section that's highlighted has no real meaning - but this doesn't have to be the case and it could highlight certain entries or a range on the chart (for example it could be a horizontal highlight rectangle).
responsive() function simply changes the SVG tag from being floated right to not
float: at all.
Because adding the
responsive() function means that the chart is redrawn
whenever the window size changes (ie when you resize the browser) the two covers are drawn in the
draw event and the nodes are assigned to global variables. These coverings are removed
before the chart is redrawn so they don't accumulate on top of each other.
<script src="RGraph.svg.common.core.js"></script> <script src="RGraph.svg.common.key.js"></script> <script src="RGraph.svg.line.js"></script>Put this where you want the chart to show up:
<div style="width: 600px; height: 250px; display: inline-block; background-color: black"></div>This is the code that generates the chart: