In our JavaFX project we need a line chart. I can easy stylize the whole chart and series using CSS, but content of our chart can change dynamically:
number of series and their displaying order depends on user actions and his data. Each series represents a concrete data category and the each category has its own style, eg. category A is shown as a dotted line and category B is shown as a dashed line. The chart can contain 0 or more series for each category,
style of series depends on data values too, eg. series line over the average is red, and below is blue.
How to do it in JavaFX?
number of series and their displaying order depends on user actions and his data.
The number of series displayed and the display order can be modified by changing the ObservableList of series which you passed to the chart's setData() call. As the chart listens for changes to the list, as the backing list changes, the chart is automatically updated to reflect the changes.
each category has its own style, eg. category A is shown as a dotted line and category B is shown as a dashed line.
This can done by determining which series in the chart is in which category, looking up all nodes related to the series via the node lookupAll(cssStyleSelector) function and applying a new custom style to the series which matches the style for the category. Dotted and dashed lines can be styled via css by setting the -fx-stroke-dash-array css property. Alternately, rather than a lookup you can dynamically change the css styleclass assigned to nodes via modifying the ObservableList returned from getStyleClass().
style of series depends on data values too, eg. series line over the average is red, and below is blue.
This is similar to how the dotted and dashed lines are displayed, but instead the color of the lines are modifed by the -fx-stroke css property and the modification depends on the average values calculated for the series.
To demonstrate the above points, I created a sample solution for this question here: https://gist.github.com/2129306
I did it like this, thought it was pretty handy. Note: This apparently works on LineCharts but not ScatterCharts.
Series<Number, Number> series = new Series<>();
...
series.nodeProperty().get().setStyle("-fx-stroke-width: 1px;");
Related
As shown in the diagram based on the date if the user didn't perform any action in 3 days there must be no line between 2 points and if the action is after 2 days show a dashed line between points.
This requirement "how to add dashed and don’t show a line between marks" can be achieved by using the onCreateRenderer callback that is available in chart series. To render a dashed line for the specific segment using the current segment index value, the existing line series renderer class can be overridden with a custom line series renderer class to get all series segment index value. You can also achieve the space between the points by using empty points.
Screenshot:
Sample: https://drive.google.com/file/d/1hObaBHZi1Gvk2yeRg0XGHjmbJUWWKh3Y/view?usp=share_link
I would like to know what are the settings capabilities on workshop charts when implementing multiple layers.
Here is an example of a chart with 2 layers (3 objects):
Among the global settings options, I would like to know:
how to have only one legend per group, instead of one per layer?
how to manage colors? Is it possible to change default?
is there any way to display dotted lines for example?
Thanks in advance
how to have only one legend per group, instead of one per layer?
Currently all the legend "flattens" all the series across all the Plot Layers and there isn't any way to change the grouping. If you really wanted to, you could use a couple metric widgets in List or Tag mode and build your own legend alongside the chart, assuming you'd made overrides for all the potential series and series segments (see below).
how to manage colors? Is it possible to change default?
Yes, you can change the color for each series on the chart. If the series has no "Segement By" config, then you can choose the color directly. If you choose to segment by some other property, then you need to add a Segment Display Override for each segment value that you want to change.
is there any way to display dotted lines for example?
You can change the style from solid to dashed in the same place that you can change the color
I created a colored and patterned pie chart as described in this stack exchange Question.
Now I also want to specify an order of the categories to apear in the pie chart.
Usually this works with the sort.values funtion:
SCALE: cat(aesthetic(aesthetic.color), sort.values("value", "value",...))
However this function doesn't seem to have an effect when having both color(var)) and
texture.pattern(var) functions inside the same ELEMENT-Statement.
You also need to specify the category order for the texture.pattern. So add the line:
SCALE: cat(aesthetic(aesthetic.texture.pattern), sort.values("value", "value", ...))
Defining the category order for both, the color aesthetic and the texture.pattern aesthetic should result in the specific ordered pie chart.
Unfortunatly the order isn't applyied to the legend, which is quiet a bummer when trying to read the pie chart. I haven't figured out how or if this can be fixed.
One of my uses of Kibana is related to displaying some information in certain cases only (say when a value is unexpected and exceeds a defined range). This element is therefore either shown or hidden from the dashboard, and displaying it could be considered as displaying an alert. I would prefer if the related pie chart was filled in red, rather than the default green.
Any ideas on how to do this?
Assuming you are describing Kibana 3, if you want terms panels pie charts to use different colors, you will need to make a code change.
There is a way to have custom colors for your pie chart. In order to do that you'll need to create a "hits" panel and pick the "pie chart" as the display. The color of the pie slices will be determined by the color that you chose for the queries that they track:
I am trying to create a chart in Excel 2013 from a subset of data within a larger report. All the examples show using the headers to create the legend on the chart, but since I am just using select rows in the report, I can't utilize the headers. Is there any way to directly modify the legend, or even indirectly. I am open to any suggestions. Basically, I have a row with multiple data points that I want to graph. The title works out okay, but the legend just indicates 1 and 7 (the columns I am charting). Since I don't want to graph the entire report, I don't seem to be able to capture the column headings.
The words in the legend are sourced from the series name. You can point the series name to any cell in the spreadsheet. In the screenshot, the original series names were one, two and three. In the series definition, they got re-pointed to the cells that say blue, red and green.
Depending on your data and requirements this can be made dynamic.