Graph pens color

Can the color of a pen on a chart change based on a value?

I have a base line that is static. pen2-Value= 12000.
Pen1 is coming from a database and I would like the color of pen 1 to change if the value is below baseline.

You can change the pen colors dynamically on an Easy Chart. You are getting into one of the “advanced” aspects of FactoryPMI. To do this you’ll want to populate the pens dataSet, which is an Expert property. The column of interest is color.

The secret is that the customizer is really a user friendly interface to the pens dataset (as well as axis and subplots). Normally users configure this data statically. You are asking to dynamically populate some of the data. The important thing to take away from this post is that the pens dataSet is bindable just like any other property in FactoryPMI. The easiest approach is to create your Easy Chart manually with the customizer, copy that dataSet into a database table via a spreadsheet or manually, and bind the axis dataset of your graph to a query that reads your database table. This may seem roundabout, but it offers several advantages:

  1. You can dynamically modify pen properties. In your SELECT query you can return a color based on expression conditions such as your example.

  2. This allows you to dynamically load pens from a database table. This is how you would set up a “click to chart” setup where users can add pens to the graph before viewing it. If you get fancy, you can give users the ability to configure graph profiles, share them between users or not, store them only for the session or indefinately, etc, etc. It’s a “power user” application.


While nathan’s post is accurate, I don’t believe it answers your question. You want a single pen to be multiple colors at once. Nathan’s technique would let you dynamically color a pen, but the entire pen would get that color. You want certain ranges to be one color, and certain ranges to be another color.

The direct answer is no - you can’t have a pen be more than one color at a time. However, you can simulate this effect with the following technique:

Split the pen up into 2 mutually exclusive pens, and make sure their renderer is set to “Line w/ Gaps”. One pen will contain only the points that are above your baseline, and one pen will contain the points that are below the baseline.

To do this, simply set up 2 pens pointing to the same table/column, lets [b]say the column is called penvalue. Set one pen’s WHERE clause to: penvalue >= 12000 and the other pen’s WHERE clause to penvalue < 12000. Now set their colors different. As long as your data is fairly contiguous, the effect of a multi-colored pen will be achieved.

Hope this helps,

Carl you are correct, I want one pen to change color based on value. I have made it work, the only problem I see is the data comes from a table that is updated at 15min this is giving me a gap on the chart, I will try some real time data .

Can the easy chart bind to a dataset??

The easy chart is driven by datasets that define its pen configuration, but the actual data (date,number) points that show up on the chart are queried from the database directly.

If you want to define your own dataset of points, you’ll have to use the classic chart component - its data is defined by raw datasets of points.

Hope this helps,