You can use different chart types for each chart series by setting the chartType
property on the series itself. This overrides the chart's default chart type.
In the example below, the chart's chartType property is set to Column,
but the Downloads series overrides that to use the LineAndSymbol
chart type:
Use legend's properties to customize the appearance of the chart legend, and
the header, footer, and axis title properties to add titles
to your charts.
You can style the legend and titles using CSS. The CSS tab below shows the rules
used to customize the appearance of the legend and titles. Note that these are
SVG elements, so you have to use CSS attributes such as "fill" instead of "color."
The FlexChart has built-in support for tooltips. By default, the control displays
tooltips when the user touches or hovers the mouse on a data point.
The tooltip content is generated using a template that may contain the following
parameters:
seriesName: The name of the series that contains the chart element.
pointIndex: The index of the chart element within the series.
x: The x value of the chart element.
y: The y value of the chart element.
By default, the tooltip template is set to
<b>{seriesName}</b><br/>{x} {y},
and you can see how that works in the charts above.
In this example, we set the tooltip template to
<b>{seriesName}</b> <img src='resources/{x}.png'/><br/>{y},
which replaces the country name with the country's flag.
You can disable the chart tooltips by setting the template to an empty string.
The FlexChart automatically picks colors for each series based on the default
palette, which you can override by setting the palette property.
But you can also override the default settings by setting the style
property of any series to an object that specifies SVG styling attributes,
including fill, stroke, strokeThickness, and so on.
The Series.style property is an exception to the general rule that
all styling in Wijmo is done through CSS. The exception reflects the fact
that many charts have dynamic series, which would be impossible to style
in advance. For example, a stock chart may show series selected by the
user while running the application.
The chart in this example uses the style and symbolStyle properties
to select style attributes for each series:
Use axis properties to customize the chart's axes,
including ranges (minimum and maximum), label format, tickmark spacing, and
gridlines.
The Axis class has boolean properties that allow you to turn features on
or off (axisLine, labels, majorTickMarks, and majorGrid).
You can style the appearance of the features that are turned on using CSS.
The appearance of the FlexChart is defined in CSS. In addition to the default theme, we
include about a dozen professionally designed themes that customize the appearance of
all Wijmo controls to achieve a consistent, attractive look.
To customize the appearance of the chart, inspect the elements you want to style and
create some CSS rules that apply to those elements.
For example, if you right-click one of the labels on the X axis in IE or Chrome, you
will see that it is an element with the "wj-label" class that is contained in an
element with the "wj-axis-x" class, which is contained in the the top-level control
element that has the "wj-flexchart" class. The first CSS rule in this example uses
this information to customize the X labels. The rule selector adds the additional
requirement, that the parent element must have the "wj-flexchart" and the
"custom-flex-chart" classes. Without this, the rule would apply to all the charts on the
page.
The FlexChart allows you to select series or data points by clicking or touching them.
Use the selectionMode property to specify whether you want to allow selection
by series, by data point, or no selection at all (selection is turned off by default).
Setting the selectionMode property to Series or Point causes
the FlexChart to update the Selection property when the user clicks the
mouse, and to apply the "wj-state-selected" class to the selected chart elements.
The Selection property returns the currently selected series. To get the
currently selected data point, get the currently selected item within the
selected series using the Series.collectionView.currentItem property,
as shown in the example.
The Series class has a visibility property that allows you to
determine whether a series should be shown in the chart and in the legend, or
only in the legend, or completely hidden.
This sample shows how you can use the visibility property to toggle
the visibility of a series in the following two ways:
Clicking the legend entries:
The chart directive sets the chart's legendToggle property to true,
which toggles the visibility property of a series when its legend entry is
clicked.
Using checkboxes:
The page uses Vue directives to bind input controls directly to the visibility
property of each series.
The FlexChart uses an ICollectionView internally, so any changes you make to
the data source are automatically reflected in the chart.
In this sample, we use a timer to add items to the data source, discarding old items
to keep the total count at 200. The result is a dynamic chart that scrolls as the new
data arrives.